예제 #1
0
파일: util.py 프로젝트: hsoft/musicguru
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
파일: util.py 프로젝트: hsoft/musicguru
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
예제 #3
0
파일: _phys.py 프로젝트: hsoft/musicguru
 def _fetch_subitems(self):
     try:
         items = io.listdir(self.path)
         bogus_names = [name for name in items if not isinstance(name, str)]
         if bogus_names:
             logging.warning("Encountered files with the wrong encoding: %r", bogus_names)
             items = (name for name in items if isinstance(name, str))                
         items = (name for name in items if not io.islink(self.path + name))
         subdirs = []
         subfiles = []
         for name in items:
             if io.isdir(self.path + name):
                 subdirs.append(name)
             else:
                 subfiles.append(name)
         return (subdirs, subfiles)
     except OSError:
         if self.parent is not None:
             return ([], [])
         else:
             raise fs.InvalidPath(self)
예제 #4
0
 def can_handle(cls, path):
     return not io.islink(path) and io.isdir(path) and is_bundle(str(path))
예제 #5
0
파일: app_se.py 프로젝트: stevexyz/dupeguru
 def can_handle(cls, path):
     return not io.islink(path) and io.isdir(path) and is_bundle(str(path))