當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.FolderDeleter類代碼示例

本文整理匯總了Python中appy.shared.utils.FolderDeleter的典型用法代碼示例。如果您正苦於以下問題:Python FolderDeleter類的具體用法?Python FolderDeleter怎麽用?Python FolderDeleter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FolderDeleter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: createDistRelease

 def createDistRelease(self):
     """Create the distutils package."""
     curdir = os.getcwd()
     distFolder = "%s/dist" % self.genFolder
     # Create setup.py
     os.mkdir(distFolder)
     f = file("%s/setup.py" % distFolder, "w")
     # List all packages to include
     packages = []
     os.chdir(os.path.dirname(appyPath))
     for dir, dirnames, filenames in os.walk("appy"):
         if self.isDistExcluded(dir):
             continue
         packageName = dir.replace("/", ".")
         packages.append('"%s"' % packageName)
     f.write(distInfo % (self.versionShort, ",".join(packages)))
     f.close()
     # Create MANIFEST.in
     f = file("%s/MANIFEST.in" % distFolder, "w")
     f.write(manifestInfo)
     f.close()
     # Move appy sources within the dist folder
     os.rename("%s/appy" % self.genFolder, "%s/appy" % distFolder)
     # Create the source distribution
     os.chdir(distFolder)
     self.executeCommand("python setup.py sdist")
     # DistUtils has created the .tar.gz file. Move it to folder "versions"
     name = "appy-%s.tar.gz" % self.versionShort
     os.rename("%s/dist/%s" % (distFolder, name), "%s/versions/%s" % (appyPath, name))
     # Clean temp files
     os.chdir(curdir)
     # Keep the Appy source for building the Debian package afterwards
     os.rename(os.path.join(self.genFolder, "dist", "appy"), os.path.join(self.genFolder, "appy"))
     FolderDeleter.delete(os.path.join(self.genFolder, "dist"))
     return name
開發者ID:a-iv,項目名稱:appy,代碼行數:35,代碼來源:publish.py

示例2: zipResult

 def zipResult(self, eggFullName, eggTempFolder):
     '''Zips the result and removes the egg temp folder.'''
     zipFile = zipfile.ZipFile(eggFullName, 'w', zipfile.ZIP_DEFLATED)
     # Put the Python module inside the egg.
     prefix = os.path.dirname(eggTempFolder)
     for dir, dirnames, filenames in os.walk(eggTempFolder):
         for f in filenames:
             fileName = os.path.join(dir, f)
             zipFile.write(fileName, fileName[len(prefix):])
     # Put the Appy module inside it if required.
     if self.includeAppy:
         eggPrefix = '%s/%s' % (eggTempFolder[len(prefix):],
                                self.moduleName.replace('.', '/'))
         # Where is Appy?
         appyPath = os.path.dirname(appy.__file__)
         appyPrefix = os.path.dirname(appyPath)
         # Clean the Appy folder
         Cleaner().run(verbose=False)
         # Insert appy files into the zip
         for dir, dirnames, filenames in os.walk(appyPath):
             if not self.dirInZip(dir): continue
             for f in filenames:
                 fileName = os.path.join(dir, f)
                 zipName = eggPrefix + fileName[len(appyPrefix):]
                 zipFile.write(fileName, zipName)
     zipFile.close()
     # Remove the temp egg folder.
     FolderDeleter.delete(eggTempFolder)
開發者ID:dpineiden,項目名稱:gestion_docs,代碼行數:28,代碼來源:eggify.py

示例3: eggify

 def eggify(self):
     '''Let's wrap a nice Python module into an ugly egg.'''
     j = os.path.join
     # First, clean the Python module
     cleanFolder(self.pythonModule, verbose=False)
     # Create the egg folder
     eggFullName = j(self.eggFolder, self.eggName)
     if os.path.exists(eggFullName):
         os.remove(eggFullName)
         print('Existing "%s" was removed.' % eggFullName)
     # Create a temp folder where to store the egg
     eggTempFolder = os.path.splitext(eggFullName)[0]
     if os.path.exists(eggTempFolder):
         FolderDeleter.delete(eggTempFolder)
         print('Removed "%s" that was in my way.' % eggTempFolder)
     os.mkdir(eggTempFolder)
     # Create the "Products" sub-folder if we must wrap the package in this
     # namespace
     eggModulePath = j(j(eggTempFolder, self.moduleName.replace('.', '/')))
     # Copy the Python module into the egg.
     os.makedirs(eggModulePath)
     copyFolder(self.pythonModule, eggModulePath)
     # Create setup files in the root egg folder
     self.createSetupFile(eggTempFolder)
     self.createInitFile(eggTempFolder)
     self.zipResult(eggFullName, eggTempFolder)
開發者ID:dpineiden,項目名稱:gestion_docs,代碼行數:26,代碼來源:eggify.py

示例4: __init__

 def __init__(self):
     # Delete the "egg" folder on not-yet-copied local site.
     eggFolder = "%s/temp/egg" % appyPath
     if os.path.isdir(eggFolder):
         FolderDeleter.delete(eggFolder)
     # Ask user id and password for FTP transfer
     userId, userPassword = askLogin()
     self.site = ftplib.FTP(self.name)
     self.site.login(userId, userPassword)
     self.rootFolder = None  # Root folder of appy site ~FtpFolder~
     self.currentFolder = None  # Currently visited folder ~FtpFolder~
開發者ID:a-iv,項目名稱:appy,代碼行數:11,代碼來源:publish.py

示例5: __init__

 def __init__(self, app, pythonVersions=('2.6',)):
     self.appName = os.path.basename(app)
     self.pythonVersions = pythonVersions
     appFolder = os.path.dirname(app)
     # Prepare the output folder (remove any existing one)
     cortexFolder = os.path.join(appFolder, 'cortex.admin')
     if os.path.exists(cortexFolder):
         FolderDeleter.delete(cortexFolder)
     allFolders = os.path.join(cortexFolder, 'applications', self.appName)
     os.makedirs(allFolders)
     self.out = allFolders
開發者ID:Sateanu,項目名稱:django-sis,代碼行數:11,代碼來源:packaging.py

示例6: run

 def run(self, verbose=True):
     cleanFolder(appyPath, verbose=verbose)
     # Remove all files in temp folders
     for tempFolder in ('%s/temp' % appyPath,
                        '%s/pod/test/temp' % appyPath):
         if os.path.exists(tempFolder):
             FolderDeleter.delete(tempFolder)
     # Remove test reports if any
     for testReport in ('%s/pod/test/Tester.report.txt' % appyPath,):
         if os.path.exists(testReport):
             os.remove(testReport)
開發者ID:a-iv,項目名稱:appy,代碼行數:11,代碼來源:clean.py

示例7: finalize

 def finalize(self):
     msg = '%d/%d successful test(s)' % \
           (self.nbOfSuccesses, (self.nbOfTests-self.nbOfIgnoredTests))
     if self.nbOfIgnoredTests >0:
         msg += ', but %d ignored test(s) not counted' % \
                self.nbOfIgnoredTests
     msg += '.'
     self.report.say(msg, force=True)
     self.report.close()
     if not self.keepTemp:
         if os.path.exists(self.tempFolder):
             FolderDeleter.delete(self.tempFolder)
開發者ID:a-iv,項目名稱:appy,代碼行數:12,代碼來源:test.py

示例8: setStylesMapping

 def setStylesMapping(self, stylesMapping):
     '''Establishes a correspondence between, on one hand, CSS styles or
        XHTML tags that will be found inside XHTML content given to POD,
        and, on the other hand, ODT styles found into the template.'''
     try:
         stylesMapping = self.stylesManager.checkStylesMapping(stylesMapping)
         self.stylesManager.setStylesMapping(stylesMapping)
     except PodError, po:
         self.contentParser.env.currentBuffer.content.close()
         self.stylesParser.env.currentBuffer.content.close()
         if os.path.exists(self.tempFolder):
             FolderDeleter.delete(self.tempFolder)
         raise po
開發者ID:tonibagur,項目名稱:appy,代碼行數:13,代碼來源:renderer.py

示例9: run

 def run(self):
     '''Renders the result.'''
     try:
         # Remember which parser is running
         self.currentParser = self.contentParser
         # Create the resulting content.xml
         self.currentParser.parse(self.contentXml)
         self.currentParser = self.stylesParser
         # Create the resulting styles.xml
         self.currentParser.parse(self.stylesXml)
         # Patch META-INF/manifest.xml
         self.patchManifest()
         # Re-zip the result
         self.finalize()
     finally:
         FolderDeleter.delete(self.tempFolder)
開發者ID:Alejoss,項目名稱:django-sis,代碼行數:16,代碼來源:renderer.py

示例10: run

 def run(self):
     self.report.say('-' * 79)
     self.report.say('- Test %s.' % self.data['Name'])
     self.report.say('- %s\n' % self.description)
     # Prepare test data
     self.tempFolder = os.path.join(self.testFolder, 'temp')
     if os.path.exists(self.tempFolder):
         FolderDeleter.delete(self.tempFolder)
     os.mkdir(self.tempFolder)
     try:
         self.do()
         self.report.say('Checking result...')
         testFailed = self.checkResult()
     except:
         testFailed = self.onError()
     self.finalize()
     return testFailed
開發者ID:tonibagur,項目名稱:appy,代碼行數:17,代碼來源:test.py

示例11: run

 def run(self):
     Cleaner().run(verbose=False)
     # Perform a small analysis on the Appy code
     LinesCounter(appy).run()
     print 'Generating site in %s...' % self.genFolder
     minimalist = askQuestion('Minimalist (shipped without tests)?',
                              default='no')
     self.prepareGenFolder(minimalist)
     self.createDocToc()
     self.applyTemplate()
     self.createZipRelease()
     #self.createCodeAndEggReleases()
     if askQuestion('Do you want to publish the site on ' \
                    'appyframework.org?', default='no'):
         AppySite().publish()
     if askQuestion('Delete locally generated site ?', default='no'):
         FolderDeleter.delete(self.genFolder)
開發者ID:ajmirsky,項目名稱:appy,代碼行數:17,代碼來源:publish.py

示例12: run

 def run(self):
     self.report.say('-' * 79)
     self.report.say('- Test %s.' % self.data['Name'])
     self.report.say('- %s\n' % self.description)
     # Prepare test data
     self.tempFolder = os.path.join(self.testFolder, 'temp', self.data['Name'])
     if os.path.exists(self.tempFolder):
         time.sleep(0.3) # Sometimes I can't remove it, so I wait
         FolderDeleter.delete(self.tempFolder)
     os.makedirs(self.tempFolder)
     try:
         self.do()
         self.report.say('Checking result...')
         testFailed = self.checkResult()
     except:
         testFailed = self.onError()
     self.finalize()
     return testFailed
開發者ID:PeterEymann,項目名稱:appypod,代碼行數:18,代碼來源:test.py

示例13: run

 def run(self):
     Cleaner().run(verbose=False)
     # Perform a small analysis on the Appy code
     LinesCounter(appy).run()
     print "Generating site in %s..." % self.genFolder
     minimalist = self.askQuestion("Minimalist (shipped without tests)?", default="no")
     self.prepareGenFolder(minimalist)
     self.createDocToc()
     self.applyTemplate()
     self.createZipRelease()
     tarball = self.createDistRelease()
     self.createDebianRelease()
     if self.askQuestion("Upload %s on PyPI?" % tarball, default="no"):
         self.uploadOnPypi(tarball)
     if self.askQuestion("Publish on appyframework.org?", default="no"):
         AppySite().publish()
     if self.askQuestion("Delete locally generated site ?", default="yes"):
         FolderDeleter.delete(self.genFolder)
開發者ID:a-iv,項目名稱:appy,代碼行數:18,代碼來源:publish.py

示例14: setStylesMapping

 def setStylesMapping(self, stylesMapping):
     '''Establishes a correspondance between, on one hand, CSS styles or
        XHTML tags that will be found inside XHTML content given to POD,
        and, on the other hand, ODT styles found into the template.'''
     try:
         stylesMapping = self.stylesManager.checkStylesMapping(stylesMapping)
         # The predefined styles below are currently ignored, because the
         # xhtml2odt parser does not take into account span tags.
         if 'span[font-weight=bold]' not in stylesMapping:
             stylesMapping['span[font-weight=bold]'] = 'podBold'
         if 'span[font-style=italic]' not in stylesMapping:
             stylesMapping['span[font-style=italic]'] = 'podItalic'
         self.stylesManager.stylesMapping = stylesMapping
     except PodError, po:
         self.contentParser.env.currentBuffer.content.close()
         self.stylesParser.env.currentBuffer.content.close()
         if os.path.exists(self.tempFolder):
             FolderDeleter.delete(self.tempFolder)
         raise po
開發者ID:Alejoss,項目名稱:django-sis,代碼行數:19,代碼來源:renderer.py

示例15: walkFile

 def walkFile(self, fileName):
     '''Unzip p_fileName in a temp folder, call self.script, and then re-zip
        the result.'''
     print 'Walking %s...' % fileName
     # Create a temp folder
     name = 'f%f' % time.time()
     tempFolder = os.path.join(self.tempFolder, name)
     os.mkdir(tempFolder)
     # Unzip the file in it
     unzip(fileName, tempFolder)
     # Call self.script
     py = sys.executable or 'python'
     cmd = [py, self.script, tempFolder]
     print '  Running %s...' % cmd,
     out, err = executeCommand(cmd)
     # Re-zip the result
     zip(fileName, tempFolder, odf=True)
     FolderDeleter.delete(tempFolder)
     print 'done.'
開發者ID:tonibagur,項目名稱:appy,代碼行數:19,代碼來源:odfwalk.py


注:本文中的appy.shared.utils.FolderDeleter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。