def __init__(self): for key in self._SECTIONS: try: section = CFPreferencesCopyAppValue(key, self._DOMAIN) self.items[key] = section.mutableCopy() except Exception: raise
def __init__(self): for key in self._SECTIONS: try: section = CFPreferencesCopyAppValue(key, self._DOMAIN) self.items[key] = section.mutableCopy() except AttributeError: self.items[key] = self.default_settings[key] except Exception: raise
def __init__(self): for key in self._SECTIONS: try: section = CFPreferencesCopyAppValue(key, self._DOMAIN) self.items[key] = section.mutableCopy() except Exception: raise for key in self._MUTABLE_KEYS + self._IMMUTABLE_KEYS: try: value = CFPreferencesCopyAppValue(key, self._DOMAIN) setattr(self, key.replace('-', '_'), value) except Exception: raise
kCFPreferencesCurrentUser major_versions = ['10', '11', 'DC', '2015'] final_prefs = {} for version in major_versions: prefs_for_vers = CFPreferencesCopyAppValue(version, 'com.adobe.Reader') if prefs_for_vers: print "Found existing key '%s'" % version # if there were preferences, then make a copy and put these in # our final_prefs we're building # - mutableCopy() isn't Python, it's Objective-C - this is because # the Objective-C wrapping around CFPreferences returns immutable # copies, and we want to add our data (EULAAccepted) to these final_prefs[version] = prefs_for_vers.mutableCopy() else: # if no prefs key for this version, create the key as an empty dict # for us to add the EULA key to print "No existing key for '%s', creating new dict" % version final_prefs[version] = {} if 'EULAAccepted' not in final_prefs[version]: print "No EULAAccepted key present, adding to '%s'" % version final_prefs[version]['EULAAccepted'] = True # We could print out all the prefs here # print final_prefs # Note: this seems odd that we might have Objective-C dict types # in some keys and Python dict types in others, but PyObjC massages
major_versions = ['10', '11', 'DC', '2015'] final_prefs = {} for version in major_versions: prefs_for_vers = CFPreferencesCopyAppValue(version, 'com.adobe.Reader') if prefs_for_vers: print "Found existing key '%s'" % version # if there were preferences, then make a copy and put these in # our final_prefs we're building # - mutableCopy() isn't Python, it's Objective-C - this is because # the Objective-C wrapping around CFPreferences returns immutable # copies, and we want to add our data (EULAAccepted) to these final_prefs[version] = prefs_for_vers.mutableCopy() else: # if no prefs key for this version, create the key as an empty dict # for us to add the EULA key to print "No existing key for '%s', creating new dict" % version final_prefs[version] = {} if 'EULAAccepted' not in final_prefs[version]: print "No EULAAccepted key present, adding to '%s'" % version final_prefs[version]['EULAAccepted'] = True # We could print out all the prefs here # print final_prefs # Note: this seems odd that we might have Objective-C dict types # in some keys and Python dict types in others, but PyObjC massages