MCPcopy
hub / github.com/XPixelGroup/DiffBIR / _format_path

Method _format_path

diffbir/dataset/file_backend.py:78–89  ·  view source on GitHub ↗

Convert a ``filepath`` to standard format of petrel oss. If the ``filepath`` is concatenated by ``os.path.join``, in a Windows environment, the ``filepath`` will be the format of 's3://bucket_name\\image.jpg'. By invoking :meth:`_format_path`, the above ``filepath``

(self, filepath: str)

Source from the content-addressed store, hash-verified

76 return filepath
77
78 def _format_path(self, filepath: str) -> str:
79 """Convert a ``filepath`` to standard format of petrel oss.
80
81 If the ``filepath`` is concatenated by ``os.path.join``, in a Windows
82 environment, the ``filepath`` will be the format of
83 's3://bucket_name\\image.jpg'. By invoking :meth:`_format_path`, the
84 above ``filepath`` will be converted to 's3://bucket_name/image.jpg'.
85
86 Args:
87 filepath (str): Path to be formatted.
88 """
89 return re.sub(r'\\+', '/', filepath)
90
91 def get(self, filepath: Union[str, Path]) -> bytes:
92 """Read data from a given ``filepath`` with 'rb' mode.

Callers 1

getMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected