Пример #1
0
def clean_empty_dirs(path, deleteself=False, files_to_delete=[]):
    """Recursively delete empty dirs in directory. 'directory' is deleted only
    if empty and 'deleteself' is True.
    Returns the list of delete paths.
    files_to_delete: The name is clear enough. However, files in
        this list will ONLY be deleted if it makes the directory deletable
        thereafter (In other words, if the directory contains files not in the
        list, NO file will be deleted)
    """
    result = []
    subdirs = [name for name in io.listdir(path) if io.isdir(path + name)]
    for subdir in subdirs:
        result.extend(clean_empty_dirs(path + subdir, True, files_to_delete))
    if deleteself and delete_if_empty(path, files_to_delete):
        result.append(str(path))
    return result
Пример #2
0
 def clean_empty_dirs(self, path):
     if self.options['clean_empty_dirs']:
         while delete_if_empty(path, ['.DS_Store']):
             path = path[:-1]
Пример #3
0
 def clean_empty_dirs(self, path):
     if self.options["clean_empty_dirs"]:
         while delete_if_empty(path, [".DS_Store"]):
             path = path.parent()
Пример #4
0
 def clean_empty_dirs(self, path):
     if self.options["clean_empty_dirs"]:
         while delete_if_empty(path, [".DS_Store"]):
             path = path.parent()
Пример #5
0
 def clean_empty_dirs(self, path):
     if self.options['clean_empty_dirs']:
         while delete_if_empty(path, ['.DS_Store']):
             path = path.parent()