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


Python NSDictionary.alloc方法代码示例

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


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

示例1: readGlyphsFile

# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import alloc [as 别名]
def readGlyphsFile(filePath):
	print "Import Glyphs File"
	pool = NSAutoreleasePool.alloc().init()
	GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)
	if GlyphsDoc is None:
		print "Could not load .glyphs file."
		pool.drain()
		return
	loadGlyphsInfo()
	from FL import fl, Font
	folder, base = os.path.split(filePath)
	base = base.replace(".glyphs", ".vfb")
	dest = os.path.join(folder, base)
	f = Font(  )
	fl.Add(f)
	global convertName
	try:
		convertName = GlyphsDoc["disablesNiceNames"] != None
	except:
		pass
	if not setFontInfo(f, GlyphsDoc):
		return False
	readGlyphs(f, GlyphsDoc)
	readKerning(f, GlyphsDoc)
	setLegacyNames(f)
	readFeatures(f, GlyphsDoc)
	
	fl.UpdateFont()
	f.modified = 0
	pool.drain()
开发者ID:andreirobu,项目名称:Glyphs-Scripts-2,代码行数:32,代码来源:Glyphs+Import.py

示例2: loadGlyphsInfo

# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import alloc [as 别名]
def loadGlyphsInfo():
	try:
		GlyphsPath = NSWorkspace.sharedWorkspace().URLForApplicationWithBundleIdentifier_("com.GeorgSeifert.Glyphs2")
		if GlyphsPath is None:
			GlyphsPath = NSWorkspace.sharedWorkspace().URLForApplicationWithBundleIdentifier_("com.GeorgSeifert.Glyphs")
		if GlyphsPath is None:
			GlyphsPath = NSWorkspace.sharedWorkspace().URLForApplicationWithBundleIdentifier_("com.schriftgestaltung.Glyphs")
		if GlyphsPath is None:
			GlyphsPath = NSWorkspace.sharedWorkspace().URLForApplicationWithBundleIdentifier_("com.schriftgestaltung.GlyphsMini")
		GlyphsPath = GlyphsPath.path()
	except:
		return
	
	if GlyphsPath is not None:
		GlyphsInfoPath = GlyphsPath+"/Contents/Frameworks/GlyphsCore.framework/Versions/A/Resources/GlyphData.xml"
		WeightCodesPath = GlyphsPath+"/Contents/Frameworks/GlyphsCore.framework/Versions/A/Resources/weights.plist"
	
	parseGlyphDataFile(GlyphsInfoPath)
	
	CustomGlyphsInfoPath = applicationSupportFolder()
	if CustomGlyphsInfoPath:
		CustomGlyphsInfoPath = CustomGlyphsInfoPath.stringByAppendingPathComponent_("/Info/GlyphData.xml")
		if os.path.isfile(CustomGlyphsInfoPath):
			parseGlyphDataFile(CustomGlyphsInfoPath)
	
	global weightCodes
	weightCodes = NSDictionary.alloc().initWithContentsOfFile_(WeightCodesPath)
开发者ID:andreirobu,项目名称:Glyphs-Scripts-2,代码行数:29,代码来源:Glyphs+Import.py

示例3: __init__

# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import alloc [as 别名]
    def __init__(self, plist_path=BOOKS_PLIST_PATH):
        if FMT_BINARY is None:
            if not NSDictionary is None:
                self.plist = NSDictionary.alloc().initWithContentsOfFile_(plist_path)
            else:
                self.plist = Ibex._ibex_plutil_read_xml(plist_path)
        else:
            self.plist = readPlist(plist_path)

        if self.plist is None:
            raise IbexError('%s: failed to read property list' % plist_path)
开发者ID:moretension,项目名称:ibex,代码行数:13,代码来源:ibex.py

示例4: readGlyphsFile

# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import alloc [as 别名]
def readGlyphsFile(filePath):
    print "Import Glyphs File"
    pool = None
    try:
        from Foundation import NSAutoreleasePool, NSDictionary
    except ImportError:
        # on Windows, PyObjC is not available
        with open(filePath, "rb") as f:
            data = f.read()
        if data.startswith("<?xml"):
            # use the built-in plistlib module for XML plist
            from plistlib import readPlistFromString

            GlyphsDoc = readPlistFromString(data)
        else:
            # use glyphsLib's Parser for ASCII plist.
            # Download it from: https://github.com/googlei18n/glyphsLib
            from glyphsLib.parser import Parser

            GlyphsDoc = Parser(dict_type=dict).parse(data)
    else:
        # on OS X, use NSDictionary
        pool = NSAutoreleasePool.alloc().init()
        GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)

    if not GlyphsDoc:
        print "Could not load .glyphs file."
        if pool:
            pool.drain()
        return

    from FL import fl, Font

    folder, base = os.path.split(filePath)
    base = base.replace(".glyphs", ".vfb")
    dest = os.path.join(folder, base)
    f = Font()
    fl.Add(f)
    global convertName
    try:
        convertName = GlyphsDoc["disablesNiceNames"] != None
    except:
        pass
    if not setFontInfo(f, GlyphsDoc):
        return False
    readGlyphs(f, GlyphsDoc)
    readKerning(f, GlyphsDoc)
    setLegacyNames(f)
    readFeatures(f, GlyphsDoc)

    fl.UpdateFont()
    f.modified = 0
    if pool:
        pool.drain()
开发者ID:schriftgestalt,项目名称:Glyphs-Scripts,代码行数:56,代码来源:Glyphs+Import.py

示例5: add

# 需要导入模块: from Foundation import NSDictionary [as 别名]
# 或者: from Foundation.NSDictionary import alloc [as 别名]
	def add(self, label, uri, index=-1):
		if label in self.labels:
			return
		if index == -1 or index > len(self.items):
			index = len(self.items)
		elif index < -1:
			index = 0
		new_item = NSDictionary.alloc().initWithDictionary_(
			dict(
				Name=NSString.alloc().initWithString_(label), 
				URL=NSString.alloc().initWithString_(uri)
			)
		)
		self.items.insert(index, new_item)
		self.labels.append(label)
开发者ID:robperc,项目名称:FavServersEditor,代码行数:17,代码来源:FavServersEditor.py


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