def addFolder(self):
        if not (os.path.exists(self._favouritesFile) and os.path.exists(self._favouritesFoldersFolder)):
            return False
        
        # get name
        name = getKeyboard(default = '', heading = 'Set name')
        if not name or name == "":
            return False

        # create cfg
        virtualFolderFile = urllib.quote_plus(name) + '.cfg'
        physicalFolder = self._favouritesFoldersFolder
        virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        if os.path.exists(virtualFolderPath):
            common.showInfo('Folder already exists')
            return False
        data = [\
            '\n',
            '########################################################',
            '# ' + name.upper(),
            '########################################################'
            ]
        fu.setFileContent(virtualFolderPath, '\n'.join(data))

        # create link
        linkToFolder = self._createItem(name, 'rss', '', '', None, 'favfolders/' + virtualFolderFile)
        fu.appendFileContent(self._favouritesFile, linkToFolder)
        return True    
 def moveToFolder(self, cfgFile, item, newCfgFile):
     if os.path.exists(cfgFile) and os.path.exists(newCfgFile):
         fav = self._createFavourite(item)
         old = fu.getFileContent(cfgFile)
         new = old.replace(enc.smart_unicode(fav).encode('utf-8'),'')
         fu.setFileContent(cfgFile, new)
         fu.appendFileContent(newCfgFile, fav)
 def moveToFolder(self, cfgFile, item, newCfgFile):
     found = self._findItem(item)
     if found:
         [cfgFile, data, fav] = found
         if os.path.exists(newCfgFile):
             new = data.replace(fav,'')
             fu.setFileContent(cfgFile, new)
             fu.appendFileContent(newCfgFile, fav)
示例#4
0
 def moveToFolder(self, cfgFile, item, newCfgFile):
     found = self._findItem(item)
     if found:
         [cfgFile, data, fav] = found
         if os.path.exists(newCfgFile):
             new = data.replace(fav, '')
             fu.setFileContent(cfgFile, new)
             fu.appendFileContent(newCfgFile, fav)
    def addItem(self, item, root=None):
        target = root
        if not target:
            # if virtual folders exist
            virtualFolder = self._virtualFolderSelection()
            if virtualFolder:
                target = virtualFolder

        if target and os.path.exists(target):
            fav = self._createFavourite(item)
            fu.appendFileContent(target, fav)
示例#6
0
    def addItem(self, item, root=None):
        target = root
        if not target:
            # if virtual folders exist
            virtualFolder = self._virtualFolderSelection()
            if virtualFolder:
                target = virtualFolder

        if target and os.path.exists(target):
            fav = self._createFavourite(item)
            fu.appendFileContent(target, fav)
    def addToFavourites(self, item, label=''):
        # if virtual folders exist
        virtualFolders = self._getVirtualFoldersList()
        targetFileForFavourite = None

        if len(virtualFolders) > 0:
            targetFileForFavourite = self._virtualFolderSelection(virtualFolders)
        else:
            targetFileForFavourite = self._favouritesFile

        if targetFileForFavourite and os.path.exists(targetFileForFavourite):
            fav = self._createFavourite(item, label)
            fu.appendFileContent(targetFileForFavourite, fav)
    def _addFolder(self, name, rootFolder=None):
        # create cfg
        filename = urllib.quote_plus(fu.cleanFilename(name))
        virtualFolderFile = filename + '.cfg'
        physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
        virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        if os.path.exists(virtualFolderPath):
            prefix = filename + '-'
            suffix = '.cfg'
            virtualFolderFile = fu.randomFilename(directory=physicalFolder, prefix=prefix, suffix=suffix)
            virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        self._createVirtualFolder(name, virtualFolderPath)

        # create link
        linkToFolder = self._createItem(name, 'rss', '', '', None, 'favfolders/' + virtualFolderFile)
        if not rootFolder or os.path.normpath(rootFolder) == self._favouritesFile:
            rootFolder = self._favouritesFile
        fu.appendFileContent(rootFolder, linkToFolder)
        return True
示例#9
0
    def _addFolder(self, name, rootFolder=None):
        # create cfg
        filename = urllib.quote_plus(fu.cleanFilename(name))
        virtualFolderFile = filename + '.cfg'
        physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
        virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        if os.path.exists(virtualFolderPath):
            prefix = filename + '-'
            suffix = '.cfg'
            virtualFolderFile = fu.randomFilename(directory=physicalFolder,
                                                  prefix=prefix,
                                                  suffix=suffix)
            virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        self._createVirtualFolder(name, virtualFolderPath)

        # create link
        linkToFolder = self._createItem(name, 'rss', '', '', None,
                                        'favfolders/' + virtualFolderFile)
        if not rootFolder or os.path.normpath(
                rootFolder) == self._favouritesFile:
            rootFolder = self._favouritesFile
        fu.appendFileContent(rootFolder, linkToFolder)
        return True