1''' 2Python mapping for the Foundation framework. 3 4This module does not contain docstrings for the wrapped code, check Apple's 5documentation for details on how to use these functions and classes. 6''' 7 8import objc as _objc 9#import ApplicationServices 10from CoreFoundation import * 11 12from Foundation._inlines import _inline_list_ 13 14__bundle__ = _objc.initFrameworkWrapper("Foundation", 15 frameworkIdentifier="com.apple.Foundation", 16 frameworkPath=_objc.pathForFramework( 17 "/System/Library/Frameworks/Foundation.framework"), 18 globals=globals(), 19 inlineTab=_inline_list_) 20 21# Import the various manually maintained bits: 22from Foundation._functiondefines import * 23from Foundation._Foundation import * 24 25import Foundation._nsobject 26import Foundation._nsindexset 27 28YES = objc.YES 29NO = objc.NO 30 31def MIN(a, b): 32 if a < b: 33 return a 34 else: 35 return b 36 37def MAX(a, b): 38 if a < b: 39 return b 40 else: 41 return a 42 43ABS = abs 44 45import sys 46NSMaximumStringLength = sys.maxint - 1 47del sys 48 49class _OC_DisabledSuddenTermination (object): 50 """ 51 Helper class to implement NSDisabledSuddenTermination 52 53 Usage:: 54 55 with NSDisabledSuddenTermination: 56 pass 57 58 Inside the with block sudden termination is disabled. 59 60 This only has an effect on OSX 10.6 or later. 61 """ 62 if hasattr(NSProcessInfo, 'disableSuddenTermination'): 63 def __enter__(self): 64 NSProcessInfo.processInfo().disableSuddenTermination() 65 66 def __exit__(self, type, value, tb): 67 NSProcessInfo.processInfo().enableSuddenTermination() 68 69 else: 70 def __enter__(self): 71 pass 72 73 def __exit__(self, type, value, tb): 74 pass 75 76 77NSDisabledSuddenTermination = _OC_DisabledSuddenTermination() 78