當前位置: 首頁>>代碼示例>>Python>>正文


Python Res.Get1Resource方法代碼示例

本文整理匯總了Python中Carbon.Res.Get1Resource方法的典型用法代碼示例。如果您正苦於以下問題:Python Res.Get1Resource方法的具體用法?Python Res.Get1Resource怎麽用?Python Res.Get1Resource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Carbon.Res的用法示例。


在下文中一共展示了Res.Get1Resource方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: writePlistToResource

# 需要導入模塊: from Carbon import Res [as 別名]
# 或者: from Carbon.Res import Get1Resource [as 別名]
def writePlistToResource(rootObject, path, restype='plst', resid=0):
    """Write 'rootObject' as a plst resource to the resource fork of path.
    """
    warnings.warnpy3k("In 3.x, writePlistToResource is removed.", stacklevel=2)
    from Carbon.File import FSRef, FSGetResourceForkName
    from Carbon.Files import fsRdWrPerm
    from Carbon import Res
    plistData = writePlistToString(rootObject)
    fsRef = FSRef(path)
    resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdWrPerm)
    Res.UseResFile(resNum)
    try:
        Res.Get1Resource(restype, resid).RemoveResource()
    except Res.Error:
        pass
    res = Res.Resource(plistData)
    res.AddResource(restype, resid, '')
    res.WriteResource()
    Res.CloseResFile(resNum) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:21,代碼來源:plistlib.py

示例2: __init__

# 需要導入模塊: from Carbon import Res [as 別名]
# 或者: from Carbon.Res import Get1Resource [as 別名]
def __init__(self, path = None):
        self.version = 1
        self.fragments = []
        self.path = path
        if path is not None and os.path.exists(path):
            currentresref = Res.CurResFile()
            resref = Res.FSpOpenResFile(path, 1)
            Res.UseResFile(resref)
            try:
                try:
                    data = Res.Get1Resource('cfrg', 0).data
                except Res.Error:
                    raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback
            finally:
                Res.CloseResFile(resref)
                Res.UseResFile(currentresref)
            self.parse(data)
            if self.version != 1:
                raise error, "unknown 'cfrg' resource format" 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:cfmfile.py

示例3: dataFromFile

# 需要導入模塊: from Carbon import Res [as 別名]
# 或者: from Carbon.Res import Get1Resource [as 別名]
def dataFromFile(pathOrFSSpec, nameOrID="", resType='NFNT'):
	from Carbon import Res
	resref = Res.FSOpenResFile(pathOrFSSpec, 1)	# readonly
	try:
		Res.UseResFile(resref)
		if not nameOrID:
			# just take the first in the file
			res = Res.Get1IndResource(resType, 1)
		elif type(nameOrID) == types.IntType:
			res = Res.Get1Resource(resType, nameOrID)
		else:
			res = Res.Get1NamedResource(resType, nameOrID)
		theID, theType, name = res.GetResInfo()
		data = res.data
	finally:
		Res.CloseResFile(resref)
	return data 
開發者ID:gltn,項目名稱:stdm,代碼行數:19,代碼來源:nfntLib.py

示例4: readPlistFromResource

# 需要導入模塊: from Carbon import Res [as 別名]
# 或者: from Carbon.Res import Get1Resource [as 別名]
def readPlistFromResource(path, restype='plst', resid=0):
    """Read plst resource from the resource fork of path.
    """
    warnings.warnpy3k("In 3.x, readPlistFromResource is removed.",
                      stacklevel=2)
    from Carbon.File import FSRef, FSGetResourceForkName
    from Carbon.Files import fsRdPerm
    from Carbon import Res
    fsRef = FSRef(path)
    resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdPerm)
    Res.UseResFile(resNum)
    plistData = Res.Get1Resource(restype, resid).data
    Res.CloseResFile(resNum)
    return readPlistFromString(plistData) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:16,代碼來源:plistlib.py

示例5: readLWFN

# 需要導入模塊: from Carbon import Res [as 別名]
# 或者: from Carbon.Res import Get1Resource [as 別名]
def readLWFN(path, onlyHeader=0):
	"""reads an LWFN font file, returns raw data"""
	resRef = Res.FSOpenResFile(path, 1)  # read-only
	try:
		Res.UseResFile(resRef)
		n = Res.Count1Resources('POST')
		data = []
		for i in range(501, 501 + n):
			res = Res.Get1Resource('POST', i)
			code = ord(res.data[0])
			if ord(res.data[1]) <> 0:
				raise T1Error, 'corrupt LWFN file'
			if code in [1, 2]:
				if onlyHeader and code == 2:
					break
				data.append(res.data[2:])
			elif code in [3, 5]:
				break
			elif code == 4:
				f = open(path, "rb")
				data.append(f.read())
				f.close()
			elif code == 0:
				pass # comment, ignore
			else:
				raise T1Error, 'bad chunk code: ' + `code`
	finally:
		Res.CloseResFile(resRef)
	data = string.join(data, '')
	assertType1(data)
	return data 
開發者ID:gltn,項目名稱:stdm,代碼行數:33,代碼來源:t1Lib.py


注:本文中的Carbon.Res.Get1Resource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。