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


Python FileUtils.cleanupPath方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def __init__(self, containerPath, isRemoteDeploy =False, sourceRootFolder ='src', **kwargs):
        """Creates a new instance of Site."""
        super(Site, self).__init__()

        self.errorCount     = 0
        self.warningCount   = 0
        self._staticPaths   = []

        self._logger = ArgsUtils.getLogger(self, kwargs)
        self._sourceRootFolderName = sourceRootFolder

        # NGinx root path in which all files reside
        self._containerPath = FileUtils.cleanupPath(containerPath, isDir=True)

        # Location of the source files used to create the website
        self._sourceWebRootPath = FileUtils.createPath(containerPath, sourceRootFolder, isDir=True)

        # Locations where files should be deployed. If the target root path is None, which is the
        # default value, the local web root path is used in its place.

        if isRemoteDeploy:
            self._targetWebRootPath = FileUtils.cleanupPath(
                tempfile.mkdtemp(prefix='staticFlow_'), isDir=True)
        else:
            self._targetWebRootPath = None

        self._localWebRootPath  = FileUtils.createPath(
            containerPath, ArgsUtils.get('localRootFolder', 'root', kwargs), isDir=True)

        path = FileUtils.createPath(self.sourceWebRootPath, '__site__.def', isFile=True)
        try:
            self._data.data = JSON.fromFile(path, throwError=True)
        except Exception, err:
            self.writeLogError(u'Unable to load site definition file: "%s"' % path, error=err)
            pass
开发者ID:sernst,项目名称:StaticFlow,代码行数:37,代码来源:Site.py

