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
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
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()
def loads(cls, data): """Load a schema from a bytestring""" return cls.from_column_dicts(json_unpack(data))
def decode_from_bytes(self, data): if data is None: return None return Schema.normalise_column_dicts(json_unpack(data))