Exemple #1
0
    def cid_field_map(self):
        cid_map = {}
        for te in self.meta_tree / "fields":
            if not isinstance(te, pygit2.Blob):
                self.L.warn(
                    "cid_field_map: Unexpected TreeEntry type=%s @ meta/fields/%s",
                    te.type_str,
                    te.name,
                )
                continue

            cid = json_unpack(te.data)
            field_name = te.name
            cid_map[cid] = field_name
        return cid_map
Exemple #2
0
    def features(self):
        geom_column = self.geom_column_name

        for feature_dir in self._iter_feature_dirs():
            source_feature_dict = {}
            for attr_blob in feature_dir:
                if not hasattr(attr_blob, "data"):
                    continue
                attr = attr_blob.name
                if attr == geom_column:
                    source_feature_dict[attr] = normalise_gpkg_geom(
                        attr_blob.data)
                else:
                    source_feature_dict[attr] = json_unpack(attr_blob.data)
            yield source_feature_dict
Exemple #3
0
 def decode_from_bytes(self, data):
     if data is None:
         return None
     if self == self.BYTES:
         return data
     elif self in (self.TEXT, self.XML):
         return ensure_text(data)
     elif self == self.JSON:
         return json_unpack(data)
     elif self == self.WKT:
         return crs_util.normalise_wkt(ensure_text(data))
     else:
         try:
             return ensure_text(data)
         except UnicodeDecodeError:
             return binascii.hexlify(data).decode()
Exemple #4
0
 def loads(cls, data):
     """Load a schema from a bytestring"""
     return cls.from_column_dicts(json_unpack(data))
Exemple #5
0
 def decode_from_bytes(self, data):
     if data is None:
         return None
     return Schema.normalise_column_dicts(json_unpack(data))