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


Python Path.open方法代码示例

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


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

示例1: testUstadMobileExport

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import open [as 别名]
 def testUstadMobileExport(self):
     # Load a package
     filePath = self.inFilePath
     
     package = Package.load(filePath)
     self.assertIsNotNone(package, "Failed to load package")
     
     
     #test the tincan.xml generation
     desc_text = "Description Test"
     package.set_description(desc_text)
     
     self.assertEqual(desc_text, package.get_tincan_description(), 
                      "Description set and picked up")
     
     #test description will be title when description is blank
     package.set_description("")
     self.assertEqual(package.get_tincan_title(), 
                  package.get_tincan_description(),
                  "Description blank, tincan desc = title")
     
     
     
     
     styles_dir = G.application.config.stylesDir / package.style
     xmlExport = XMLExport(G.application.config, styles_dir,
                           self.epubOutPath)
     
     
     xmlExport.export(package)
     
     
     
     self.extract_dir = TempDirPath()
     zip_file = ZipFile(self.epubOutPath)
     zip_file.extractall(self.extract_dir)
     
     outdir = self.extract_dir/"EPUB"
     
     
     #test that we can force it to have a title and identifier
     missing_metadata_dict = {"title" : "", "identifier" : ""}
     
     cover = xmlExport.make_cover_page(package)
     self.assertIsNotNone(cover, "Can create cover for package")
     publication= xmlExport.make_publication_epub3(outdir, package, cover)
     self.assertIsNotNone(publication, "Can create publication object")
     
     
     fixed_metadata = publication.check_metadata_for_epub(
                        missing_metadata_dict, package)
     self.assertTrue(len(fixed_metadata['title']) > 0, 
                     "Title Added")
     
     self.assertEqual(fixed_metadata['identifier'],
                      package.dublinCore.identifier,
                      "Identifier added from dublin core")
     
     
     
     #check that the modification time on our resource files 
     #are as per original so they can be easily cached
     xml_copy_list = xmlExport.make_xml_copy_list(package, outdir) 
     TestUtils.check_copy_list_mod_time(xml_copy_list,self)
     
     
     mainFolder = Path(self.extract_dir/"EPUB")
     assert mainFolder.exists()
     
     exeTocPath = Path(mainFolder / "exetoc.xml")
     
     
     #check the tincan.xml
     tincan_etree_doc = ElementTree.parse(
                      self.extract_dir/"tincan.xml")
     namespaces = {"tincan" : 
                         "http://projecttincan.com/tincan.xsd"}
     tincan_etree = tincan_etree_doc.getroot()
     
     
     launch_el_arr = tincan_etree.findall(
                      "tincan:activities/tincan:activity/tincan:launch",
                      namespaces)
     self.assertEqual(len(launch_el_arr), 1, 
                      "1 activity with launch")
     self.assertEqual(
         tincan_etree.find(
             "tincan:activities/tincan:activity[0]/tincan:name", 
             namespaces).text,
         package.get_tincan_title())
     
     self.assertEqual(
         tincan_etree.find(
            "tincan:activities/tincan:activity[0]/tincan:description",
            namespaces).text,
         package.get_tincan_description(),
         "Description serialized matchese tincan desc")
     
     
     str = exeTocPath.open().read()
#.........这里部分代码省略.........
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:103,代码来源:testustadmobileexport.py


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