Conditions | 2 |
Total Lines | 51 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # -*- coding: utf-8 -*- |
||
52 | def initialize(context): |
||
53 | |||
54 | from content.aetiologicagent import AetiologicAgent |
||
55 | from content.caseoutcome import CaseOutcome |
||
56 | from content.casestatus import CaseStatus |
||
57 | from content.ethnicity import Ethnicity |
||
58 | from content.casesyndromicclassification import CaseSyndromicClassification |
||
59 | from content.disease import Disease |
||
60 | from content.doctor import Doctor |
||
61 | from content.doctors import Doctors |
||
62 | from content.drug import Drug |
||
63 | from content.drugprohibition import DrugProhibition |
||
64 | from content.identifiertype import IdentifierType |
||
65 | from content.immunization import Immunization |
||
66 | from content.insurancecompany import InsuranceCompany |
||
67 | from content.patient import Patient |
||
68 | from content.patients import Patients |
||
69 | from content.symptom import Symptom |
||
70 | from content.treatment import Treatment |
||
71 | from content.vaccinationcenter import VaccinationCenter |
||
72 | from content.vaccinationcentercontact import VaccinationCenterContact |
||
73 | |||
74 | from controlpanel.bika_aetiologicagents import AetiologicAgents |
||
75 | from controlpanel.bika_caseoutcomes import CaseOutcomes |
||
76 | from controlpanel.bika_casesyndromicclassifications import CaseSyndromicClassifications |
||
77 | from controlpanel.bika_casestatuses import CaseStatuses |
||
78 | from controlpanel.bika_diseases import Diseases |
||
79 | from controlpanel.bika_drugprohibitions import DrugProhibitions |
||
80 | from controlpanel.bika_drugs import Drugs |
||
81 | from controlpanel.bika_identifiertypes import IdentifierTypes |
||
82 | from controlpanel.bika_immunizations import Immunizations |
||
83 | from controlpanel.bika_treatments import Treatments |
||
84 | from controlpanel.bika_insurancecompanies import InsuranceCompanies |
||
85 | from controlpanel.bika_ethnicities import Ethnicities |
||
86 | from controlpanel.bika_vaccinationcenters import VaccinationCenters |
||
87 | |||
88 | content_types, constructors, ftis = process_types( |
||
89 | listTypes(PROJECTNAME), |
||
90 | PROJECTNAME) |
||
91 | |||
92 | allTypes = zip(content_types, constructors) |
||
93 | for atype, constructor in allTypes: |
||
94 | kind = "%s: Add %s" % (config.PROJECTNAME, atype.portal_type) |
||
|
|||
95 | perm_name = "Add{}".format(atype.portal_type) |
||
96 | perm = getattr(permissions, perm_name, AddPortalContent) |
||
97 | plone_utils.ContentInit(kind, |
||
98 | content_types = (atype,), |
||
99 | permission = perm, |
||
100 | extra_constructors = (constructor,), |
||
101 | fti = ftis, |
||
102 | ).initialize(context) |
||
103 |