本文整理汇总了Python中MacOS.openrf方法的典型用法代码示例。如果您正苦于以下问题:Python MacOS.openrf方法的具体用法?Python MacOS.openrf怎么用?Python MacOS.openrf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MacOS
的用法示例。
在下文中一共展示了MacOS.openrf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tofile
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def tofile(self, path, resonly=False):
outfile = open(path, 'wb')
data = False
if resonly:
if self.resourcefork is None:
raise Error, "No resource fork found"
fp = open(path, 'wb')
fp.write(self.resourcefork)
fp.close()
elif (self.resourcefork is None and self.datafork is None):
raise Error, "No useful forks found"
else:
if self.datafork is not None:
fp = open(path, 'wb')
fp.write(self.datafork)
fp.close()
if self.resourcefork is not None:
fp = MacOS.openrf(path, '*wb')
fp.write(self.resourcefork)
fp.close()
示例2: compareData
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def compareData(self):
fp = open(test_support.TESTFN, 'r')
data1 = fp.read()
fp.close()
fp = open(TESTFN2, 'r')
data2 = fp.read()
fp.close()
if data1 != data2:
return 'Data forks differ'
rfp = MacOS.openrf(test_support.TESTFN, '*rb')
data1 = rfp.read(1000)
rfp.close()
rfp = MacOS.openrf(TESTFN2, '*rb')
data2 = rfp.read(1000)
rfp.close()
if data1 != data2:
return 'Resource forks differ'
return ''
示例3: getfileinfo
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def getfileinfo(name):
finfo = FSSpec(name).FSpGetFInfo()
dir, file = os.path.split(name)
# XXX Get resource/data sizes
fp = open(name, 'rb')
fp.seek(0, 2)
dlen = fp.tell()
fp = openrf(name, '*rb')
fp.seek(0, 2)
rlen = fp.tell()
return file, finfo, dlen, rlen
示例4: openrsrc
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def openrsrc(name, *mode):
if not mode:
mode = '*rb'
else:
mode = '*' + mode[0]
return openrf(name, mode)
示例5: copy
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def copy(src, dst, createpath=0, copydates=1, forcetype=None):
"""Copy a file, including finder info, resource fork, etc"""
src = File.pathname(src)
dst = File.pathname(dst)
if createpath:
mkdirs(os.path.split(dst)[0])
ifp = open(src, 'rb')
ofp = open(dst, 'wb')
d = ifp.read(BUFSIZ)
while d:
ofp.write(d)
d = ifp.read(BUFSIZ)
ifp.close()
ofp.close()
ifp = openrf(src, '*rb')
ofp = openrf(dst, '*wb')
d = ifp.read(BUFSIZ)
while d:
ofp.write(d)
d = ifp.read(BUFSIZ)
ifp.close()
ofp.close()
srcfss = File.FSSpec(src)
dstfss = File.FSSpec(dst)
sf = srcfss.FSpGetFInfo()
df = dstfss.FSpGetFInfo()
df.Creator, df.Type = sf.Creator, sf.Type
if forcetype is not None:
df.Type = forcetype
df.Flags = (sf.Flags & COPY_FLAGS)
dstfss.FSpSetFInfo(df)
if copydates:
srcfsr = File.FSRef(src)
dstfsr = File.FSRef(dst)
catinfo, _, _, _ = srcfsr.FSGetCatalogInfo(Files.kFSCatInfoAllDates)
dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo)
示例6: openrf
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def openrf(path, mode):
return open(path + '.rsrc', mode)
示例7: setUp
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def setUp(self):
fp = open(test_support.TESTFN, 'w')
fp.write('hello world\n')
fp.close()
rfp = MacOS.openrf(test_support.TESTFN, '*wb')
rfp.write('goodbye world\n')
rfp.close()
示例8: compareData
# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def compareData(self, isrf, data):
if isrf:
fp = MacOS.openrf(TESTFN2, '*rb')
else:
fp = open(TESTFN2, 'rb')
filedata = fp.read(1000)
self.assertEqual(data, filedata)