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


Python FileUtils.getDirectoryOf方法代码示例

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


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

示例1: _copyWalker

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

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def save(self, toPDF=True):
        """ Writes the current _drawing in SVG format to the file specified at initialization. If
            one wishes to have create a PDF file (same file name as used for the .SVG, but with
            suffix .PDF), then call with toPDF True). """

        if not self.siteMapReady:
            return

        # Make sure the directory where the file will be saved exists before saving
        FileUtils.getDirectoryOf(self._drawing.filename, createIfMissing=True)

        self._drawing.save()

        #  we're done if no PDF version is also required
        if not toPDF:
            return

        # strip any extension off of the file name
        basicName = self.fileName.split(".")[0]

        # load up the command
        cmd = ["/Applications/Inkscape.app/Contents/Resources/bin/inkscape", "-f", None, "-A", None]
        cmd[2] = basicName + ".svg"
        cmd[4] = basicName + ".pdf"

        # and execute it
        response = SystemUtils.executeCommand(cmd)
        if response["error"]:
            print("response[error]=%s" % response["error"])
开发者ID:sernst,项目名称:Cadence,代码行数:31,代码来源:CadenceDrawing.py

示例3: __init__

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def __init__(self):
        """Creates a new instance of PyGlassApplication."""
        QtCore.QObject.__init__(self)
        self._qApplication = None
        self._window       = None
        self._splashScreen = None

        # Sets a temporary standard out and error for deployed applications in a write allowed
        # location to prevent failed write results.
        if PyGlassEnvironment.isDeployed:
            if appdirs:
                userDir = appdirs.user_data_dir(self.appID, self.appGroupID)
            else:
                userDir = FileUtils.createPath(
                    os.path.expanduser('~'), '.pyglass', self.appGroupID, self.appID, isDir=True)

            path = FileUtils.createPath(
                userDir,
                self.appID + '_out.log', isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stdout = open(path, 'w+')

            FileUtils.createPath(
                appdirs.user_data_dir(self.appID, self.appGroupID),
                self.appID + '_error.log',
                isFile=True)
            folder = FileUtils.getDirectoryOf(path, createIfMissing=True)
            sys.stderr = open(path, 'w+')

        PyGlassEnvironment.initializeAppSettings(self)
开发者ID:hannahp,项目名称:PyGlass,代码行数:32,代码来源:PyGlassApplication.py

示例4: initializeFromInternalPath

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

示例5: __init__

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def __init__(self, parent, test =True, install =True, check =False, verbose =True, **kwargs):
        """Creates a new instance of MayaIniRemoteThread."""
        super(MayaIniRemoteThread, self).__init__(parent, **kwargs)
        self._test      = test
        self._verbose   = verbose
        self._install   = install
        self._check     = check
        self._output    = {}

        self._cadenceEntry = MayaEnvEntry.fromRootPath(FileUtils.createPath(
            FileUtils.getDirectoryOf(cadence.__file__), noTail=True))

        self._elixirEntry = MayaEnvEntry.fromRootPath(FileUtils.createPath(
            FileUtils.getDirectoryOf(elixir.__file__), noTail=True))
开发者ID:sernst,项目名称:Cadence,代码行数:16,代码来源:MayaIniRemoteThread.py

示例6: _handleImportSitemaps

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

        self.mainWindow.showLoading(
            self,
            u'Browsing for Sitemap File',
            u'Choose the Sitemap CSV file to import into the database')

        path = PyGlassBasicDialogManager.browseForFileOpen(
            parent=self,
            caption=u'Select CSV File to Import',
            defaultPath=self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) )

        self.mainWindow.hideLoading(self)

        if not path or not StringUtils.isStringType(path):
            self.mainWindow.toggleInteractivity(True)
            return

        # Store directory location as the last active directory
        self.mainWindow.appConfig.set(
            UserConfigEnum.LAST_BROWSE_PATH, FileUtils.getDirectoryOf(path) )

        self.mainWindow.showStatus(
            self,
            u'Importing Sitemaps',
            u'Reading sitemap information into database')

        SitemapImporterRemoteThread(
            parent=self,
            path=path
        ).execute(
            callback=self._sitemapImportComplete,
            logCallback=self._handleImportStatusUpdate)
开发者ID:sernst,项目名称:Cadence,代码行数:35,代码来源:DatabaseManagerWidget.py

示例7: rootPath

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def rootPath(self):
        if self._rootPath:
            return self._rootPath

        if self._appFilePath:
            return FileUtils.getDirectoryOf(self._appFilePath)

        return FileUtils.createPath(os.path.expanduser('~'), self.appName, isDir=True)
开发者ID:sernst,项目名称:Ziggurat,代码行数:10,代码来源:ZigguratApplication.py

示例8: initialize

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
def initialize(my_path):
    if os.path.isfile(my_path):
        my_path = FileUtils.getDirectoryOf(my_path)

    path = FileUtils.makeFolderPath(my_path, 'data')
    SystemUtils.remove(path)
    os.makedirs(path)

    return path
开发者ID:sernst,项目名称:Cadence,代码行数:11,代码来源:__init__.py

