MCPcopy Create free account
hub / github.com/comaps/comaps / metadata

Method metadata

tools/python/mwm/mwm_python.py:238–265  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

236 return self._types
237
238 def metadata(self) -> Dict[mi.MetadataField, str]:
239 mwm = self.mwm
240 if mwm.metadata_offsets is None or self._index not in mwm.metadata_offsets:
241 return {}
242
243 old_pos = mwm.file.tell()
244 new_pos = mwm.get_tag("meta").offset + mwm.metadata_offsets[self._index]
245 mwm.file.seek(new_pos)
246 metadata = {}
247 if mwm.version().format >= 8:
248 sz = read_varuint(mwm.file)
249 for _ in range(sz):
250 t = read_varuint(mwm.file)
251 field = mi.MetadataField(t)
252 metadata[field] = read_string(mwm.file)
253 else:
254 while True:
255 t = read_uint(mwm.file, 1)
256 is_last = t & 0x80 > 0
257 t = t & 0x7F
258 l = read_uint(mwm.file, 1)
259 field = mi.MetadataField(t)
260 metadata[field] = mwm.file.read(l).decode("utf-8")
261 if is_last:
262 break
263
264 mwm.file.seek(old_pos)
265 return metadata
266
267 def names(self) -> Dict[str, str]:
268 return self._names

Callers

nothing calls this directly

Calls 6

read_varuintFunction · 0.85
read_stringFunction · 0.85
read_uintFunction · 0.85
get_tagMethod · 0.80
versionMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected