def db_filepath(profile_paths: Dict[str, PathLike], filenames: str='places', ext='sqlite') -> Dict[str, PathLike]:
""" Yields the path for the next database file.
Exits program if browser info or profile directory path are invalid.
Accepts profile directory path.
Optional: file name(s), extensions (default is sqlite)
"""
try:
ext_joiner = '' if ext[0] in {os.extsep, '.'} else os.extsep # if a . in ext arg, doesn't add another
except (TypeError, IndexError): # if file doesn't have an ext, ext arg is empty, doesn't add the `.`
ext_joiner, ext = ('', '')
if filenames is None:
filenames = _db_files(profile_paths=profile_paths, ext=ext)
filenames = [filenames]
file_names = [ext_joiner.join([file_, ext]) for file_ in filenames]
try:
return {profile_name: os.path.join(profile_path_, file_name_) for
profile_name, profile_path_ in profile_paths.items() for file_name_ in file_names}
except TypeError as excep:
print('Missing value: browser name or profile path', excep, sep='\n')
if debug: raise excep
os.sys.exit()
paths_setup.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录