def migrate_sample(self, data): if not data.get('name'): data['name'] = (data.get('id', data.get('page_id', u'')[:20]) or strip_json(self.context['path'].split('/')[-1])) version = data.get('version', '') if version == '0.13.0' or version >= '0.13.1': return data if any(body in data for body in ('original_body', 'rendered_body')): self._migrate_html(self, data) schemas = json.load(self.context['storage'].open('items.json')) if version >= '0.13.0': return data if 'id' not in data: data['id'] = data['name'] annotations = (data.pop('plugins', {}).get('annotations-plugin', {}) .get('extracts', [])) items = [a for a in annotations if a.get('item_container')] if items: return data extractors = json.load(self.context['storage'].open_with_default( 'extractors.json', {})) sample, new_schemas = port_sample(data, schemas, extractors) self._add_schemas(self, new_schemas) self.save_raw(self, sample) return sample
def migrate_sample(self, data): if not data.get('name'): data['name'] = data.get('id', data.get('page_id', u'')[:20]) if data.get('version', '') >= '0.13.1': return data if any(body in data for body in ('original_body', 'rendered_body')): self._migrate_html(self, data) schemas = json.load(self.context['storage'].open('items.json')) if data.get('version', '') > '0.13.0': schema_id, new_schemas = guess_schema(data, schemas) self._add_schemas(self, new_schemas) # Add the most likely schema id to the base containers if needed self._populate_schema_id(data, schema_id) data = repair_ids(data) return data if 'id' not in data: data['id'] = data['name'] annotations = (data.pop('plugins', {}).get('annotations-plugin', {}) .get('extracts', [])) items = [a for a in annotations if a.get('item_container')] if items: return data extractors = json.load(self.context['storage'].open_with_default( 'extractors.json', {})) sample, new_schemas = port_sample(data, schemas, extractors) self._add_schemas(self, new_schemas) self.save_raw(self, sample) return sample
def migrate_sample(self, data): if not data.get('name'): data['name'] = (data.get('id', data.get('page_id', u'')[:20]) or strip_json(self.context['path'].split('/')[-1])) version = data.get('version', '') if version == '0.13.0' or version >= '0.13.1': return data if any(body in data for body in ('original_body', 'rendered_body')): self._migrate_html(self, data) schemas = json.load(self.context['storage'].open('items.json')) if version >= '0.13.0': return data if 'id' not in data: data['id'] = data['name'] annotations = (data.pop('plugins', {}).get('annotations-plugin', {}).get('extracts', [])) items = [a for a in annotations if a.get('item_container')] if items: return data extractors = json.load(self.context['storage'].open_with_default( 'extractors.json', {})) sample, new_schemas = port_sample(data, schemas, extractors) self._add_schemas(self, new_schemas) self.save_raw(self, sample) return sample