| @@ 66-79 (lines=14) @@ | ||
| 63 | self.table.create(self.engine, checkfirst=True) |
|
| 64 | self.table.indexes.clear() |
|
| 65 | ||
| 66 | @staticmethod |
|
| 67 | def _parse(data): |
|
| 68 | for key, value in list(six.iteritems(data)): |
|
| 69 | if isinstance(value, six.binary_type): |
|
| 70 | data[key] = utils.text(value) |
|
| 71 | for each in ('schedule', 'fetch', 'process', 'track'): |
|
| 72 | if each in data: |
|
| 73 | if data[each]: |
|
| 74 | if isinstance(data[each], bytearray): |
|
| 75 | data[each] = str(data[each]) |
|
| 76 | data[each] = json.loads(data[each]) |
|
| 77 | else: |
|
| 78 | data[each] = {} |
|
| 79 | return data |
|
| 80 | ||
| 81 | @staticmethod |
|
| 82 | def _stringify(data): |
|
| @@ 37-48 (lines=12) @@ | ||
| 34 | def _create_project(self, project): |
|
| 35 | collection_name = self._collection_name(project) |
|
| 36 | self.database[collection_name].ensure_index('status') |
|
| 37 | self.database[collection_name].ensure_index('taskid') |
|
| 38 | self._list_project() |
|
| 39 | ||
| 40 | def _parse(self, data): |
|
| 41 | if '_id' in data: |
|
| 42 | del data['_id'] |
|
| 43 | for each in ('schedule', 'fetch', 'process', 'track'): |
|
| 44 | if each in data: |
|
| 45 | if data[each]: |
|
| 46 | if isinstance(data[each], bytearray): |
|
| 47 | data[each] = str(data[each]) |
|
| 48 | data[each] = json.loads(data[each], encoding='utf8') |
|
| 49 | else: |
|
| 50 | data[each] = {} |
|
| 51 | return data |
|