Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
Show All 27 Lines | if cls == "local": | ||||
if "with_path" in kwargs: | if "with_path" in kwargs: | ||||
warnings.warn( | warnings.warn( | ||||
"Usage of the 'with-path' config option is deprecated. " | "Usage of the 'with-path' config option is deprecated. " | ||||
"The db flavor is now used instead.", | "The db flavor is now used instead.", | ||||
DeprecationWarning, | DeprecationWarning, | ||||
) | ) | ||||
with_path = kwargs.get("with_path") | with_path = kwargs.get("with_path") | ||||
from swh.provenance.provenance import ProvenanceBackend | from swh.provenance.backend import ProvenanceBackend | ||||
prov = ProvenanceBackend(conn) | prov = ProvenanceBackend(conn) | ||||
if with_path is not None: | if with_path is not None: | ||||
flavor = "with-path" if with_path else "without-path" | flavor = "with-path" if with_path else "without-path" | ||||
if prov.storage.flavor != flavor: | if prov.storage.flavor != flavor: | ||||
raise ValueError( | raise ValueError( | ||||
"The given flavor does not match the flavor stored in the backend." | "The given flavor does not match the flavor stored in the backend." | ||||
) | ) | ||||
return prov | return prov | ||||
else: | else: | ||||
raise NotImplementedError | raise NotImplementedError |