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


Python NSAutoreleasePool.alloc方法代码示例

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


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

示例1: readGlyphsFile

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool 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: get_modified

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def get_modified(self, obj):
     with self.lock:
         try:
             if self.dirty.get(obj, False):
                 pool = NSAutoreleasePool.alloc().init()
                 old_password = self.oldvalues.get(obj, self.default)
                 new_password = self.values.get(obj, self.default)
                 account = (account for account, group in chain(*(attr.values.iteritems() for attr in Account.__dict__.itervalues() if isinstance(attr, SettingsGroupMeta))) if group is obj).next()
                 if self.label is None:
                     label = '%s (%s)' % (NSApp.delegate().applicationName, account.id)
                 else:
                     label = '%s %s (%s)' % (NSApp.delegate().applicationName, self.label, account.id)
                 k = EMGenericKeychainItem.genericKeychainItemForService_withUsername_(label, account.id)
                 if k is None and new_password:
                     EMGenericKeychainItem.addGenericKeychainItemForService_withUsername_password_(label, account.id, new_password)
                 elif k is not None:
                     if new_password:
                         k.setPassword_(new_password)
                     else:
                         k.removeFromKeychain()
                 return ModifiedValue(old=old_password, new=new_password)
             else:
                 return None
         finally:
             try:
                 self.oldvalues[obj] = self.values[obj]
             except KeyError:
                 self.oldvalues.pop(obj, None)
             self.dirty[obj] = False
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:31,代码来源:__init__.py

示例3: hideAndClear

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def hideAndClear():
     # Will be run from worker thread, create own NSAutoreleasePool
     pool = NSAutoreleasePool.alloc().init()
     self.password.SetValue("")
     self.status.SetLabel("")
     self.Hide()
     del pool
开发者ID:nolanlum,项目名称:airbears-supplicant,代码行数:9,代码来源:ui.py

示例4: get_country_code

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
def get_country_code():
    try:
        if platform == 'linux':
            l = locale.getdefaultlocale()[0]
            if l is not None:
                return l.split(LOCALE_SPLITCHAR, 1)[1][:2].upper()
        elif platform == 'mac':
            from Foundation import NSAutoreleasePool, NSLocale, NSLocaleCountryCode
            pool = NSAutoreleasePool.alloc().init()
            try:
                return NSLocale.currentLocale().objectForKey_(NSLocaleCountryCode).upper()
            finally:
                del pool

        else:
            from dropbox.win32.version import WIN2K, WINDOWS_VERSION
            if WINDOWS_VERSION != WIN2K:
                GEO_ISO2 = 4
                nation = ctypes.windll.kernel32.GetUserGeoID(16)
                buf = ctypes.create_string_buffer(20)
                if ctypes.windll.kernel32.GetGeoInfoA(nation, GEO_ISO2, ctypes.byref(buf), ctypes.sizeof(buf), 0):
                    return buf.value.upper()
    except Exception:
        unhandled_exc_handler()

    return 'US'
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:28,代码来源:i18n.py

示例5: callLater

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
def callLater(delay, func, *args, **kwargs):
    """call a function on the main thread after a delay (async)"""
    pool = NSAutoreleasePool.alloc().init()
    obj = PyObjCAppHelperCaller.alloc().initWithArgs_((func, args, kwargs))
    obj.callLater_(delay)
    del obj
    del pool
开发者ID:BMXE,项目名称:music-player,代码行数:9,代码来源:AppHelper.py

示例6: _doPostWithParams_

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def _doPostWithParams_(self, params):
     script, message = params
     pool = NSAutoreleasePool.alloc().init()
     try:
         script.post_message(message)
     except Exception, e:
         print "Failed to post to script:", e
开发者ID:BlastarIndia,项目名称:frida-python,代码行数:9,代码来源:Capture.py

示例7: hideAndClear

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def hideAndClear():
     # Will be run from worker thread, create own NSAutoreleasePool
     if sys.platform == "darwin":
         pool = NSAutoreleasePool.alloc().init()
     self.password.SetValue("")
     self.status.SetLabel("")
     self.Hide()
     if sys.platform == "darwin":
         del pool
开发者ID:gnowxilef,项目名称:airbears-supplicant,代码行数:11,代码来源:ui.py

示例8: callAfter

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
def callAfter(func, *args, **kwargs):
    """
    Call a function on the Main thread (async).
    """
    pool = NSAutoreleasePool.alloc().init()
    runner = PyObjCMessageRunner.alloc().initWithPayload_((func, args, kwargs))
    runner.callAfter()
    del runner
    del pool
开发者ID:SalvatoreTosti,项目名称:free-armor-trimming,代码行数:11,代码来源:AppHelper.py

示例9: restart

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
def restart():
    report_bad_assumption('Trying to restart finder.')
    if has_progress_windows():
        raise FinderBusyError()
    pool = NSAutoreleasePool.alloc().init()
    try:
        return FinderRestarterHelper.alloc().initAndRestartFinder()
    finally:
        del pool
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:11,代码来源:finder.py

示例10: wrapped_execute

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def wrapped_execute(self, msg, lines):
     """wrapped_execute"""
     try:
         p = NSAutoreleasePool.alloc().init()
         result = super(AutoreleasePoolWrappedThreadedEngineService,
                         self).wrapped_execute(msg, lines)
     finally:
         p.drain()
     
     return result
开发者ID:dhomeier,项目名称:ipython-py3k,代码行数:12,代码来源:cocoa_frontend.py

示例11: testBasic

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
    def testBasic(self):
        # This is mostly a regression tests, the function used to crash on
        # this...
        if objc.platform != 'MACOSX':
            return

        pool = NSAutoreleasePool.alloc().init()
        s = NSLocalizedString(b"hello world".decode('ascii'), b"".decode('ascii'))
        del pool
        self.assertEqual (s, b"hello world".decode('ascii'))
开发者ID:BMXE,项目名称:music-player,代码行数:12,代码来源:test_nslocalizedstring.py

示例12: readGlyphsFile

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

示例13: open

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
        def open(self, url, new = 0, autoraise = True):
            pool = NSAutoreleasePool.alloc().init()
            try:
                fake_url = NSURL.URLWithString_('http:')
                os_status, app_ref, appurl = LSGetApplicationForURL(fake_url, kLSRolesAll, None, None)
                if os_status != 0:
                    raise Exception('No browser default?')
                self._name = app_ref.as_pathname().encode('utf-8')
            finally:
                del pool

            return super(DefaultMacBrowser, self).open(url, new, autoraise)
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:14,代码来源:url_info.py

示例14: _doDetachWithParams_

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
 def _doDetachWithParams_(self, params):
     session, script = params
     pool = NSAutoreleasePool.alloc().init()
     try:
         script.unload()
     except:
         pass
     try:
         session.detach()
     except:
         pass
     del pool
开发者ID:BlastarIndia,项目名称:frida-python,代码行数:14,代码来源:Capture.py

示例15: run

# 需要导入模块: from Foundation import NSAutoreleasePool [as 别名]
# 或者: from Foundation.NSAutoreleasePool import alloc [as 别名]
    def run(self):
        # start streaming acquisition
        try:
            from Foundation import NSAutoreleasePool
            pool = NSAutoreleasePool.alloc().init()
        except ImportError:
            pass # Windows

        # acquisition loop
        while self.monitor.running:
            #print "Stream thread tryin to enqueue", time.clock()
            self.serial_queue.enqueue(self.acquire_stream)
开发者ID:jaygottfried,项目名称:Mod_Voyeur,代码行数:14,代码来源:monitor.py


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