Skip to content

Commit

Permalink
feat:get_real_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Dec 13, 2024
1 parent e3ec321 commit fea4557
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,21 @@ def get_name_url(content, pattern, multiline=False, check_url=True):
return channels


def get_real_path(path) -> str:
"""
Get the real path
"""
dir_path, file = os.path.split(path)
user_real_path = os.path.join(dir_path, 'user_' + file)
real_path = user_real_path if os.path.exists(user_real_path) else path
return real_path


def get_urls_from_file(path: str) -> list:
"""
Get the urls from file
"""
real_path = resource_path(path)
real_path = get_real_path(resource_path(path))
urls = []
url_pattern = constants.url_pattern
if os.path.exists(real_path):
Expand All @@ -562,7 +572,7 @@ def get_name_urls_from_file(path: str) -> dict[str, list]:
"""
Get the name and urls from file
"""
real_path = resource_path(path)
real_path = get_real_path(resource_path(path))
name_urls = defaultdict(list)
txt_pattern = constants.txt_pattern
if os.path.exists(real_path):
Expand Down

0 comments on commit fea4557

Please sign in to comment.