• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python package.Package类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中exe.engine.package.Package的典型用法代码示例。如果您正苦于以下问题:Python Package类的具体用法?Python Package怎么用?Python Package使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: handleExtractPackage

 def handleExtractPackage(self, client, filename, existOk):
     """
     Create a new package consisting of the current node and export
     'existOk' means the user has been informed of existance and ok'd it
     """
     filename  = Path(filename)
     saveDir = filename.dirname()
     if saveDir and not saveDir.exists():
         client.alert(_(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.'))
         return
     if not filename.lower().endswith('.elp'):
         filename += '.elp'
     if Path(filename).exists() and existOk != 'true':
         msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename
         client.alert(_(u'EXTRACT FAILED!\n%s' % msg))
         return
     try:
         package = Package(filename.namebase)
         package.style  = self.package.style
         package.author = self.package.author
         extractNode  = self.package.currentNode.clone()
         extractNode.mergeIntoPackage(package)
         package.root = package.currentNode = extractNode
         package.save(filename)
     except Exception, e:
         client.alert(_('EXTRACT FAILED!\n%s' % str(e)))
         raise
开发者ID:,项目名称:,代码行数:27,代码来源:


示例2: Saver

class Saver():

  def __init__(self,outputfilename="prova2.elp",titol="Exportacio de LliureX"):

    self._outputfile = outputfilename
    self._titol = titol

    self.document = Package('LLiureX')

    self.document.set_name('Lliurex')
    self.document.set_description('Lliurex')
    self.document.set_author('Lliurex')
    self.document.set_title('Documentacio LLiurex')

  def addWikipedia(self,title,url,parent):
     W = WikipediaIdeviceLliurex(url)
     W.set_title(title)
     W.edit = False
     W.loadArticle("")
     W.undo = False
     parent.addIdevice(W)

  def save(self):
    self.document.save(self._outputfile)

  def AddNode(self,parent,titol):
    Fill = parent.createChild();
    Fill.setTitle(titol)
    return Fill

  def getRoot(self):
    return self.document.root
开发者ID:fercavi,项目名称:media2elp,代码行数:32,代码来源:saver.py


示例3: __exportIdevice

 def __exportIdevice(self, filename):
     """
     export the current generic idevices.
     """
     if not filename.endswith(".idp"):
         filename = filename + ".idp"
     name = Path(filename).namebase
     package = Package(name)
     package.idevices.append(self.editorPane.idevice.clone())
     package.save(filename)
开发者ID:tquilian,项目名称:exelearningTest,代码行数:10,代码来源:editorpage.py


示例4: __exportIdevice

 def __exportIdevice(self, filename):
     """
     export the current generic idevices.
     """
     if not filename.endswith('.idp'):
         filename = filename + '.idp'
     name = Path(filename).namebase
     package = Package(name)
     for idevice in self.ideviceStore.generic:
         package.idevices.append(idevice.clone())                
     package.save(filename)
开发者ID:,项目名称:,代码行数:11,代码来源:


示例5: do_export

    def do_export(self, inputf, outputf):
        if hasattr(self, 'export_' + self.options["export"]):
            LOG.debug("Exporting to type %s, in: %s, out: %s, overwrite: %s" \
            % (self.options["export"], inputf, outputf, str(self.options["overwrite"])))
            if not outputf:
                if self.options["export"] in ('website', 'singlepage'):
                    outputf = inputf.rsplit(".elp")[0]
                else:
                    outputf = inputf + self.extensions[self.options["export"]]
            outputfp = Path(outputf)
            if outputfp.exists() and not self.options["overwrite"]:
                error = _(u'"%s" already exists.\nPlease try again \
with a different filename') % outputf
                raise Exception(error.encode(sys.stdout.encoding))
            else:
                if outputfp.exists() and self.options["overwrite"]:
                    if outputfp.isdir():
                        for filen in outputfp.walkfiles():
                            filen.remove()
                        outputfp.rmdir()
                    else:
                        outputfp.remove()
                pkg = Package.load(inputf)
                LOG.debug("Package %s loaded" % (inputf))
                if not pkg:
                    error = _(u"Invalid input package")
                    raise Exception(error.encode(sys.stdout.encoding))
                self.styles_dir = self.web_dir.joinpath('style', pkg.style)
                LOG.debug("Styles dir: %s" % (self.styles_dir))
                getattr(self, 'export_' + self.options["export"])(pkg, outputf)
                return outputf
        else:
            raise Exception(_(u"Export format not implemented")\
.encode(sys.stdout.encoding))
开发者ID:manamani,项目名称:iteexe,代码行数:34,代码来源:cmdlineexporter.py


示例6: doTest

    def doTest(self, ExporterClass):
        """Exports a package with meta data"""
        # Load our test package
        package = Package.load('testPackage.elp')
        # Do the export
        outFilename = Path('scormtest.zip')
        exporter = ExporterClass(self.app.config,
                                 '../exe/webui/style/default', 
                                 outFilename)
        exporter.export(package)
        # Check that it made a nice zip file
        assert outFilename.exists()
        # See if the manifest file was created
        zipped = ZipFile(outFilename)
        filenames = zipped.namelist()
        assert 'imsmanifest.xml' in filenames, filenames
        self._testManifest(zipped.read('imsmanifest.xml'))

        # Test that all the node's html files have been generated
        pagenodes  = Set([p.node for p in exporter.pages])
        othernodes = Set(self._getNodes([], package.root))
        assert pagenodes == othernodes

        for page in exporter.pages:
            self._testPage(page, zipped)

        # Clean up
        zipped.close()
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:28,代码来源:testexport.py


示例7: loadPackage

 def loadPackage(self, path):
     """
     Load a package from disk, add it to the store and return it
     """
     package = Package.load(path)
     self.loaded[package.name] = package
     return package
开发者ID:UstadMobile,项目名称:eXePUB,代码行数:7,代码来源:packagestore.py


示例8: testExport

    def testExport(self):
        # Delete the output dir
        outdir = TempDirPath()
        
        G.application = Application()
        
        G.application.loadConfiguration()
        G.application.preLaunch()
        
        # Load a package
        package = Package.load('testing/testPackage2.elp')
        # Do the export
        style_dir = G.application.config.stylesDir / package.style
        
        exporter = WebsiteExport(G.application.config,
                                 style_dir, 
                                 outdir)
        
        exporter.export(package)
        # Check that it all exists now
        assert outdir.isdir()
        assert (outdir / 'index.html').isfile()
        # Check that the style sheets have been copied
        for filename in style_dir.files():
            assert ((outdir / filename.basename()).exists(),
                    'Style file "%s" not copied' % (outdir / filename.basename()))

        # Check that each node in the package has had a page made
        pagenodes  = Set([p.node for p in exporter.pages])
        othernodes = Set(self._getNodes([], package.root))
        assert pagenodes == othernodes

        for page in exporter.pages:
            self._testPage(page, outdir)
开发者ID:Rafav,项目名称:iteexe,代码行数:34,代码来源:testexport.py


示例9: createPackageFromTemplate

    def createPackageFromTemplate(self, templateBase):
        """
        Creates a new package from Template
        """
        log.debug(u"createPackageFromTemplate")
        package = Package.load(templateBase, isTemplate=True)
        package.set_templateFile(str(templateBase.basename().splitext()[0]))
        # Make up an initial unique name
        i = 1
        name = u"newPackage"
        while name in self.loaded:
            name = u"newPackage" + unicode(i)
            i += 1
        
        # Prevent the package from opening on the last node edited
        package.currentNode = package.root
        
        package.name = name
        package.filename = ""

        # We have to make sure the DocType of the package is the one selected
        # in preferences and not the one used to save de template
        package.docType = G.application.config.docType

        if G.application.config.locale.split('_')[0] != 'zh':
            package.lang = G.application.config.locale.split('_')[0]
        else:
            package.lang = G.application.config.locale
            
        package.translatePackage()
        package.isChanged = False
        
        self.loaded[package.name] = package

        return package
开发者ID:exelearning,项目名称:iteexe,代码行数:35,代码来源:packagestore.py


示例10: _loadPackage

 def _loadPackage(self, client, filename, newLoad=True,
                  destinationPackage=None):
     """Load the package named 'filename'"""
     try:
         encoding = sys.getfilesystemencoding()
         if encoding is None:
             encoding = 'utf-8'
         filename2 = toUnicode(filename, encoding)
         log.debug("filename and path" + filename2)
         # see if the file exists AND is readable by the user
         try:
             open(filename2, 'rb').close()
         except IOError:
             filename2 = toUnicode(filename, 'utf-8')
             try:
                 open(filename2, 'rb').close()
             except IOError:
                 client.alert(_(u'File %s does not exist or is not readable.') % filename2)
                 return None
         package = Package.load(filename2, newLoad, destinationPackage)
         if package is None:
             raise Exception(_("Couldn't load file, please email file to [email protected]"))
     except Exception, exc:
         if log.getEffectiveLevel() == logging.DEBUG:
             client.alert(_(u'Sorry, wrong file format:\n%s') % unicode(exc))
         else:
             client.alert(_(u'Sorry, wrong file format'))
         log.error(u'Error loading package "%s": %s' % (filename2, unicode(exc)))
         log.error(u'Traceback:\n%s' % traceback.format_exc())
         raise
开发者ID:giorgil2,项目名称:eXe,代码行数:30,代码来源:mainpage.py


示例11: import_xml

 def import_xml(self, inputf, outputf):
     if not outputf:
         outputf = inputf.rsplit(".xml")[0]
     xml = open(inputf).read()
     pkg = Package.load(outputf, fromxml=xml)
     if not pkg:
         raise Exception(_(u"Invalid output package '%s'") % outputf)
     pkg.save()
     return outputf
开发者ID:,项目名称:,代码行数:9,代码来源:


示例12: import_xliff

 def import_xliff(self, inputf, outputf):
     if not outputf:
         outputf = inputf.rsplit(".xlf")[0]
     pkg = Package.load(outputf)
     if not pkg:
         raise Exception(_(u"Invalid output package '%s'") % outputf)
     importer = XliffImport(pkg, inputf)
     importer.parseAndImport(self.options["from-source"])
     pkg.save()
     return outputf
开发者ID:,项目名称:,代码行数:10,代码来源:


示例13: __init__

  def __init__(self,outputfilename="prova2.elp",titol="Exportacio de LliureX"):

    self._outputfile = outputfilename
    self._titol = titol

    self.document = Package('LLiureX')

    self.document.set_name('Lliurex')
    self.document.set_description('Lliurex')
    self.document.set_author('Lliurex')
    self.document.set_title('Documentacio LLiurex')
开发者ID:fercavi,项目名称:media2elp,代码行数:11,代码来源:saver.py


示例14: _loadPackage

 def _loadPackage(self, client, filename):
     """Load the package named 'filename'"""
     try:
         encoding = sys.getfilesystemencoding()
         if encoding is None:
             encoding = 'utf-8'
         filename2 = unicode(filename, encoding)
         log.debug("filename and path" + filename2)
         package = Package.load(filename2)
         if package is None:
             filename2 = unicode(filename, 'utf-8')
             package = Package.load(filename2)
             if package is None:
                 raise Exception(_("Couldn't load file, please email file to [email protected]"))
     except Exception, exc:
         if log.getEffectiveLevel() == logging.DEBUG:
             client.alert(_(u'Sorry, wrong file format:\n%s') % unicode(exc))
         else:
             client.alert(_(u'Sorry, wrong file format'))
         log.error(u'Error loading package "%s": %s' % (filename2, unicode(exc)))
         log.error(u'Traceback:\n%s' % traceback.format_exc())
         raise
开发者ID:,项目名称:,代码行数:22,代码来源:


示例15: render_POST

    def render_POST(self, request):
        #check the parameters
        required_headers = ['ldshake_frame_origin','name','sectoken']

        for r_h in required_headers:
            if r_h not in request.args:
                return 'error'

        #get an id and increment the counter
        self.id_count_lock.acquire()
        id = self.id_count;
        self.id_count += 1
        self.id_count_lock.release()

        package_name = request.args['sectoken'][0]

        if 'document' not in request.args:
            package = Package(package_name)
        else:
            fullpath = '/var/local/exelearning/' + package_name + '_' + str(random.randrange(1,999999)) + '.elp'
            try:
                elp_file = open(fullpath, "wb")
                elp_file.write(request.args['document'][0])
                elp_file.close()
                package = Package.load(fullpath, True, None)
                package.set_name(package_name)
            except:
                return 'error'

        self.putChild(str(id), LdShakeDocument({
            'name':     request.args['name'][0],
            'sectoken': request.args['sectoken'][0],
            'ldshake_frame_origin': request.args['ldshake_frame_origin'][0]
        }, self, package, self.webserver))

        #return the resource URL
        return request.prePathURL() + str(id) + '/'
开发者ID:,项目名称:,代码行数:37,代码来源:


示例16: __importIdevice

 def __importIdevice(self, filename):
     """
     import the idevices which are not existed in current package from another package
     """
     newPackage = Package.load(filename)
     for idevice in newPackage.idevices:
         isExisted = False
         for currentIdevice in self.ideviceStore.generic:
             if idevice.title == currentIdevice.title:
                 isExisted = True
                 break
         if not isExisted:
             newIdevice = idevice.clone()
             self.ideviceStore.addIdevice(newIdevice)
     self.ideviceStore.save()
开发者ID:,项目名称:,代码行数:15,代码来源:


示例17: launch

    def launch(self):
        """
        launches the webbrowser
        """

        if self.packagePath:
            try:
                package = Package.load(self.packagePath)
                self.webServer.root.package = package
                launchBrowser(self.config, package.name)
            except:
                self.webServer.root.packagePath = None
                launchBrowser(self.config, "")
        else:
            launchBrowser(self.config, "")
开发者ID:UstadMobile,项目名称:eXePUB,代码行数:15,代码来源:application.py


示例18: setUp

 def setUp(self):
     class MyConfig:
         def __init__(self):
             self.port       = 8081
             self.dataDir    = Path(".")
             self.webDir     = Path(".")
             self.exeDir     = Path(".")
             self.configDir  = Path(".")
             self.styles     = ["default"]
     app = Application()
     app.config = MyConfig()
     app.preLaunch()
     self.client = FakeClient()
     self.package = Package('temp')
     app.webServer.root.bindNewPackage(self.package)
     self.outline = app.webServer.root.children['temp'].outlinePane
开发者ID:,项目名称:,代码行数:16,代码来源:


示例19: testExport

 def testExport(self):
     outdir = TempDirPath()
     package = Package.load('testPackage.elp')
     exporter = WebsiteExport('../exe/webui/style/default', 
                              outdir,
                              '../exe/webui/images', 
                              '../exe/webui/scripts',
                              '../exe/webui/templates')
     exporter.export(package)
     assert outdir.isdir()
     assert (outdir / 'index.html').isfile()
     for filename in Path('../exe/webui/style/default').files():
         assert ((outdir / filename.basename()).exists(),
                 'Style file "%s" not copied' % (outdir / filename.basename()))
     pagenodes  = Set([p.node for p in exporter.pages])
     othernodes = Set(self._getNodes([], package.root))
     assert pagenodes == othernodes
     for page in exporter.pages:
         self._testPage(page, outdir)
开发者ID:,项目名称:,代码行数:19,代码来源:


示例20: _testSaveAndLoad

    def _testSaveAndLoad(self):
        packageStore = PackageStore()
        package = packageStore.createPackage()
        # Check that it has been given a default name
        self.assertEquals(package.name, "newPackage")
        package.author = "UoA"
        package.description = "Nice test package"
        Config._getConfigPathOptions = lambda s: ["exe.conf"]
        config = Config()
        filePath = config.dataDir / "package1.elp"
        package.save(filePath)

        package1 = Package.load(filePath)
        self.assert_(package1)
        self.assertEquals(package1.author, "UoA")
        self.assertEquals(package1.description, "Nice test package")
        # Package name should have been set when it was saved
        self.assertEquals(package.name, "package1")
        self.assertEquals(package1.name, "package1")
开发者ID:kohnle-lernmodule,项目名称:palama,代码行数:19,代码来源:testpackage.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python path.toUnicode函数代码示例发布时间:2022-05-24
下一篇:
Python idevice.Idevice类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap