本文整理汇总了Python中pyaid.file.FileUtils.FileUtils.getContents方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.getContents方法的具体用法?Python FileUtils.getContents怎么用?Python FileUtils.getContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.file.FileUtils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.getContents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateAppExtensions
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def updateAppExtensions(cls, descriptorPath, extensionIDs):
s = []
offset = '\n '
for eid in extensionIDs:
s.append('<extensionID>%s</extensionID>' % eid)
print 'EXTENSIONS:', s
data = FileUtils.getContents(descriptorPath)
data = cls.APP_EXTENSION_PATTERN.sub(
'\g<prefix>' + offset + offset.join(s) + '\n \g<suffix>', data)
return FileUtils.putContents(data, descriptorPath)
示例2: updateAppIconList
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def updateAppIconList(cls, descriptorPath, iconDefs):
s = []
offset = '\n '
for icon in iconDefs:
size = icon['size']
name = icon['name']
s.append('<image%sx%s>icons/%s</image%sx%s>' % (size, size, name, size, size))
data = FileUtils.getContents(descriptorPath)
data = cls.APP_ICON_PATTERN.sub(
'\g<prefix>' + offset + offset.join(s) + '\n \g<suffix>', data)
return FileUtils.putContents(data, descriptorPath)
示例3: _deployWalker
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def _deployWalker(self, args, path, names):
"""Doc..."""
# Skip CDN file uploads when not walking the CDN root path explicitly
if not args['cdn'] and path.find(StaticFlowEnvironment.CDN_ROOT_PREFIX) != -1:
return
for name in names:
namePath = FileUtils.createPath(path, name)
if os.path.isdir(namePath) or StringUtils.ends(name, self._SKIP_EXTENSIONS):
continue
headersPath = namePath + '.headers'
if os.path.exists(headersPath):
headers = JSON.fromFile(headersPath)
else:
headers = dict()
if self._forceAll:
lastModified = None
elif self._forceHtml and StringUtils.ends(name, self._FORCE_HTML_EXTENSIONS):
lastModified = None
else:
lastModified = ArgsUtils.extract('_LAST_MODIFIED', None, headers)
if lastModified:
lastModified = TimeUtils.webTimestampToDateTime(lastModified)
kwargs = dict(
key=u'/' + namePath[len(self._localRootPath):].replace(u'\\', u'/').strip(u'/'),
maxAge=headers.get('max-age', -1),
eTag=headers.get('eTag', None),
expires=headers.get('Expires'),
newerThanDate=lastModified,
policy=S3Bucket.PUBLIC_READ)
if StringUtils.ends(name, self._STRING_EXTENSIONS):
result = self._bucket.put(
contents=FileUtils.getContents(namePath),
zipContents=True,
**kwargs)
else:
result = self._bucket.putFile(filename=namePath, **kwargs)
if result:
self._logger.write(u'DEPLOYED: ' + unicode(namePath) + u'->' + unicode(kwargs['key']))
示例4: compileCss
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def compileCss(cls, site, path):
outPath = FileUtils.changePathRoot(
path, site.sourceWebRootPath, site.targetWebRootPath)
FileUtils.getDirectoryOf(outPath, createIfMissing=True)
if site.isLocal:
shutil.copy(path, outPath)
site.writeLogSuccess(u'COPIED', unicode(path))
else:
cmd = cls.modifyNodeCommand([
FileUtils.createPath(
StaticFlowEnvironment.nodePackageManagerPath, 'minify', isFile=True),
'"%s"' % path,
'"%s"' % outPath])
iniDirectory = os.curdir
os.chdir(os.path.dirname(path))
result = SystemUtils.executeCommand(cmd)
if result['code']:
site.logger.write(unicode(result['error']))
site.writeLogError(u'CSS compilation failure:', extras={
'PATH':path,
'ERROR':result['error']})
os.chdir(iniDirectory)
return False
site.writeLogSuccess(u'COMPRESSED', unicode(path))
os.chdir(iniDirectory)
source = FileUtils.getContents(outPath)
if not source:
return False
FileUtils.putContents(
cls._CSS_CDN_IMAGE_RE.sub('url(\g<quote>' + site.cdnRootUrl + '/', source),
outPath)
lastModified = FileUtils.getUTCModifiedDatetime(path)
SiteProcessUtils.createHeaderFile(outPath, lastModified)
cls.copyToCdnFolder(outPath, site, lastModified)
return True
示例5: updateAppFilename
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def updateAppFilename(cls, descriptorPath, filename, contentFilename):
data = FileUtils.getContents(descriptorPath)
data = cls.FILENAME_PATTERN.sub('\g<prefix>' + filename + '\g<suffix>', data)
data = cls.CONTENT_FILENAME_PATTERN.sub('\g<prefix>' + contentFilename + '.swf\g<suffix>', data)
return FileUtils.putContents(data, descriptorPath)
示例6: updateAppId
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def updateAppId(cls, descriptorPath, appId):
data = FileUtils.getContents(descriptorPath)
data = cls.APP_ID_PATTERN.sub('\g<prefix>' + appId + '\g<suffix>', data)
return FileUtils.putContents(data, descriptorPath)
示例7: updateDescriptorNamespace
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getContents [as 别名]
def updateDescriptorNamespace(cls, descriptorPath, airVersion):
data = FileUtils.getContents(descriptorPath)
data = cls.DESCRIPTOR_VERSION_PATTERN.sub('\g<prefix>' + airVersion + '\g<suffix>', data)
return FileUtils.putContents(data, descriptorPath)