Skip to content

Commit

Permalink
VCQ-183 clean up tools/misc.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
li-zhi committed Oct 10, 2023
1 parent 117b658 commit abea90d
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions python/vmaf/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,7 @@ def get_file_name_extension(path):
return Path(path).suffix[1:]


def get_normalized_path(dir_):
"""
>>> get_normalized_path('abc/xyz/')
'abc/xyz'
>>> get_normalized_path('abc/xyz')
'abc/xyz'
>>> get_normalized_path('abc/xyz.txt')
'abc/xyz.txt'
"""
if dir_[-1] == '/':
return dir_[:-1]
else:
return dir_


def get_dir_without_last_slash(path):
def get_dir_without_last_slash(path: str) -> str:
"""
>>> get_dir_without_last_slash('abc/src01_hrc01.yuv')
Expand All @@ -127,7 +110,7 @@ def get_dir_without_last_slash(path):
'abc/xyz'
"""
return "/".join(path.split("/")[:-1])
return os.path.dirname(path)


def make_parent_dirs_if_nonexist(path):
Expand Down Expand Up @@ -248,15 +231,14 @@ def import_python_file(filepath : str, override : dict = None):
return ret


def make_absolute_path(path, current_dir):
'''
def make_absolute_path(path: str, current_dir: str) -> str:
"""
>>> make_absolute_path('abc/cde.fg', '/xyz/')
'/xyz/abc/cde.fg'
>>> make_absolute_path('/abc/cde.fg', '/xyz/')
'/abc/cde.fg'
'''
"""
assert current_dir.endswith('/'), f"expect current_dir ends with '/', but is: {current_dir}"
if path[0] == '/':
return path
else:
Expand Down

0 comments on commit abea90d

Please sign in to comment.