| Conditions | 2 |
| Total Lines | 115 |
| Code Lines | 91 |
| 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 | import os |
||
| 21 | def main(argv=sys.argv): |
||
| 22 | from fixtures.data import trees, geo |
||
| 23 | from fixtures.styles_and_cultures import styles_and_cultures |
||
| 24 | from fixtures.materials import materials |
||
| 25 | from fixtures.eventtypes import eventtypes |
||
| 26 | from fixtures.heritagetypes import heritagetypes |
||
| 27 | from fixtures.periods import periods |
||
| 28 | from fixtures.species import species |
||
| 29 | if len(argv) < 2: |
||
| 30 | usage(argv) |
||
| 31 | config_uri = argv[1] |
||
| 32 | options = parse_vars(argv[2:]) |
||
| 33 | setup_logging(config_uri) |
||
| 34 | settings = get_appsettings(config_uri, options=options) |
||
| 35 | engine = engine_from_config(settings, 'sqlalchemy.') |
||
| 36 | db_session = sessionmaker(bind=engine)() |
||
| 37 | import_provider( |
||
| 38 | trees, |
||
| 39 | ConceptScheme( |
||
| 40 | id=1, |
||
| 41 | uri='urn:x-skosprovider:trees', |
||
| 42 | labels=[ |
||
| 43 | Label('Verschillende soorten bomen', 'prefLabel', 'nl'), |
||
| 44 | Label('Different types of trees', 'prefLabel', 'en') |
||
| 45 | ] |
||
| 46 | ), |
||
| 47 | db_session |
||
| 48 | ) |
||
| 49 | import_provider( |
||
| 50 | geo, |
||
| 51 | ConceptScheme( |
||
| 52 | id=2, |
||
| 53 | uri='urn:x-skosprovider:geo', |
||
| 54 | labels=[ |
||
| 55 | Label('Geografie', 'prefLabel', 'nl'), |
||
| 56 | Label('Geography', 'prefLabel', 'en') |
||
| 57 | ] |
||
| 58 | ), |
||
| 59 | db_session |
||
| 60 | ) |
||
| 61 | import_provider( |
||
| 62 | styles_and_cultures, |
||
| 63 | ConceptScheme( |
||
| 64 | id=3, |
||
| 65 | uri='https://id.erfgoed.net/thesauri/stijlen_en_culturen', |
||
| 66 | labels=[ |
||
| 67 | Label('Stijlen en Culturen', 'prefLabel', 'nl'), |
||
| 68 | Label('Styles and Cultures', 'prefLabel', 'en') |
||
| 69 | ] |
||
| 70 | ), |
||
| 71 | db_session |
||
| 72 | ) |
||
| 73 | import_provider( |
||
| 74 | materials, |
||
| 75 | ConceptScheme( |
||
| 76 | id=4, |
||
| 77 | uri='https://id.erfgoed.net/thesauri/materialen', |
||
| 78 | labels=[ |
||
| 79 | Label('Materialen', 'prefLabel', 'nl'), |
||
| 80 | Label('Materials', 'prefLabel', 'en') |
||
| 81 | ] |
||
| 82 | ), |
||
| 83 | db_session |
||
| 84 | ) |
||
| 85 | import_provider( |
||
| 86 | eventtypes, |
||
| 87 | ConceptScheme( |
||
| 88 | id=5, |
||
| 89 | uri='https://id.erfgoed.net/thesauri/gebeurtenistypes', |
||
| 90 | labels=[ |
||
| 91 | Label('Gebeurtenistypes', 'prefLabel', 'nl'), |
||
| 92 | Label('Event types', 'prefLabel', 'en') |
||
| 93 | ] |
||
| 94 | ), |
||
| 95 | db_session |
||
| 96 | ) |
||
| 97 | import_provider( |
||
| 98 | heritagetypes, |
||
| 99 | ConceptScheme( |
||
| 100 | id=6, |
||
| 101 | uri='https://id.erfgoed.net/thesauri/erfgoedtypes', |
||
| 102 | labels=[ |
||
| 103 | Label('Erfgoedtypes', 'prefLabel', 'nl'), |
||
| 104 | Label('Heritage types', 'prefLabel', 'en') |
||
| 105 | ] |
||
| 106 | ), |
||
| 107 | db_session |
||
| 108 | ) |
||
| 109 | import_provider( |
||
| 110 | periods, |
||
| 111 | ConceptScheme( |
||
| 112 | id=7, |
||
| 113 | uri='https://id.erfgoed.net/thesauri/dateringen', |
||
| 114 | labels=[ |
||
| 115 | Label('Dateringen', 'prefLabel', 'nl'), |
||
| 116 | Label('Periods', 'prefLabel', 'en') |
||
| 117 | ] |
||
| 118 | ), |
||
| 119 | db_session |
||
| 120 | ) |
||
| 121 | import_provider( |
||
| 122 | species, |
||
| 123 | ConceptScheme( |
||
| 124 | id=8, |
||
| 125 | uri='https://id.erfgoed.net/thesauri/soorten', |
||
| 126 | labels=[ |
||
| 127 | Label('Soorten', 'prefLabel', 'nl'), |
||
| 128 | Label('Species', 'prefLabel', 'en') |
||
| 129 | ] |
||
| 130 | ), |
||
| 131 | db_session |
||
| 132 | ) |
||
| 133 | db_session.commit() |
||
| 134 | db_session.close() |
||
| 135 | print('--atramhasis-db-initialized--') |
||
| 136 |