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


Python Res.Error方法代码示例

本文整理汇总了Python中Carbon.Res.Error方法的典型用法代码示例。如果您正苦于以下问题:Python Res.Error方法的具体用法?Python Res.Error怎么用?Python Res.Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carbon.Res的用法示例。


在下文中一共展示了Res.Error方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: writePlistToResource

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [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: findtemplate

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def findtemplate(template=None):
    """Locate the applet template along sys.path"""
    if MacOS.runtimemodel == 'macho':
        return None
    if not template:
        template=TEMPLATE
    for p in sys.path:
        file = os.path.join(p, template)
        try:
            file, d1, d2 = Carbon.File.FSResolveAliasFile(file, 1)
            break
        except (Carbon.File.Error, ValueError):
            continue
    else:
        raise BuildError, "Template %r not found on sys.path" % (template,)
    file = file.as_pathname()
    return file 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:buildtools.py

示例3: close

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def close(self):
		if self.closed:
			return
		Res.UseResFile(self.resref)
		try:
			res = Res.Get1NamedResource('sfnt', self.fullname)
		except Res.Error:
			pass
		else:
			res.RemoveResource()
		res = Res.Resource(self.file.getvalue())
		if self.res_id is None:
			self.res_id = Res.Unique1ID('sfnt')
		res.AddResource('sfnt', self.res_id, self.fullname)
		res.ChangedResource()
		
		self.createFond()
		del self.ttFont
		Res.CloseResFile(self.resref)
		self.file.close()
		self.closed = 1 
开发者ID:gltn,项目名称:stdm,代码行数:23,代码来源:macUtils.py

示例4: open_pathname

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def open_pathname(pathname, verbose=0):
    """Open a resource file given by pathname, possibly decoding an
    AppleSingle file"""
    # No resource fork. We may be on OSX, and this may be either
    # a data-fork based resource file or a AppleSingle file
    # from the CVS repository.
    try:
        refno = Res.FSOpenResourceFile(pathname, u'', 1)
    except Res.Error, arg:
        if arg[0] != -199:
            # -199 is "bad resource map"
            raise 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:macresource.py

示例5: resource_pathname

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def resource_pathname(pathname, verbose=0):
    """Return the pathname for a resource file (either DF or RF based).
    If the pathname given already refers to such a file simply return it,
    otherwise first decode it."""
    # No resource fork. We may be on OSX, and this may be either
    # a data-fork based resource file or a AppleSingle file
    # from the CVS repository.
    try:
        refno = Res.FSOpenResourceFile(pathname, u'', 1)
    except Res.Error, arg:
        if arg[0] != -199:
            # -199 is "bad resource map"
            raise 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:15,代码来源:macresource.py

示例6: close

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def close(self):
		if self.resref <> None:
			try:
				Res.CloseResFile(self.resref)
			except Res.Error:
				pass
			self.resref = None 
开发者ID:gltn,项目名称:stdm,代码行数:9,代码来源:fondLib.py

示例7: MyOpenResFile

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def MyOpenResFile(path):
	mode = 1  # read only
	try:
		resref = Res.FSOpenResFile(path, mode)
	except Res.Error:
		# try data fork
		resref = Res.FSOpenResourceFile(path, u'', mode)
	return resref 
开发者ID:gltn,项目名称:stdm,代码行数:10,代码来源:macUtils.py

示例8: getSFNTResIndices

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def getSFNTResIndices(path):
	"""Determine whether a file has a resource fork or not."""
	try:
		resref = MyOpenResFile(path)
	except Res.Error:
		return []
	Res.UseResFile(resref)
	numSFNTs = Res.Count1Resources('sfnt')
	Res.CloseResFile(resref)
	return range(1, numSFNTs + 1) 
开发者ID:gltn,项目名称:stdm,代码行数:12,代码来源:macUtils.py

示例9: copyres

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def copyres(input, output, skiptypes, skipowner, progress=None):
    ctor = None
    alltypes = []
    Res.UseResFile(input)
    ntypes = Res.Count1Types()
    progress_type_inc = 50/ntypes
    for itype in range(1, 1+ntypes):
        type = Res.Get1IndType(itype)
        if type in skiptypes:
            continue
        alltypes.append(type)
        nresources = Res.Count1Resources(type)
        progress_cur_inc = progress_type_inc/nresources
        for ires in range(1, 1+nresources):
            res = Res.Get1IndResource(type, ires)
            id, type, name = res.GetResInfo()
            lcname = string.lower(name)

            if lcname == OWNERNAME and id == 0:
                if skipowner:
                    continue # Skip this one
                else:
                    ctor = type
            size = res.size
            attrs = res.GetResAttrs()
            if progress:
                progress.label("Copy %s %d %s"%(type, id, name))
                progress.inc(progress_cur_inc)
            res.LoadResource()
            res.DetachResource()
            Res.UseResFile(output)
            try:
                res2 = Res.Get1Resource(type, id)
            except MacOS.Error:
                res2 = None
            if res2:
                if progress:
                    progress.label("Overwrite %s %d %s"%(type, id, name))
                    progress.inc(0)
                res2.RemoveResource()
            res.AddResource(type, id, name)
            res.WriteResource()
            attrs = attrs | res.GetResAttrs()
            res.SetResAttrs(attrs)
            Res.UseResFile(input)
    return alltypes, ctor 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:48,代码来源:buildtools.py

示例10: need

# 需要导入模块: from Carbon import Res [as 别名]
# 或者: from Carbon.Res import Error [as 别名]
def need(restype, resid, filename=None, modname=None):
    """Open a resource file, if needed. restype and resid
    are required parameters, and identify the resource for which to test. If it
    is available we are done. If it is not available we look for a file filename
    (default: modname with .rsrc appended) either in the same folder as
    where modname was loaded from, or otherwise across sys.path.

    Returns the refno of the resource file opened (or None)"""

    if modname is None and filename is None:
        raise ArgumentError, "Either filename or modname argument (or both) must be given"

    if type(resid) is type(1):
        try:
            h = Res.GetResource(restype, resid)
        except Res.Error:
            pass
        else:
            return None
    else:
        try:
            h = Res.GetNamedResource(restype, resid)
        except Res.Error:
            pass
        else:
            return None

    # Construct a filename if we don't have one
    if not filename:
        if '.' in modname:
            filename = modname.split('.')[-1] + '.rsrc'
        else:
            filename = modname + '.rsrc'

    # Now create a list of folders to search
    searchdirs = []
    if modname == '__main__':
        # If we're main we look in the current directory
        searchdirs = [os.curdir]
    if modname in sys.modules:
        mod = sys.modules[modname]
        if hasattr(mod, '__file__'):
            searchdirs = [os.path.dirname(mod.__file__)]
    searchdirs.extend(sys.path)

    # And look for the file
    for dir in searchdirs:
        pathname = os.path.join(dir, filename)
        if os.path.exists(pathname):
            break
    else:
        raise ResourceFileNotFoundError, filename

    refno = open_pathname(pathname)

    # And check that the resource exists now
    if type(resid) is type(1):
        h = Res.GetResource(restype, resid)
    else:
        h = Res.GetNamedResource(restype, resid)
    return refno 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:63,代码来源:macresource.py


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