本文整理汇总了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()
示例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)
示例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)
示例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()
示例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)