Exemplo n.º 1
0
    def transfer_classes(self, instance):
        schemas = self.parse.get_schemas()

        relations = []

        for parse_schema in schemas:
            syncano_schema = ClassProcessor.create_schema(parse_schema)
            self.data.add_class(syncano_name=syncano_schema.class_name, syncano_schema=syncano_schema.schema,
                                parse_name=parse_schema['className'], parse_schema=parse_schema)

            if syncano_schema.has_relations:
                relations.append(
                    {
                        syncano_schema.class_name: syncano_schema.relations
                    }
                )

        for class_to_process in self.data.sort_classes():
            try:
                instance.classes.create(name=class_to_process.syncano_name, schema=class_to_process.syncano_schema)
            except Exception as e:
                log.warning('Class already defined in this instance: {}/{}; Using existing class'.format(
                    class_to_process.syncano_name, instance.name)
                )
                log.warning(e)

        self.set_relations(relations)
Exemplo n.º 2
0
 def _process_array_field(cls, key, value, processed_object):
     for i, item in enumerate(value):
         if isinstance(item, dict):
             if item.get('__type') == ParseFieldTypeE.POINTER:
                 log.warning('Array of pointers not supported, writing: {}'.format(item.get('objectId')))
                 value[i] = item['objectId']
     values_list = json.dumps(value)
     processed_object[key.lower()] = values_list