本文整理汇总了Python中folder.Folder.add_file方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.add_file方法的具体用法?Python Folder.add_file怎么用?Python Folder.add_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类folder.Folder
的用法示例。
在下文中一共展示了Folder.add_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: walk_through_folders
# 需要导入模块: from folder import Folder [as 别名]
# 或者: from folder.Folder import add_file [as 别名]
def walk_through_folders(parent_folder, configuration_folder_structure, root_folder_name):
if type(parent_folder) is not str:
raise Exception
if type(root_folder_name) is not str:
raise Exception
if type(configuration_folder_structure) is not ConfigurationFolder:
raise Exception
current_folder = Folder(root_folder_name)
for dir in os.listdir(parent_folder):
path = os.path.join(parent_folder, dir)
if os.path.isdir(path):
folder = Folder(dir)
temp_conf_folder = None
for conf_folder in configuration_folder_structure.all_folders():
if str(folder) == str(conf_folder):
if conf_folder.is_excluded():
break
else:
current_folder.add_folder(walk_through_folders(os.path.join(str(parent_folder), str(folder)), conf_folder, str(folder)))
break
if os.path.isfile(path):
file = File(dir)
is_excluded = True
for extension in configuration_folder_structure.all_extensions():
if extension == file.extension():
is_excluded = False
break
is_excluded_file = False
for conf_file in configuration_folder_structure.all_files():
if str(file) == str(conf_file):
if conf_file.is_excluded():
is_excluded_file = True
break
if is_excluded is False and is_excluded_file is False:
current_folder.add_file(file)
return current_folder