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


Python FileUtils.mergeCopy方法代码示例

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


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

示例1: _deployResources

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
    def _deployResources(cls):
        """ On windows the resource folder data is stored within the application install directory.
            However, due to permissions issues, certain file types cannot be accessed from that
            directory without causing the program to crash. Therefore, the stored resources must
            be expanded into the user's AppData/Local folder. The method checks the currently
            deployed resources folder and deploys the stored resources if the existing resources
            either don't exist or don't match the currently installed version of the program. """

        if not OsUtils.isWindows() or not PyGlassEnvironment.isDeployed:
            return False

        storagePath       = PyGlassEnvironment.getInstallationPath('resource_storage', isDir=True)
        storageStampPath  = FileUtils.makeFilePath(storagePath, 'install.stamp')
        resourcePath      = PyGlassEnvironment.getRootResourcePath(isDir=True)
        resourceStampPath = FileUtils.makeFilePath(resourcePath, 'install.stamp')

        try:
            resousrceData = JSON.fromFile(resourceStampPath)
            storageData   = JSON.fromFile(storageStampPath)
            if resousrceData['CTS'] == storageData['CTS']:
                return False
        except Exception as err:
            pass

        SystemUtils.remove(resourcePath)
        FileUtils.mergeCopy(storagePath, resourcePath)
        return True
开发者ID:sernst,项目名称:PyGlass,代码行数:29,代码来源:PyGlassApplication.py

示例2: _copyResourceFolder

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
    def _copyResourceFolder(self, sourcePath, parts):
        targetPath = FileUtils.createPath(self._targetPath, *parts, isDir=True)
        WidgetUiCompiler(sourcePath).run()

        if self._verbose:
            self._log.write('COPYING: %s -> %s' % (sourcePath, targetPath))
        return FileUtils.mergeCopy(sourcePath, targetPath)
开发者ID:sernst,项目名称:PyGlass,代码行数:9,代码来源:ResourceCollector.py

示例3: _copyV4SupportLib

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
 def _copyV4SupportLib(self):
     v4Path = self._owner.mainWindow.getAndroidSDKPath(*AndroidCompiler._V4_SUPPORT_LIB, isDir=True)
     for item in os.listdir(v4Path):
         itemPath = FileUtils.createPath(v4Path, item, isDir=True)
         self._copyMerges.append(
             FileUtils.mergeCopy(itemPath, self.getTargetPath('android', 'src'), False)
         )
开发者ID:sernst,项目名称:CompilerDeck,代码行数:9,代码来源:AndroidCompiler.py

示例4: _deployIcons

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
    def _deployIcons(cls, sourcePath, targetPath, record):
        merges    = record['merges']
        dirs      = record['dirs']
        itemNames = record['itemNames']
        icons     = record['icons']

        merges.append(FileUtils.mergeCopy(sourcePath, targetPath))
        dirs.append(sourcePath)
        itemNames.append('icons')

        for item in os.listdir(targetPath):
            size = item.split('_')[-1].split('.')[0]
            icons.append({'size':size, 'name':item})
开发者ID:sernst,项目名称:CompilerDeck,代码行数:15,代码来源:AirUtils.py

示例5: deployExternalIncludes

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
    def deployExternalIncludes(cls, flexProjectData):
        """ Deploys all of the external includes file and folders to the platform-specific project
            bin folder for use in packaging or debugging. Returns a list of FileLists for each
            copy operation that occurred so that the deploy operation can be undone later. """

        dirs      = []
        files     = []
        merges    = []
        itemNames = []

        out = {'dirs':dirs, 'files':files, 'merges':merges, 'itemNames':itemNames, 'icons':[]}
        sets = flexProjectData

        #-------------------------------------------------------------------------------------------
        # ICONS
        #       Cascade through the various locations where icons may reside for a given platform
        #       and copy the preferred location to the bin for compilation.

        iconTargetPath = FileUtils.createPath(sets.platformBinPath, 'icons', isDir=True)

        #--- Platform[Specific] | Build-Type[Specific] ---#
        iconPath = FileUtils.createPath(
            sets.platformProjectPath, 'icons', sets.buildTypeFolderName, isDir=True)

        #--- Platform[Specific] | Build-Type[Generic] ---#
        if not os.path.exists(iconPath):
            iconPath = FileUtils.createPath(sets.platformProjectPath, 'icons', isDir=True)

        #--- Platform[Generic] | Build-Type[Specific] ---#
        if not os.path.exists(iconPath):
            iconPath = FileUtils.createPath(
                sets.projectPath, 'icons', sets.buildTypeFolderName, isDir=True)

        #--- Platform[Generic] | Build-Type[Generic] ---#
        if not os.path.exists(iconPath):
            iconPath = FileUtils.createPath(sets.projectPath, 'icons', isDir=True)

        # If an icon path exists, copy those files to the target path for inclusion
        if os.path.exists(iconPath):
            cls._deployIcons(iconPath, iconTargetPath, out)
        cls.updateAppIconList(sets.appDescriptorPath, out['icons'])

        #-------------------------------------------------------------------------------------------
        # INCLUDES FOLDER
        #       Copy everything in the includes directory with the generic includes first and then
        #       the platform-specific includes merged in (potentially overwriting general files
        #       in the process if there is a naming collision. This allows for platform specific
        #       file overrides when desirable.

        #--- Generic Includes ---#
        includesPath = sets.externalIncludesPath
        if os.path.exists(includesPath):
            for item in os.listdir(includesPath):
                if item.startswith('.'):
                    continue

                source = FileUtils.createPath(includesPath, item)
                merges.append(FileUtils.mergeCopy(
                    source, FileUtils.createPath(sets.platformBinPath, item)))
                if os.path.isdir(source):
                    dirs.append(source)
                else:
                    files.append(source)
                itemNames.append(item)

        #--- Specific Includes ---#
        includesPath = sets.platformExternalIncludesPath
        if not includesPath or not os.path.exists(includesPath):
            return out

        for item in os.listdir(includesPath):
            if item.startswith('.'):
                continue

            source = FileUtils.createPath(includesPath, item)
            merges.append(FileUtils.mergeCopy(
                source, FileUtils.createPath(sets.platformBinPath, item)))
            if os.path.isdir(source):
                dirs.append(source)
            else:
                files.append(source)
            itemNames.append(item)
        return out
开发者ID:sernst,项目名称:CompilerDeck,代码行数:85,代码来源:AirUtils.py

示例6: _runImpl

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

示例7: _compileImpl

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]
    def _compileImpl(self):
        sets = self._settings
        os.chdir(sets.projectPath)

        adtPath     = self.getAirPath('bin', 'adt', isFile=True)
        swcRootPath = FileUtils.createPath(sets.projectPath, 'swc', isDir=True)

        buildPath = FileUtils.createPath(sets.projectPath, 'build', isDir=True)
        SystemUtils.remove(buildPath)
        os.makedirs(buildPath)

        sets.setPlatform(FlexProjectData.DEFAULT_PLATFORM)

        swcPath = FileUtils.createPath(
            swcRootPath,
            sets.getSetting('FOLDER'),
            sets.getSetting('FILENAME') + '.swc',
            isFile=True)

        cmd = [adtPath,
            '-package',
            '-target', 'ane', sets.getSetting('FILENAME') + '.ane', 'extension.xml',
            '-swc', swcPath]

        platforms = [
            (FlexProjectData.DEFAULT_PLATFORM, 'default', None),
            (FlexProjectData.ANDROID_PLATFORM, 'Android-ARM', 'jar'),
            (FlexProjectData.IOS_PLATFORM, 'iPhone-ARM', 'a'),
            (FlexProjectData.WINDOWS_PLATFORM, 'Windows-x86', None),
            (FlexProjectData.MAC_PLATFORM, 'MacOS-x86', None)]

        platformsData = []
        for platformDef in platforms:
            if not sets.setPlatform(platformDef[0]):
                continue

            platformFolder = sets.getSetting('FOLDER')

            platformBuildPath = FileUtils.createPath(buildPath, platformFolder, isDir=True, noTail=True)
            os.makedirs(platformBuildPath)

            # LIBRARY.SWF
            SystemUtils.copy(
                FileUtils.createPath(
                    sets.projectPath, 'swc', platformFolder, 'extracted', 'library.swf', isFile=True),
                FileUtils.createPath(platformBuildPath, 'library.swf', isFile=True) )

            # NATIVE LIBRARY
            nativeLibrary = sets.getSetting('NATIVE_LIBRARY')
            if nativeLibrary:
                SystemUtils.copy(
                    FileUtils.createPath(sets.projectPath, platformFolder, nativeLibrary, isFile=True),
                    FileUtils.createPath(buildPath, platformFolder, nativeLibrary, isFile=True))

            # Android RES folder
            if platformDef[0] == FlexProjectData.ANDROID_PLATFORM:
                FileUtils.mergeCopy(
                    FileUtils.createPath(sets.projectPath, platformFolder, 'res', isDir=True),
                    FileUtils.createPath(buildPath, platformFolder, 'res', isDir=True))

            cmd.extend(['-platform', platformDef[1]])

            optionsPath = FileUtils.createPath(
                sets.projectPath, platformFolder, 'platform.xml', isFile=True, noTail=True)
            if os.path.exists(optionsPath):
                cmd.extend(['-platformoptions', '"%s"' % optionsPath])

            cmd.extend(['-C', platformBuildPath, '.'])

            data = dict(
                nativeLibrary=nativeLibrary,
                definition=platformDef,
                folder=platformFolder,
                initializer=sets.getSetting('INITIALIZER'),
                finalizer=sets.getSetting('FINALIZER'))
            platformsData.append(data)

        self._createExtensionDescriptor(platformsData)
        result = self.executeCommand(cmd, 'PACKAGING ANE')

        # Cleanup deployed library.swf files
        SystemUtils.remove(buildPath)

        if result:
            self._log.write('PACKAGING FAILED')
            return False

        self._log.write('PACKAGED SUCCEEDED')
        return True