示例9: redirectLogOutputs

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def redirectLogOutputs(self, prefix =None, logFolderPath =None):
        """ Sets a temporary standard out and error for deployed applications in a write allowed
            location to prevent failed write results. """

        if not PyGlassEnvironment.isDeployed:
            return

        if not prefix:
            prefix = self.appID

        if not prefix.endswith('_'):
            prefix += '_'

        if logFolderPath:
            logPath = logFolderPath
        elif PyGlassEnvironment.isInitialized:
            logPath = PyGlassEnvironment.getRootLocalResourcePath('logs', isDir=True)
        else:
            prefix += 'init_'
            if appdirs:
                logPath = appdirs.user_data_dir(self.appID, self.appGroupID)
            else:
                logPath = FileUtils.createPath(
                    os.path.expanduser('~'), '.pyglass', self.appGroupID, self.appID, isDir=True)

        FileUtils.getDirectoryOf(logPath, createIfMissing=True)
        try:
            sys.stdout.flush()
            sys.stdout.close()
        except Exception as err:
            pass
        sys.stdout = open(FileUtils.makeFilePath(logPath, prefix + 'out.log'), 'w+')

        try:
            sys.stderr.flush()
            sys.stderr.close()
        except Exception as err:
            pass
        sys.stderr = open(FileUtils.makeFilePath(logPath, prefix + 'error.log'), 'w+')

        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:43,代码来源:PyGlassApplication.py

示例10: compileCss

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

示例11: compileCoffeescript

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

示例12: copyToCdnFolder

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def copyToCdnFolder(cls, targetPath, processor, lastModified =None, headers =None):
        if processor.isLocal:
            return False

        folder = targetPath[len(processor.targetWebRootPath):].replace('\\', '/').strip('/').split('/')
        destPath = FileUtils.createPath(
            processor.targetWebRootPath, processor.cdnRootFolder, folder, isFile=True)
        destFolder = FileUtils.getDirectoryOf(destPath)
        if not os.path.exists(destFolder):
            os.makedirs(destFolder)
        shutil.copy(targetPath, destPath)

        if not headers:
            headers = dict()

        if 'Expires' not in headers:
            headers['Expires'] = TimeUtils.dateTimeToWebTimestamp(
                datetime.datetime.utcnow() + datetime.timedelta(days=360))
        cls.createHeaderFile(destPath, lastModified=lastModified, headers=headers)
        return True
开发者ID:sernst,项目名称:StaticFlow,代码行数:22,代码来源:SiteProcessUtils.py

示例13: _handleExport

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

        self.mainWindow.showLoading(
            self,
            u'Browsing for Exporting File',
            u'Choose the file location to save the export')

        defaultPath = self.mainWindow.appConfig.get(UserConfigEnum.LAST_SAVE_PATH)
        if not defaultPath:
            defaultPath = self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH)

        path = PyGlassBasicDialogManager.browseForFileSave(
            parent=self, caption=u'Specify Export File', defaultPath=defaultPath)
        self.mainWindow.hideLoading(self)

        if not path:
            self.mainWindow.toggleInteractivity(True)
            return

        # Store directory location as the last save directory
        self.mainWindow.appConfig.set(
            UserConfigEnum.LAST_SAVE_PATH,
            FileUtils.getDirectoryOf(path) )

        if not path.endswith('.json'):
            path += '.json'

        self.mainWindow.showStatus(
            self,
            u'Exporting Tracks',
            u'Writing track information from database')

        self._thread = TrackExporterRemoteThread(
            self, path=path,
            pretty=self.exportPrettyCheck.isChecked(),
            compressed=self.exportCompressCheck.isChecked(),
            difference=self.exportDiffCheck.isChecked())

        self._thread.execute(
            callback=self._handleImportComplete,
            logCallback=self._handleImportStatusUpdate)
开发者ID:sernst,项目名称:Cadence,代码行数:43,代码来源:DatabaseManagerWidget.py

示例14: _handleImport

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def _handleImport(self):
        label = u'CSV'
        importType = TrackImporterRemoteThread.CSV

        self.mainWindow.showLoading(
            self,
            u'Browsing for Track File',
            u'Choose the %s file to import into the database' % label)

        path = PyGlassBasicDialogManager.browseForFileOpen(
            parent=self,
            caption=u'Select %s File to Import' % label,
            defaultPath=self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) )

        self.mainWindow.hideLoading(self)
        if not path or not StringUtils.isStringType(path):
            self.mainWindow.toggleInteractivity(True)
            return

        # Store directory location as the last active directory
        self.mainWindow.appConfig.set(
            UserConfigEnum.LAST_BROWSE_PATH, FileUtils.getDirectoryOf(path) )

        self.mainWindow.showStatus(
            self,
            u'Importing Tracks',
            u'Reading track information into database')

        TrackImporterRemoteThread(
            parent=self,
            path=path,
            verbose=self.verboseDisplayCheck.isChecked(),
            importType=importType,
            compressed=False
        ).execute(
            callback=self._handleImportComplete,
            logCallback=self._handleImportStatusUpdate )
开发者ID:sernst,项目名称:Cadence,代码行数:39,代码来源:DatabaseManagerWidget.py

示例15: _processFolderDefinitions

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import getDirectoryOf [as 别名]
    def _processFolderDefinitions(self, path):
        cd        = ConfigsDict(JSON.fromFile(path))
        directory = FileUtils.getDirectoryOf(path)

        for item in os.listdir(directory):
            # Only find content source file types
            if not StringUtils.ends(item, ('.sfml', '.html')):
                continue

            # Skip files that already have a definitions file
            itemPath     = FileUtils.createPath(directory, item, isFile=True)
            itemDefsPath = itemPath.rsplit('.', 1)[0] + '.def'
            if os.path.exists(itemDefsPath):
                continue

            test = SiteProcessUtils.testFileFilter(
                itemPath,
                cd.get(('FOLDER', 'EXTENSION_FILTER')),
                cd.get(('FOLDER', 'NAME_FILTER')))
            if not test:
                continue

            JSON.toFile(itemDefsPath, dict(), pretty=True)
        return True
开发者ID:sernst,项目名称:StaticFlow,代码行数:26,代码来源:Site.py


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