| 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 json |
||
| 21 | |||
| 22 | def usage(argv): |
||
| 23 | cmd = os.path.basename(argv[0]) |
||
| 24 | print('usage: %s <config_uri> [var=value]\n' |
||
| 25 | '(example: "%s development.ini")' % (cmd, cmd)) |
||
| 26 | sys.exit(1) |
||
| 27 | |||
| 28 | |||
| 29 | def json_serial(obj): |
||
| 30 | if isinstance(obj, (datetime, date)): |
||
| 31 | return obj.isoformat() |
||
| 32 | raise TypeError(f"Type {obj} not serializable") |
||
| 33 | |||
| 34 | |||
| 35 | def initialize_providers(session): |
||
| 36 | from fixtures.data import trees, geo |
||
| 37 | from fixtures.styles_and_cultures import styles_and_cultures |
||
| 38 | from fixtures.materials import materials |
||
| 39 | from fixtures.eventtypes import eventtypes |
||
| 40 | from fixtures.heritagetypes import heritagetypes |
||
| 41 | from fixtures.periods import periods |
||
| 42 | from fixtures.species import species |
||
| 43 | from fixtures.bluebirds import bluebirds |
||
| 44 | |||
| 45 | import_provider( |
||
| 46 | trees, |
||
| 47 | session, |
||
| 48 | ConceptScheme( |
||
| 49 | id=1, |
||
| 50 | uri='urn:x-skosprovider:trees', |
||
| 51 | labels=[ |
||
| 52 | Label('Verschillende soorten bomen', 'prefLabel', 'nl'), |
||
| 53 | Label('Different types of trees', 'prefLabel', 'en') |
||
| 54 | ] |
||
| 55 | ), |
||
| 56 | ) |
||
| 57 | import_provider( |
||
| 58 | geo, |
||
| 59 | session, |
||
| 60 | ConceptScheme( |
||
| 61 | id=2, |
||
| 62 | uri='urn:x-skosprovider:geo', |
||
| 63 | labels=[ |
||
| 64 | Label('Geografie', 'prefLabel', 'nl'), |
||
| 65 | Label('Geography', 'prefLabel', 'en') |
||
| 66 | ] |
||
| 67 | ), |
||
| 68 | ) |
||
| 69 | import_provider( |
||
| 70 | styles_and_cultures, |
||
| 71 | session, |
||
| 72 | ConceptScheme( |
||
| 73 | id=3, |
||
| 74 | uri='https://id.erfgoed.net/thesauri/stijlen_en_culturen', |
||
| 75 | labels=[ |
||
| 76 | Label('Stijlen en Culturen', 'prefLabel', 'nl'), |
||
| 77 | Label('Styles and Cultures', 'prefLabel', 'en') |
||
| 78 | ] |
||
| 79 | ), |
||
| 80 | ) |
||
| 81 | import_provider( |
||
| 82 | materials, |
||
| 83 | session, |
||
| 84 | ConceptScheme( |
||
| 85 | id=4, |
||
| 86 | uri='https://id.erfgoed.net/thesauri/materialen', |
||
| 87 | labels=[ |
||
| 88 | Label('Materialen', 'prefLabel', 'nl'), |
||
| 89 | Label('Materials', 'prefLabel', 'en') |
||
| 90 | ] |
||
| 91 | ), |
||
| 92 | ) |
||
| 93 | import_provider( |
||
| 94 | eventtypes, |
||
| 95 | session, |
||
| 96 | ConceptScheme( |
||
| 97 | id=5, |
||
| 98 | uri='https://id.erfgoed.net/thesauri/gebeurtenistypes', |
||
| 99 | labels=[ |
||
| 100 | Label('Gebeurtenistypes', 'prefLabel', 'nl'), |
||
| 101 | Label('Event types', 'prefLabel', 'en') |
||
| 102 | ] |
||
| 103 | ), |
||
| 104 | ) |
||
| 105 | import_provider( |
||
| 106 | heritagetypes, |
||
| 107 | session, |
||
| 108 | ConceptScheme( |
||
| 109 | id=6, |
||
| 110 | uri='https://id.erfgoed.net/thesauri/erfgoedtypes', |
||
| 111 | labels=[ |
||
| 112 | Label('Erfgoedtypes', 'prefLabel', 'nl'), |
||
| 113 | Label('Heritage types', 'prefLabel', 'en') |
||
| 114 | ] |
||
| 115 | ), |
||
| 116 | ) |
||
| 117 | import_provider( |
||
| 118 | periods, |
||
| 119 | session, |
||
| 120 | ConceptScheme( |
||
| 121 | id=7, |
||
| 122 | uri='https://id.erfgoed.net/thesauri/dateringen', |
||
| 123 | labels=[ |
||
| 124 | Label('Dateringen', 'prefLabel', 'nl'), |
||
| 125 | Label('Periods', 'prefLabel', 'en') |
||
| 126 | ] |
||
| 127 | ), |
||
| 128 | ) |
||
| 129 | import_provider( |
||
| 130 | species, |
||
| 131 | session, |
||
| 132 | ConceptScheme( |
||
| 133 | id=8, |
||
| 134 | uri='https://id.erfgoed.net/thesauri/soorten', |
||
| 135 | labels=[ |
||
| 136 | Label('Soorten', 'prefLabel', 'nl'), |
||
| 197 | main() |