本文整理汇总了Python中psr.sys.Sys.dirname方法的典型用法代码示例。如果您正苦于以下问题:Python Sys.dirname方法的具体用法?Python Sys.dirname怎么用?Python Sys.dirname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psr.sys.Sys
的用法示例。
在下文中一共展示了Sys.dirname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onCommandMerge
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import dirname [as 别名]
def onCommandMerge(self):
""""""
done = True
if not Sys.g.QUIET : self.parser.print_header()
if done :
toPath = None
try :
Sys.ptask()
key = Io.get_data(self.o.keyfile)
km = Kirmah(key)
kcf = None
istar = True
try:
import tarfile
dpath = Sys.dirname(Sys.realpath(self.o.outputfile))+Sys.sep if self.o.outputfile is not None else Sys.dirname(Sys.realpath(self.a[1]))+Sys.sep
if self.o.outputfile is None :
self.o.outputfile = dpath
with tarfile.open(self.a[1], mode='r') as tar:
#~ print(dpath)
tar.extractall(path=dpath)
kcf = None
for tarinfo in tar:
#~ print(tarinfo.name)
if tarinfo.isreg() and tarinfo.name[-4:]=='.kcf':
#~ print(dpath+tarinfo.name)
kcf = dpath+tarinfo.name
if kcf is not None :
km.DIR_OUTBOX = dpath
toPath = km.mergeFile(kcf, self.o.outputfile)
except BadKeyException:
Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
done = False
except Exception :
istar = False
toPath = km.mergeFile(self.a[1], self.o.outputfile)
#~ if self.o.outputfile is not None :
#~ Io.rename(toPath, self.o.outputfile)
#~ toPath = self.o.outputfile
except BadKeyException:
Sys.pwarn((('BadKeyException : ',('wrong key ',Sys.CLZ_WARN_PARAM), ' !'),), False)
done = False
except Exception as e :
done = False
if Sys.g.DEBUG :
print(e)
elif not Sys.g.QUIET :
Sys.pwarn((str(e),))
if not done :
if istar :
with tarfile.open(self.a[1], mode='r') as tar:
for tarinfo in tar:
Sys.removeFile(dpath+tarinfo.name)
if not Sys.g.QUIET :
self.onend_cmd('Kirmah Merge', self.stime, done, toPath)
示例2: createNewKey
# 需要导入模块: from psr.sys import Sys [as 别名]
# 或者: from psr.sys.Sys import dirname [as 别名]
def createNewKey(self, filename, size):
""""""
if not Sys.isdir(Sys.dirname(filename)):
Sys.mkdir_p(Sys.dirname(filename))
Io.set_data(filename,KeyGen(size).key[:size])