def path_to_oid(self, path): try: if path == '': # This is a special case where repr_to_oid converts '' to the # OID z64. raise TypeError() return utils.repr_to_oid(path) except TypeError: raise ValueError('Not a valid OID path: `%s`' % path)
def splitBlobFilename(self, filename): """Returns the oid and tid for a given blob filename. If the filename cannot be recognized as a blob filename, (None, None) is returned. """ if not filename.endswith(BLOB_SUFFIX): return None, None path, filename = os.path.split(filename) oid = self.getOIDForPath(path) serial = filename[:-len(BLOB_SUFFIX)] serial = utils.repr_to_oid(serial) return oid, serial
def oid(o): repr = '%016x' % o return repr_to_oid(repr)