当前位置: 首页>>代码示例>>Python>>正文


Python FileUtils.getUTCModifiedDatetime方法代码示例

本文整理汇总了Python中pyaid.file.FileUtils.FileUtils.getUTCModifiedDatetime方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.getUTCModifiedDatetime方法的具体用法?Python FileUtils.getUTCModifiedDatetime怎么用?Python FileUtils.getUTCModifiedDatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyaid.file.FileUtils.FileUtils的用法示例。


在下文中一共展示了FileUtils.getUTCModifiedDatetime方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _copyWalker

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getUTCModifiedDatetime [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
开发者ID:sernst,项目名称:StaticFlow,代码行数:36,代码来源:Site.py

示例2: compileCss

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getUTCModifiedDatetime [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
开发者ID:sernst,项目名称:StaticFlow,代码行数:42,代码来源:SiteProcessUtils.py

示例3: compileCoffeescript

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getUTCModifiedDatetime [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
开发者ID:sernst,项目名称:StaticFlow,代码行数:26,代码来源:SiteProcessUtils.py

示例4: _runImpl

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getUTCModifiedDatetime [as 别名]
    def _runImpl(self):
        if not os.path.exists(self.targetWebRootPath):
            os.makedirs(self.targetWebRootPath)

        for staticPath in self.get('STATIC_PATHS', []):
            self._staticPaths.append(FileUtils.createPath(
                self.sourceWebRootPath,
                *staticPath.strip(u'/').split(u'/')))

        #-------------------------------------------------------------------------------------------
        # COPY FILES
        #       Copies files from the source folders to the target root folder, maintaining folder
        #       structure in the process
        FileUtils.walkPath(self.sourceWebRootPath, self._copyWalker)

        #--- COMMON FILES ---#
        copies = [
            (u'StaticFlow Javascript', 'web/js', 'js/sflow'),
            (u'StaticFlow CSS', 'web/css', 'css/sflow') ]

        for item in copies:
            source = FileUtils.createPath(
                StaticFlowEnvironment.rootResourcePath, *item[1].split('/'), isDir=True)
            target = FileUtils.createPath(
                self.targetWebRootPath, *item[2].split('/'), isDir=True)

            if os.path.exists(target):
                SystemUtils.remove(target)

            targetFolder = FileUtils.createPath(target, '..', isDir=True)
            if not os.path.exists(targetFolder):
                os.makedirs(targetFolder)

            fileList = FileUtils.mergeCopy(source, target)
            for path, data in fileList.files.iteritems():
                SiteProcessUtils.copyToCdnFolder(
                    path, self, FileUtils.getUTCModifiedDatetime(source))

            self.writeLogSuccess(u'COPIED', u'%s | %s -&gt; %s' % (
                item[0], source.rstrip(os.sep), target.rstrip(os.sep) ))

        #-------------------------------------------------------------------------------------------
        # COMPILE
        #       Compiles source files to the target root folder
        currentPath = os.curdir
        os.path.walk(self.sourceWebRootPath, self._compileWalker, None)
        os.chdir(currentPath)

        #-------------------------------------------------------------------------------------------
        # CREATE PAGE DEFS
        #       Creates the page data files that define the pages to be generated
        os.path.walk(self.sourceWebRootPath, self._htmlDefinitionWalker, None)
        self._pages.process()

        self._sitemap.write()
        self._robots.write()

        for rssGenerator in self._rssGenerators:
            rssGenerator.write()

        self._writeGoogleFiles()

        #-------------------------------------------------------------------------------------------
        # CLEANUP
        #       Removes temporary and excluded file types from the target root folder
        os.path.walk(self.targetWebRootPath, self._cleanupWalker, dict())

        return True
开发者ID:sernst,项目名称:StaticFlow,代码行数:70,代码来源:Site.py


注:本文中的pyaid.file.FileUtils.FileUtils.getUTCModifiedDatetime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。