コード例 #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
ファイル: app_se.py プロジェクト: astrofrog/dupeguru
 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))