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


Python Path.splitpath方法代码示例

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


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

示例1: save

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import splitpath [as 别名]
 def save(self, filename=None, tempFile=False):
     """
     Save package to disk
     pass an optional filename
     """
     self.tempFile = tempFile
     if filename:
         filename = Path(filename)
         name = filename.splitpath()[1]
         if not tempFile:
             self.name = name.basename().splitext()[0]
     elif self.filename:
         filename = Path(self.filename)
     else:
         raise AssertionError(u'No name passed when saving a new package')
     log.debug(u"Will save %s to: %s" % (self.name, filename))
     if tempFile:
         self.nonpersistant.remove('filename')
         oldFilename, self.filename = self.filename, unicode(self.filename)
         try:
             filename.safeSave(self.doSave, _('SAVE FAILED!\nLast succesful save is %s.'))
         finally:
             self.nonpersistant.append('filename')
             self.filename = oldFilename
     else:
         self.filename = filename
         filename.safeSave(self.doSave, _('SAVE FAILED!\nLast succesful save is %s.'))
         self.isChanged = False
         self.updateRecentDocuments(filename)
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: save

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import splitpath [as 别名]
 def save(self, filename=None, tempFile=False):
     if filename:
         filename = Path(filename)
         # If we are being given a new filename...
         # Change our name to match our new filename
         name = filename.splitpath()[1]
         if not tempFile:
             self.name = name.basename().splitext()[0]
     elif self.filename:
         # Otherwise use our last saved/loaded from filename
         filename = Path(self.filename)
     else:
         # If we don't have a last saved/loaded from filename,
         # raise an exception because, we need to have a new
         # file passed when a brand new package is saved
         raise AssertionError(u'No name passed when saving a new package')
     
     if not tempFile:
         # Update our new filename for future saves
         self.filename = filename
         filename.safeSave(self.doSave, _('SAVE FAILED!\nLast succesful save is %s.'))
         self.isChanged = False
开发者ID:UstadMobile,项目名称:eXePUB,代码行数:24,代码来源:epubpackage.py


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