Source code for GLXShell.libs.utils
[docs]def file_exist(path):
try:
with open(path, "r"):
return True
except OSError:
return False
[docs]def size_of(size, suffix="B"):
"""
Scale bytes to its proper format
**Example:**
1253656 => '1.20MB'
1253656678 => '1.17GB'
:param size: bytes size to convert
:type size: int
:param suffix: what suffix is add at the end of the returned value
:type: str
"""
for unit in ["", "K", "M", "G", "T", "P", "E", "Z", "Y"]:
if size < 1024:
return "{size:.2f}{unit}{suffix}".format(size=size, unit=unit, suffix=suffix)
size /= 1024