MCPcopy Create free account
hub / github.com/modelscope/modelscope / get_file_size

Function get_file_size

modelscope/utils/file_utils.py:191–206  ·  view source on GitHub ↗
(file_path_or_obj: Union[str, Path, bytes, BinaryIO])

Source from the content-addressed store, hash-verified

189
190
191def get_file_size(file_path_or_obj: Union[str, Path, bytes, BinaryIO]) -> int:
192 if isinstance(file_path_or_obj, (str, Path)):
193 file_path = Path(file_path_or_obj)
194 return file_path.stat().st_size
195 elif isinstance(file_path_or_obj, bytes):
196 return len(file_path_or_obj)
197 elif isinstance(file_path_or_obj, io.BufferedIOBase):
198 current_position = file_path_or_obj.tell()
199 file_path_or_obj.seek(0, os.SEEK_END)
200 size = file_path_or_obj.tell()
201 file_path_or_obj.seek(current_position)
202 return size
203 else:
204 raise TypeError(
205 'Unsupported type: must be string, Path, bytes, or io.BufferedIOBase'
206 )
207
208
209def get_file_hash(

Callers 1

get_file_hashFunction · 0.85

Calls 2

tellMethod · 0.80
seekMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…