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