1""" 2Python <-> Objective-C bridge (PyObjC) 3 4This module defines the core interfaces of the Python<->Objective-C bridge. 5""" 6import sys 7 8# Aliases for some common Objective-C constants 9nil = None 10YES = True 11NO = False 12 13# Import the namespace from the _objc extension 14def _update(g=globals()): 15 16 # Dummy import of copy_reg, needed 17 # for py2app. 18 if sys.version_info[0] == 2: 19 import copy_reg 20 21 import objc._objc as _objc 22 for k in _objc.__dict__: 23 g.setdefault(k, getattr(_objc, k)) 24_update() 25del _update 26 27from objc._convenience import * 28from objc._bridgesupport import * 29 30from objc._dyld import * 31from objc._protocols import * 32from objc._descriptors import * 33from objc._category import * 34from objc._bridges import * 35from objc._compat import * 36from objc._pythonify import * 37from objc._locking import * 38from objc._context import * 39from objc._properties import * 40from objc._lazyimport import * 41 42import objc._pycoder as _pycoder 43 44# Make sure our global autorelease pool is 45# recycled when the interpreter shuts down. 46# This avoids issue1402 in the python 47# bugtracker 48import atexit 49atexit.register(recycleAutoreleasePool) 50 51 52# Helper function for new-style metadata modules 53def _resolve_name(name): 54 if '.' not in name: 55 raise ValueError(name) 56 57 module, name = name.rsplit('.', 1) 58 m = __import__(module) 59 for k in module.split('.')[1:]: 60 m = getattr(m, k) 61 62 return getattr(m, name) 63