fix bug
This commit is contained in:
parent
c64c2f3581
commit
48c0b1f0ee
@ -35,6 +35,7 @@ def save_urls(urls, output_file, root_folder):
|
||||
"""将URL链接保存到YAML文件中"""
|
||||
with open(output_file, 'w', encoding='utf-8') as f:
|
||||
f.write(f"{root_folder}:\n")
|
||||
if has_subdirectories(urls):
|
||||
for dir_name, files in urls.items():
|
||||
if dir_name == '.':
|
||||
for file in files:
|
||||
@ -43,6 +44,9 @@ def save_urls(urls, output_file, root_folder):
|
||||
f.write(f" {dir_name.split('/')[-1]}:\n")
|
||||
for file in files:
|
||||
f.write(f" {file}\n")
|
||||
else:
|
||||
for file in urls['.']:
|
||||
f.write(f" {file}\n")
|
||||
|
||||
def parse_arguments():
|
||||
"""解析命令行参数"""
|
||||
@ -65,6 +69,10 @@ def list_files_recursive(start_path='.', exclude_files=None):
|
||||
file_paths.append(os.path.join(root, file))
|
||||
return file_paths
|
||||
|
||||
def has_subdirectories(urls):
|
||||
"""检查是否存在子文件夹"""
|
||||
return any(dir_name != '.' for dir_name in urls)
|
||||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
current_script = os.path.basename(__file__)
|
||||
|
Loading…
Reference in New Issue
Block a user