def delDirs(self, dirs): """ Delete Directories @param dirs: directories to be created @type dirs: List of str """ self.__delActualDirs(dirs) Tagging.delTagsFromElements(self, dirs)
def delFiles(self, files, dirs=[]): """ Delete files @param files: List of files to be used @type files: List of instances of L{TagFile} """ Tagging.delElementsFromTags(self, files, tagList=dirs)
def renameDir(self, dirs1, dirs2): """ Rename directories """ fileList = Tagging.getElements(self, tagList=dirs1) Tagging.delTagsFromElements(self, dirs1, elementList=fileList) Tagging.addTags(self, elementList=fileList, newTagList=dirs2) if [dirs1[-1] != dirs2[-1]]: self.__renameActualDir(dirs1[-1], dirs2[-1])
def createDirs(self, dirs, mode=DEFAULT_DIR_MODE): """ Create Directories @param dirs: directories to be created @type dirs: List of str @param mode: Mode with which the directories are to be created, if required @type mode: int """ self.__createActualDirs(dirs, mode) Tagging.addTags(self, newTagList=dirs)
def delFilesFromDirs(self, files, dirs): """ Delete files from directories @param files: List of files to be used @type files: List of instances of L{TagFile} @param dirs: List of directories @type dirs: List of str """ self.__delActualDirs(dirs) Tagging.delTagsFromElements(self, dirs, files)
def addDirsToFiles(self, fileList, dirList, mode=DEFAULT_DIR_MODE): """ Associates the specified directories to the specified files @param fileList: List of files to be used @type fileList: List of instances of L{TagFile} @param dirList: List of directories @type dirList: List of str @param mode: Mode with which the directories are to be created, if required @type mode: int """ self.__createActualDirs(dirList, mode) Tagging.addTags(self, fileList, dirList)
def getActualLocation(self, dirs, filename): filesInDir = Tagging.getElements(self, dirs) matchingFiles = [x for x in filesInDir if x.name == filename] if len(matchingFiles) == 0: return None else: return matchingFiles[0].location
def getDirsAndFilesForDirs(self, dirList, beRestrictive=False, getCover=False): """ Get files contained in all the directories specified in dirList. Also get list of other directories which contain ANY of these files @param dirList: List of directories to be used @type dirList: List of str @param beRestrictive: Only return those directories which are NOT associated with ALL the files with which the given list of directories is associated. The philosophy behind this is, having already got a set of files associated with the given set of directories, it would be useful to find directories that would restrict the set set of directories further. This helps in creating an hierarchy of directories. Defaults to False @type beRestrictive: bool @param getCover: Get a set of directories which between them contain all the files that are contianed within the given set of directories. This helps particularly when there are large number of tags in the system. Instead of looking at 100s of directories it would be helpful to look at only those directories which cover all currently selected files. Defaults to False @type getCover: bool @return: A tuple of list of directories and list of files @rtype: (List of str, List of instances of L{TagFile}) """ return Tagging.getTagsAndElementsForTags(self, dirList, beRestrictive, getCover)
def getAllDirs(self): """ Get a list of all directories @return: List of all directories @rtype: List of str """ return Tagging.getTagsForTags(self, tagList = [])
def getAllDirs(self): """ Get a list of all directories @return: List of all directories @rtype: List of str """ return Tagging.getTagsForTags(self, tagList=[])
def getFilesForDirs(self, dirList): """ Get a list of files which are contained in all of the given directories @param dirList: Directories for which to get files @type dirList: List of str @return: List of files @rtype: List of instances of L{TagFile} """ return Tagging.getElements(self, dirList)
def getDirsForDirs(self, dirList): """ Get directories which contain the files contained in the given directories @param dirList: List of directories to be used @type dirList: List of str @return: List of all directories @rtype: List of str """ return Tagging.getTagsForTags(self, dirList)
def getDirsForFiles(self, files): """ Get directories which contain the given files @param files: List of files to be used @type files: List of instances of L{TagFile} @return: List of all directories @rtype: List of str """ return Tagging.getTagsForElements(self, files)
def __str__(self): return 'Directory helper for ' + Tagging.__str__(self)