本文整理汇总了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()
#.........这里部分代码省略.........