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


Python MacOS.openrf方法代码示例

本文整理汇总了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() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:22,代码来源:applesingle.py

示例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 '' 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:20,代码来源:test_macostools.py

示例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 
开发者ID:glmcdona,项目名称:meddle,代码行数:13,代码来源:binhex.py

示例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) 
开发者ID:glmcdona,项目名称:meddle,代码行数:8,代码来源:binhex.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:41,代码来源:macostools.py

示例6: openrf

# 需要导入模块: import MacOS [as 别名]
# 或者: from MacOS import openrf [as 别名]
def openrf(path, mode):
            return open(path + '.rsrc', mode) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:4,代码来源:applesingle.py

示例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() 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:9,代码来源:test_macostools.py

示例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) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:9,代码来源:test_applesingle.py


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