本文整理汇总了Python中pyaid.file.FileUtils.FileUtils.changePathRoot方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.changePathRoot方法的具体用法?Python FileUtils.changePathRoot怎么用?Python FileUtils.changePathRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyaid.file.FileUtils.FileUtils
的用法示例。
在下文中一共展示了FileUtils.changePathRoot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _copyWalker
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import changePathRoot [as 别名]
def _copyWalker(self, walkData):
staticFolder = False
for folder in self._staticPaths:
path = FileUtils.cleanupPath(walkData.folder, isDir=True)
folder = FileUtils.cleanupPath(folder, isDir=True)
if path == folder or FileUtils.isInFolder(path, folder):
staticFolder = True
break
copiedNames = []
for item in walkData.names:
if not staticFolder and not StringUtils.ends(item, self._FILE_COPY_TYPES):
continue
sourcePath = FileUtils.createPath(walkData.folder, item)
if os.path.isdir(sourcePath):
continue
destPath = FileUtils.changePathRoot(
sourcePath, self.sourceWebRootPath, self.targetWebRootPath)
try:
FileUtils.getDirectoryOf(destPath, createIfMissing=True)
shutil.copy(sourcePath, destPath)
lastModified = FileUtils.getUTCModifiedDatetime(sourcePath)
SiteProcessUtils.createHeaderFile(destPath, lastModified)
SiteProcessUtils.copyToCdnFolder(destPath, self, lastModified)
copiedNames.append(item)
except Exception, err:
self.writeLogError(u'Unable to copy file', error=err, extras={
'SOURCE':sourcePath,
'TARGET':destPath })
return
示例2: compileCss
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import changePathRoot [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
示例3: compileCoffeescript
# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import changePathRoot [as 别名]
def compileCoffeescript(cls, site, path):
csPath = FileUtils.cleanupPath(path, isFile=True)
outPath = FileUtils.changePathRoot(
csPath[:-6] + 'js', site.sourceWebRootPath, site.targetWebRootPath)
FileUtils.getDirectoryOf(outPath, createIfMissing=True)
outDir = os.path.dirname(outPath)
result = cls.compileCoffeescriptFile(csPath, outDir, minify=not site.isLocal)
if result['code']:
site.writeLogError(u'Failed to compile: "%s"' % unicode(path))
print result
return False
else:
site.writeLogSuccess(u'COMPILED', unicode(path))
lastModified = FileUtils.getUTCModifiedDatetime(csPath)
SiteProcessUtils.createHeaderFile(outPath, lastModified)
if site.isLocal:
return True
cls.copyToCdnFolder(outPath, site, lastModified)
site.writeLogSuccess(u'COMPRESSED', unicode(outPath))
return True