本文整理汇总了Python中utils.fileUtils.setFileContent函数的典型用法代码示例。如果您正苦于以下问题:Python setFileContent函数的具体用法?Python setFileContent怎么用?Python setFileContent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFileContent函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: moveToFolder
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)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:7,代码来源:favouritesManager.py
示例2: changeFanart
def changeFanart(self, cfgFile, item, newFanart):
if os.path.exists(cfgFile):
fav = self._createFavourite(item)
newfav = self._createFavourite(item, fanart=newFanart)
old = fu.getFileContent(cfgFile)
new = old.replace(enc.smart_unicode(fav).encode('utf-8'), enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:7,代码来源:favouritesManager.py
示例3: changeLabel
def changeLabel(self, item, newLabel):
found = self._findItem(item)
if found:
item['title'] = newLabel
[cfgFile, data, fav] = found
# if it's a virtual folder, rename file, rename header, update link
if self._isVirtualFolder(item):
url = item.getInfo('url')
oldFile = self._getFullPath(url)
newFilename = urllib.quote_plus(fu.cleanFilename(newLabel))
virtualFolderFile = newFilename + '.cfg'
physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
# check if new target is valid
if os.path.exists(virtualFolderPath):
prefix = newFilename + '-'
suffix = '.cfg'
virtualFolderFile = fu.randomFilename(directory=physicalFolder, prefix=prefix, suffix=suffix)
virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
# update header
content = fu.getFileContent(oldFile)
oldHeader = self.cfgBuilder.buildHeader(item['title'])
newHeader = self.cfgBuilder.buildHeader(newLabel)
content = content.replace(oldHeader, newHeader)
# rename file
self._removeVirtualFolder(oldFile, False)
fu.setFileContent(virtualFolderPath, content)
# update link
item['url'] = self._getShortPath(virtualFolderPath)
newfav = self._createFavourite(item)
new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:32,代码来源:favouritesManager.py
示例4: changeFanart
def changeFanart(self, item, newFanart):
found = self._findItem(item)
if found:
[cfgFile, data, fav] = found
newfav = self._createFavourite(item, fanart=newFanart)
new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:7,代码来源:favouritesManager.py
示例5: changeIcon
def changeIcon(self, item, newIcon):
found = self._findItem(item)
if found:
[cfgFile, data, fav] = found
newfav = self._createFavourite(item, icon=newIcon)
new = data.replace(fav, newfav.encode("utf-8"))
fu.setFileContent(cfgFile, new)
开发者ID:hanspeder36,项目名称:HalowTV,代码行数:7,代码来源:favouritesManager.py
示例6: addFolder
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
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:28,代码来源:favouritesManager.py
示例7: moveToFolder
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)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:8,代码来源:favouritesManager.py
示例8: removeItem
def removeItem(self, item):
found = self._findItem(item)
if found:
[cfgFile, data, fav] = found
new = data.replace(fav,'')
fu.setFileContent(cfgFile, new)
# delete virtual folder
if self._isVirtualFolder(item):
self._removeVirtualFolder(item)
开发者ID:gtfamily,项目名称:gtfamily,代码行数:10,代码来源:favouritesManager.py
示例9: getSearchPhrase
def getSearchPhrase(self):
searchCache = os.path.join(common.Paths.cacheDir, 'search')
default_phrase = fu.getFileContent(searchCache)
if not default_phrase:
default_phrase = ''
search_phrase = common.showOSK(default_phrase, common.translate(30102))
if search_phrase == '':
return None
xbmc.sleep(10)
fu.setFileContent(searchCache, search_phrase)
return search_phrase
开发者ID:hackur,项目名称:SportsDevil-Fixes,代码行数:13,代码来源:main.py
示例10: getSearchPhrase
def getSearchPhrase(self):
searchCache = os.path.join(common.Paths.cacheDir, 'search')
try:
curr_phrase = fu.getFileContent(searchCache)
except:
curr_phrase = ''
search_phrase = getKeyboard(default = curr_phrase, heading = common.translate(30102))
if search_phrase == '':
return None
xbmc.sleep(10)
fu.setFileContent(searchCache, search_phrase)
return search_phrase
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:13,代码来源:main.py
示例11: do
def do(self):
if self.source and self.target:
response = None
try:
f = urllib.urlopen(self.source.file)
response = f.read()
f.close()
except:
return False
fU.setFileContent(self.target.file, response)
return True
return False
开发者ID:gtfamily,项目名称:gtfamily,代码行数:14,代码来源:syncManager.py
示例12: removeItem
def removeItem(self, item):
found = self._findItem(item)
if found:
try:
# delete virtual folder
if self._isVirtualFolder(item):
self._removeVirtualFolder(item['url'], True)
# delete link
[cfgFile, data, fav] = found
new = data.replace(fav,'')
fu.setFileContent(cfgFile, new)
return True
except:
return False
return False
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:15,代码来源:favouritesManager.py
示例13: removeItem
def removeItem(self, item):
cfgFile = self._favouritesFile
definedIn = item.getInfo('definedIn')
if definedIn and definedIn.startswith('favfolders/'):
cfgFile = os.path.join(self._favouritesFoldersFolder, definedIn.split('/')[1])
if os.path.exists(cfgFile):
fav = self._createFavourite(item)
old = fu.getFileContent(cfgFile)
new = old.replace(enc.smart_unicode(fav).encode('utf-8'),'')
fu.setFileContent(cfgFile, new)
# delete virtual folder
if self._isVirtualFolder(item):
self._removeVirtualFolder(item)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:15,代码来源:favouritesManager.py
示例14: getCustomModules
def getCustomModules(self):
head = [\
'########################################################',
'# Custom Modules #',
'########################################################',
''
]
txt = '\n'.join(head)
self.modules = []
for root, _, files in os.walk(self._customModulesFolder , topdown = False):
for name in files:
if name.endswith('.module'):
self.modules.append(name)
txt += fileUtils.getFileContent(os.path.join(root, name)) + '\n'
fileUtils.setFileContent(self._customModulesFile, txt)
开发者ID:AMOboxTV,项目名称:AMOBox.LegoBuild,代码行数:17,代码来源:customModulesManager.py
示例15: __init__
def __init__(self, favouritesFolder):
self._favouritesFolder = favouritesFolder
if not os.path.exists(self._favouritesFolder):
os.makedirs(self._favouritesFolder, 0777)
self._favouritesFile = os.path.join(self._favouritesFolder, 'favourites.cfg')
if not os.path.exists(self._favouritesFile):
data = [\
'########################################################',
'# Favourites #',
'########################################################'
]
fu.setFileContent(self._favouritesFile, '\n'.join(data))
self._favouritesFoldersFolder = os.path.join(self._favouritesFolder, 'favfolders')
if not os.path.exists(self._favouritesFoldersFolder):
os.mkdir(self._favouritesFoldersFolder)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:17,代码来源:favouritesManager.py
示例16: changeLabel
def changeLabel(self, cfgFile, item, newLabel):
if os.path.exists(cfgFile):
oldfav = self._createFavourite(item)
old = fu.getFileContent(cfgFile)
# if it's a virtual folder, change target url too; check if target already exists; rename target
# (helpful, if you want to edit files manually)
if self._isVirtualFolder(item):
url = item.getInfo('url')
oldTargetFile = os.path.join(self._favouritesFoldersFolder, url.split('/')[1])
# check if new target is valid
newTargetFile = os.path.join(self._favouritesFoldersFolder, urllib.quote_plus(newLabel) + '.cfg')
if os.path.exists(newTargetFile):
common.showInfo('Folder already exists')
return
# rename target
os.rename(oldTargetFile, newTargetFile)
# update target url
item.setInfo('url', 'favfolders/' + urllib.quote_plus(newLabel) + '.cfg')
newfav = self._createFavourite(item, title=newLabel)
new = old.replace(enc.smart_unicode(oldfav).encode('utf-8'), enc.smart_unicode(newfav).encode('utf-8'))
fu.setFileContent(cfgFile, new)
开发者ID:rollysalvana,项目名称:pampereo-xbmc-plugins,代码行数:24,代码来源:favouritesManager.py
示例17: _createVirtualFolder
def _createVirtualFolder(self, name, path):
fullPath = self._getFullPath(path)
data = self.cfgBuilder.buildHeader(name)
fu.setFileContent(fullPath, data)
开发者ID:Anniyan,项目名称:SportsDevil-Fixes,代码行数:4,代码来源:favouritesManager.py
注:本文中的utils.fileUtils.setFileContent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论