(minerName, jsonName, keyIdName=None)
| 97 | eos.db.gamedata_meta.create_all() |
| 98 | |
| 99 | def _readData(minerName, jsonName, keyIdName=None): |
| 100 | compiled_data = None |
| 101 | for i in itertools.count(0): |
| 102 | try: |
| 103 | with open(os.path.join(JSON_DIR, minerName, '{}.{}.json'.format(jsonName, i)), encoding='utf-8') as f: |
| 104 | rawData = json.load(f) |
| 105 | if i == 0: |
| 106 | compiled_data = {} if type(rawData) == dict else [] |
| 107 | if type(rawData) == dict: |
| 108 | compiled_data.update(rawData) |
| 109 | else: |
| 110 | compiled_data.extend(rawData) |
| 111 | except FileNotFoundError: |
| 112 | break |
| 113 | |
| 114 | if not keyIdName: |
| 115 | return compiled_data |
| 116 | # IDs in keys, rows in values |
| 117 | data = [] |
| 118 | for k, v in compiled_data.items(): |
| 119 | row = {} |
| 120 | row.update(v) |
| 121 | row[keyIdName] = int(k) |
| 122 | data.append(row) |
| 123 | return data |
| 124 | |
| 125 | def _addRows(data, cls, fieldMap=None): |
| 126 | if fieldMap is None: |
no test coverage detected