本文整理汇总了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)
示例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