def _get_from_token(self, token): attrs = token.split(':') # "type_name:path/to/ref" if len(attrs) == 2: type_name = attrs[0] path = attrs[1] backend = self._get_backend(type_name) return backend[path] # "type_name:path/to/ref:n0c0ffee" elif len(attrs) == 3: type_name = attrs[0] path = attrs[1] hash = attrs[2] backend = self._get_backend(type_name) ref = backend[path] if ref.hash[:8] == hash: return ref else: raise RefHashMismatchError( "{}: hash does not match with: {}".format( token, ref.token)) else: return None
def _get_from_token(self, token): attrs = token.split(":") # "type_name:path/to/ref" if len(attrs) == 2: type_name = attrs[0] path = attrs[1] backend = self._get_backend(type_name) return backend[path] # "type_name:path/to/ref:n0c0ffee" elif len(attrs) == 3: type_name = attrs[0] path = attrs[1] hash = attrs[2] if hash == "embedded": return self.ref_from_embedded(type_name, path) else: backend = self._get_backend(type_name) ref = backend[path] if ref.hash[:8] == hash: return ref else: raise RefHashMismatchError( "{}: token hash does not match with stored reference hash: {}" .format(token, ref.token)) else: return None