开发者ID:sernst,项目名称:CompilerDeck,代码行数:91,代码来源:NativeExtensionCompiler.py

示例8: _compileImpl

# 需要导入模块: from pyaid.file.FileUtils import FileUtils [as 别名]
# 或者: from pyaid.file.FileUtils.FileUtils import mergeCopy [as 别名]

#.........这里部分代码省略.........
            self._log.write('Including Android V4 Support library...')
            self._copyV4SupportLib()

        #-------------------------------------------------------------------------------------------
        # COMPILE APK
        libsPath = self.getTargetPath('android', 'libs')
        if not os.path.exists(libsPath):
            os.makedirs(libsPath)

        for item in AndroidCompiler.FLASH_LIBS:
            shutil.copy2(
                self.getAirPath('lib', 'android', item),
                self.getTargetPath('android', 'libs', item)
            )

        batchCmd = [
            'set JAVA_HOME=%s' % self._owner.mainWindow.getJavaJDKPath(),
            'cd "%s"'  % (self.getTargetPath() + 'android'),
            'set errorlevel=',
            '%s %s' % (
                self._owner.mainWindow.getJavaAntPath('bin', 'ant.bat'),
                'debug' if self._settings.debug else 'release'
            )
        ]

        if self.executeBatchCommand(batchCmd, messageHeader='COMPILING ANDROID APK'):
            self._log.write('FAILED: APK COMPILATION')
            return False
        self._log.write('SUCCESS: APK COMPILED')

        #-------------------------------------------------------------------------------------------
        # INCLUDE EXTERNAL JAR LIBRARIES
        libSources = []
        libsPath   = self.getTargetPath('android', 'libs')
        ignores    = AndroidCompiler.FLASH_LIBS + AndroidCompiler.IGNORE_LIBS
        for item in os.listdir(libsPath):
            if item in ignores or not item.endswith('.jar'):
                continue
            libSources.append(item)

        if libSources:
            libSrcPath = self.getTargetPath('android', 'lib-src')
            if os.path.exists(libSrcPath):
                shutil.rmtree(libSrcPath)
            os.makedirs(libSrcPath)

            for item in libSources:
                src  = libsPath + item
                dest = self.getTargetPath('android', 'lib-temp')

                if os.path.exists(dest):
                    shutil.rmtree(dest)
                os.makedirs(dest)

                z = zipfile.ZipFile(src)
                z.extractall(path=dest)

                metaInfPath = self.getTargetPath('android', 'lib-temp', 'META-INF')
                if os.path.exists(metaInfPath):
                    shutil.rmtree(metaInfPath)

                FileUtils.mergeCopy(dest, libSrcPath)
                shutil.rmtree(dest)

            for item in os.listdir(libSrcPath):
                shutil.copytree(
                    libSrcPath + item,
                    self.getTargetPath('android', 'bin', 'classes') + item
                )

            if os.path.exists(libSrcPath):
                shutil.rmtree(libSrcPath)

        #-------------------------------------------------------------------------------------------
        # CREATE JAR FILE
        batchCmd = [
            'set JAVA_HOME=%s' % self._owner.mainWindow.getJavaJDKPath(),
            'cd "%s"' % self.getTargetPath('android', 'bin'),
            'set errorlevel=',
            '"%s" cvf %s -C %s .' % (
                self._owner.mainWindow.getJavaJDKPath('bin', 'jar.exe'),
                self.getTargetPath('bin', 'android', self._settings.targetName + '.jar'),
                self.getTargetPath('android', 'bin') + 'classes'
            )
        ]

        if self.executeBatchCommand(batchCmd, messageHeader='COMPILING ANDROID JAR'):
            self._log.write('FAILED: JAR COMPILATION')
            return False
        self._log.write('SUCCESS: JAR COMPILED')

        #-------------------------------------------------------------------------------------------
        # COPY RESOURCES TO BIN
        binResourcePath = self.getTargetPath('bin', 'android', 'res')
        if os.path.exists(binResourcePath):
            shutil.rmtree(binResourcePath)
        shutil.copytree(self.getTargetPath('android', 'res'), binResourcePath)
        self._log.write('SUCCESS: RESOURCES DEPLOYED')

        return True
开发者ID:sernst,项目名称:CompilerDeck,代码行数:104,代码来源:AndroidCompiler.py


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