def test_get_qt_enum(self): from PyQt5.QtCore import QStandardPaths values = util.get_qt_enum(QStandardPaths, QStandardPaths.LocateOption) self.assertIn('LocateFile', values) self.assertIn('LocateDirectory', values) self.assertNotIn('DesktopLocation', values)
import os import os.path import shutil from PyQt5.QtCore import QStandardPaths from picard.util import get_qt_enum # Files not considered relevant for a directory. If a directory has only # some of these files inside it is still considered empty and can be deleted. JUNK_FILES = set([".DS_Store", "desktop.ini", "Desktop.ini", "Thumbs.db"]) # Special file system locations Picard should never delete. PROTECTED_DIRECTORIES = set() for location in get_qt_enum(QStandardPaths, QStandardPaths.StandardLocation): value = getattr(QStandardPaths, location) for path in QStandardPaths.standardLocations(value): PROTECTED_DIRECTORIES.add(os.path.realpath(path)) class SkipRemoveDir(Exception): pass def is_empty_dir(path, ignored_files=None): """ Checks if a directory is considered empty. Args: path: Path to directory to check.