MCPcopy
hub / github.com/zju3dv/4K4D / get_local_path

Method get_local_path

easyvolcap/engine/file_client.py:725–749  ·  view source on GitHub ↗

Download a file from ``filepath``. ``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It can be called with ``with`` statement, and when exists from the ``with`` statement, the temporary path will be released. Args: filepath (str): Down

(
            self, filepath: str)

Source from the content-addressed store, hash-verified

723
724 @contextmanager
725 def get_local_path(
726 self, filepath: str) -> Generator[Union[str, Path], None, None]:
727 """Download a file from ``filepath``.
728
729 ``get_local_path`` is decorated by :meth:`contxtlib.contextmanager`. It
730 can be called with ``with`` statement, and when exists from the
731 ``with`` statement, the temporary path will be released.
732
733 Args:
734 filepath (str): Download a file from ``filepath``.
735
736 Examples:
737 >>> client = HTTPBackend()
738 >>> # After existing from the ``with`` clause,
739 >>> # the path will be removed
740 >>> with client.get_local_path('http://path/of/your/file') as path:
741 ... # do something here
742 """
743 try:
744 f = tempfile.NamedTemporaryFile(delete=False)
745 f.write(self.get(filepath))
746 f.close()
747 yield f.name
748 finally:
749 os.remove(f.name)
750
751
752class FileClient:

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
writeMethod · 0.45
closeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected