本文整理匯總了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