def get_frameworks(): flist = [] frameworks = {} frameworks['No Framework'] = {'bundle': None, 'items': []} for i in ObjCClass.get_names(): if bundles.bundleForClass(i): try: if frameworks[bundles.bundleForClass(i).bundleID]: frameworks[bundles.bundleForClass(i).bundleID]['items'] += [i] else: frameworks[bundles.bundleForClass(i).bundleID] = {'bundle': bundles.bundleForClass(i), 'items': [i]} except KeyError: frameworks[bundles.bundleForClass(i).bundleID] = {'bundle': bundles.bundleForClass(i), 'items': [i]} else: frameworks['No Framework']['items'] += [i] flist = sorted(frameworks.keys()) return {'flist': flist, 'frameworks': frameworks}
def get_classes(): classes = {} classes['No Class'] = [] for i in ObjCClass.get_names(): if bundles.bundleForClass(i): try: if classes[bundles.bundleForClass(i).bundleID]: classes[bundles.bundleForClass(i).bundleID] += [i] else: classes[bundles.bundleForClass(i).bundleID] = [i] except KeyError: classes[bundles.bundleForClass(i).bundleID] = [i] else: classes['No Class'] += [i] clist = [] for k, v in classes.items(): clist += [[k, v]] return clist
def get_classes_for_bundle(bundle, regex=True, class_imfo=True, alloc=False): results = [] if isinstance(bundle, (str)) and regex: search = re.compile(bundle) if isinstance(bundle, (type(re.compile('')))): search = bundle for i in ObjCClass.get_names(): if bundles.bundleForClass(i): if regex: if isinstance(bundles.bundleForClass(i).bundleID, (str)): if search.match(bundles.bundleForClass(i).bundleID): results += [i] else: if isinstance(bundles.bundleForClass(i).bundleID, (str)): if bundle in bundles.bundleForClass(i).bundleID: results += [i] if class_imfo: results = [ObjCClassInfo(i) for i in results] return results
# coding: utf-8 # https://forum.omz-software.com/topic/2808/bug-objc_util-and-dir from objc_util import ObjCClass print('\n'.join(ObjCClass.get_names('OM')))
# coding: utf-8 # https://forum.omz-software.com/topic/2876/pydia-a-package-installer-for-pythonista/2 from objc_util import * c= ObjCClass.get_names(prefix='UI')+ObjCClass.get_names(prefix='NS') for cls in c: if not cls.startswith('_'): try: globals()[cls]=ObjCClass(cls) except ValueError: pass #============================== from objc_util import ObjCClass globals().update({n: ObjCClass(n) for n in ObjCClass.get_names('UI')})