當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。