示例2: _copyWalker

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [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

示例3: path

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
 def path(self):
     if not self._path:
         return None
     if not StringUtils.ends(self._path, '.csv'):
         if not FileUtils.getFileExtension(self._path):
             self._path += '.csv'
     return FileUtils.cleanupPath(self._path, isFile=True)
开发者ID:sernst,项目名称:Cadence,代码行数:9,代码来源:CsvWriter.py

示例4: __init__

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def __init__(self, localRootPath, sourceWebRootPath, forceHtml =False, forceAll =False, **kwargs):
        """Creates a new instance of S3SiteDeployer."""
        self._logger            = ArgsUtils.getLogger(self, kwargs)
        self._localRootPath     = FileUtils.cleanupPath(localRootPath, isDir=True)
        self._sourceWebRootPath = FileUtils.cleanupPath(sourceWebRootPath, isDir=True)
        self._forceHtml         = forceHtml
        self._forceAll          = forceAll
        self._cdnRootPath       = None

        try:
            siteData = JSON.fromFile(FileUtils.createPath(
                sourceWebRootPath, '__site__.def', isFile=True), throwError=True)
        except Exception, err:
            self._logger.writeError(
                u'Failed to read __site__.def file. Check to make sure JSON is valid.', err)
            siteData = {}
开发者ID:sernst,项目名称:StaticFlow,代码行数:18,代码来源:S3SiteDeployer.py

示例5: initializeFromInternalPath

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def initializeFromInternalPath(cls, referencePath, force =False):
        """ Used to explicitly initialiize the pyglass environment when running inside the source
            code respository with a standard structure where the repository root has a src and
            a resources folder. """

        if cls.isInitialized and not force:
            return True

        path = FileUtils.cleanupPath(referencePath, noTail=True)
        if os.path.isfile(path):
            path = FileUtils.getDirectoryOf(referencePath, noTail=True)

        rootPath = None
        while path:
            srcPath = FileUtils.makeFolderPath(path, 'src', isDir=True)
            resPath = FileUtils.makeFolderPath(path, 'resources', isDir=True)
            if os.path.exists(srcPath) and os.path.exists(resPath):
                rootPath = path
                break
            path = FileUtils.getDirectoryOf(path, noTail=True)

        if not rootPath:
            return False

        cls._rootResourcePath       = FileUtils.makeFolderPath(rootPath, 'resources')
        cls._rootLocalResourcePath  = FileUtils.makeFolderPath(rootPath, 'resources', 'local')
        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:29,代码来源:PyGlassEnvironment.py

示例6: browseForFileOpen

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def browseForFileOpen(cls, parent, caption =None, defaultPath =None):
        out = QtGui.QFileDialog.getOpenFileName(
            parent,
            caption=caption if caption else u'Select a File',
            dir=defaultPath if defaultPath else os.path.expanduser('~'))

        if not out or not out[0]:
            return out
        return FileUtils.cleanupPath(out[0], isFile=True)
开发者ID:hannahp,项目名称:PyGlass,代码行数:11,代码来源:PyGlassBasicDialogManager.py

示例7: browseForDirectory

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def browseForDirectory(cls, parent, caption =None, defaultPath =None):
        out = QtGui.QFileDialog.getExistingDirectory(
            parent,
            caption=caption if caption else u'Select a Directory',
            dir=defaultPath if defaultPath else os.path.expanduser('~'))

        if not out:
            return out
        return FileUtils.cleanupPath(out, isDir=True)
开发者ID:hannahp,项目名称:PyGlass,代码行数:11,代码来源:PyGlassBasicDialogManager.py

示例8: toFile

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def toFile(self, path):
        path = FileUtils.cleanupPath(path, isFile=True)

        try:
            f = open(path, 'wb')
            f.write(self._data)
            f.close()
        except Exception:
            print('FAILED: Write ByteChunk to file')
            raise
开发者ID:sernst,项目名称:PyAid,代码行数:12,代码来源:ByteChunk.py

示例9: browseForFileOpen

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def browseForFileOpen(cls, parent, caption =None, defaultPath =None, allowMultiple =False, filterDefs =None):
        QFD = QtGui.QFileDialog
        f = QFD.getOpenFileNames if allowMultiple else QFD.getOpenFileName
        out = f(
            parent,
            caption=caption if caption else 'Select a File',
            dir=defaultPath if defaultPath else os.path.expanduser('~'),
            filter=cls.getFileFilterString(filterDefs))

        if not out or not out[0]:
            return None

        if not allowMultiple:
            return FileUtils.cleanupPath(out[0], isFile=True)

        items = []
        for item in out[0]:
            items.append(FileUtils.cleanupPath(item, isFile=True))
        return items
开发者ID:sernst,项目名称:PyGlass,代码行数:21,代码来源:PyGlassBasicDialogManager.py

示例10: browseForFileSave

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def browseForFileSave(cls, parent, caption =None, defaultPath =None, filterDefs =None):
        out = QtGui.QFileDialog.getSaveFileName(
            parent,
            caption=caption if caption else 'Specify File',
            dir=defaultPath if defaultPath else os.path.expanduser('~'),
            options=QtGui.QFileDialog.AnyFile,
            filter=cls.getFileFilterString(filterDefs))

        if not out or not out[0]:
            return None
        return FileUtils.cleanupPath(out[0], isFile=True)
开发者ID:sernst,项目名称:PyGlass,代码行数:13,代码来源:PyGlassBasicDialogManager.py

示例11: _handleLocatePath

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def _handleLocatePath(self):
        self.refreshGui()
        path = QtGui.QFileDialog.getExistingDirectory(
            self,
            caption=u'Specify Root NGinx Path',
            dir=self.rootPath
        )

        if path:
            path = FileUtils.cleanupPath(path)
            self._pathLineEdit.setText(path)
开发者ID:sernst,项目名称:NGinxWinManager,代码行数:13,代码来源:NwmHomeWidget.py

示例12: loggingPath

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def loggingPath(self, value):
        self._logPath = FileUtils.cleanupPath(value)

        logFolder = self.getLogFolder()
        if logFolder:
            name = self._name
            extension = self.logFileExtension
            if self.timestampFileSuffix:
                name += '_' + self._timeCode
            self._logFile = FileUtils.createPath(logFolder, name + '.' + extension)
            if self.removeIfExists:
                self.resetLogFile()
        else:
            self._logFile = None
开发者ID:sernst,项目名称:PyAid,代码行数:16,代码来源:Logger.py

示例13: __init__

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def __init__(self, rootPath =None, recursive =True, **kwargs):
        """Creates a new instance of WidgetUiCompiler."""
        self._log        = Logger(self)
        self._verbose    = ArgsUtils.get('verbose', False, kwargs)
        self._recursive  = recursive
        self._pythonPath = os.path.normpath(sys.exec_prefix)

        if rootPath and os.path.isabs(rootPath):
            self._rootPath = FileUtils.cleanupPath(rootPath, isDir=True)
        elif rootPath:
            parts = rootPath.split(os.sep if rootPath.find(os.sep) != -1 else '/')
            self._rootPath = PyGlassEnvironment.getRootResourcePath(*parts, isDir=True)
        else:
            self._rootPath = PyGlassEnvironment.getRootResourcePath()
开发者ID:hannahp,项目名称:PyGlass,代码行数:16,代码来源:WidgetUiCompiler.py

示例14: _handleBrowseFolders

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def _handleBrowseFolders(self):

        path = QtGui.QFileDialog.getExistingDirectory(
            self,
            'Select Project Folder',
            self.appConfig.get(self._LAST_PROJECT_PATH, u''))

        if not path:
            return

        path = FileUtils.cleanupPath(path, isDir=True)
        self.appConfig.set(self._LAST_PROJECT_PATH, path)
        self.pathLine.setText(path)
        self.openBtn.setEnabled(True)
开发者ID:sernst,项目名称:CompilerDeck,代码行数:16,代码来源:DeckHomeWidget.py

示例15: createIcon

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import cleanupPath [as 别名]
    def createIcon(cls, iconsPath):
        """ Creates a window icon from a path, adding the standard icon sizes for multiple
            operating systems. """

        if not os.path.exists(iconsPath):
            return None

        iconsPath = FileUtils.cleanupPath(iconsPath, isDir=True)
        icon      = QtGui.QIcon()
        sizes     = [512, 256, 180, 128, 96, 72, 64, 48, 32, 24, 16]
        for size in sizes:
            path = FileUtils.createPath(iconsPath, str(size) + '.png', isFile=True)
            if os.path.exists(path):
                icon.addFile(path)
        return icon
开发者ID:sernst,项目名称:PyGlass,代码行数:17,代码来源:PyGlassGuiUtils.py


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