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


Python Foundation.NSMutableDictionary类代码示例

本文整理汇总了Python中Foundation.NSMutableDictionary的典型用法代码示例。如果您正苦于以下问题:Python NSMutableDictionary类的具体用法?Python NSMutableDictionary怎么用?Python NSMutableDictionary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: fixSpotlight

def fixSpotlight ():
  DISABLED_ITEMS=set(["MENU_WEBSEARCH", "MENU_SPOTLIGHT_SUGGESTIONS", "OTHER", "BOOKMARKS", "MESSAGES"])
  REQUIRED_ITEM_KEYS=set(["enabled", "name"])
  BUNDLE_ID="com.apple.Spotlight"
  PREF_NAME="orderedItems"
  DEFAULT_VALUE=[
    {'enabled' : True, 'name' : 'APPLICATIONS'},
    {'enabled' : False, 'name' : 'MENU_SPOTLIGHT_SUGGESTIONS'},
    {'enabled' : True, 'name' : 'MENU_CONVERSION'},
    {'enabled' : True, 'name' : 'MENU_EXPRESSION'},
    {'enabled' : True, 'name' : 'MENU_DEFINITION'},
    {'enabled' : True, 'name' : 'SYSTEM_PREFS'},
    {'enabled' : True, 'name' : 'DOCUMENTS'},
    {'enabled' : True, 'name' : 'DIRECTORIES'},
    {'enabled' : True, 'name' : 'PRESENTATIONS'},
    {'enabled' : True, 'name' : 'SPREADSHEETS'},
    {'enabled' : True, 'name' : 'PDF'},
    {'enabled' : False, 'name' : 'MESSAGES'},
    {'enabled' : True, 'name' : 'CONTACT'},
    {'enabled' : True, 'name' : 'EVENT_TODO'},
    {'enabled' : True, 'name' : 'IMAGES'},
    {'enabled' : False, 'name' : 'BOOKMARKS'},
    {'enabled' : True, 'name' : 'MUSIC'},
    {'enabled' : True, 'name' : 'MOVIES'},
    {'enabled' : True, 'name' : 'FONTS'},
    {'enabled' : False, 'name' : 'MENU_OTHER'},
    {'enabled' : False, 'name' : 'MENU_WEBSEARCH'}
  ]

  items = CFPreferencesCopyValue(PREF_NAME, BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
  newItems = None
  if items is None or len(items) is 0:
    # Actual preference values are populated on demand; if the user
    # hasn't previously configured Spotlight, the preference value
    # will be unavailable
    newItems = DEFAULT_VALUE
  else:
    newItems = NSMutableArray.new()
    for item in items:
      print item['name']
      missing_keys = []
      for key in REQUIRED_ITEM_KEYS:
        if not item.has_key(key):
          missing_keys.append(key)

      if len(missing_keys) != 0:
        print "Preference item %s is missing expected keys (%s), skipping" % (item, missing_keys)
        newItems.append(item)
        continue

      if item["name"] not in DISABLED_ITEMS:
        newItems.append(item)
        continue

      newItem = NSMutableDictionary.dictionaryWithDictionary_(item)
      newItem.setObject_forKey_(0, "enabled")
      newItems.append(newItem)

  CFPreferencesSetValue(PREF_NAME, newItems, BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
  CFPreferencesSynchronize(BUNDLE_ID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost)
开发者ID:noroot,项目名称:fix-macosx,代码行数:60,代码来源:fix-macosx.py

示例2: change_bundle_id

def change_bundle_id(filename, new_bundle_id):
	
    keyToModify = 'CFBundleIdentifier'
    plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename)
    if plist != None and keyToModify in plist.allKeys():
        plist[keyToModify] = new_bundle_id
        plist.writeToFile_atomically_(filename, 1)
开发者ID:akfreas,项目名称:ios-ci-tools,代码行数:7,代码来源:PlistUtility.py

示例3: testFunctions

    def testFunctions(self):
        ref = SCPreferencesCreate(None, "pyobjc.test", "pyobjc.test")
        self.assertIsInstance(ref, SCPreferencesRef)

        r = SCPreferencesAddValue(ref, "use",
                NSMutableDictionary.dictionaryWithDictionary_(
                    { "python2": True, "python3": False }))
        self.assertTrue(r)

        v = SCPreferencesPathCreateUniqueChild(ref, "/")
        self.assertIsInstance(v, unicode)

        v = SCPreferencesPathGetValue(ref, "/use")
        self.assertIsInstance(v, NSDictionary)

        v = SCPreferencesPathSetValue(ref, "/use", dict(python2=True, python3=True))
        self.assertTrue(v is True)

        v = SCPreferencesPathSetLink(ref, "/use_python", "/use")
        self.assertTrue(v is True)

        v = SCPreferencesPathGetLink(ref, "/use_python")
        self.assertEqual(v, "/use")

        v = SCPreferencesPathRemoveValue(ref, "/use")
        self.assertTrue(v is True)
开发者ID:aosm,项目名称:pyobjc,代码行数:26,代码来源:test_scpreferencespath.py

示例4: initialize

    def initialize(self):
        paraStyle = NSParagraphStyle.defaultParagraphStyle().mutableCopy()
        paraStyle.setAlignment_(NSCenterTextAlignment)

        self.badgeAttributes = NSMutableDictionary.dictionaryWithObjectsAndKeys_(NSFont.boldSystemFontOfSize_(8),
                                NSFontAttributeName, NSColor.whiteColor(), NSForegroundColorAttributeName,
                                paraStyle, NSParagraphStyleAttributeName)
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:7,代码来源:FancyTabSwitcher.py

示例5: export

    def export(self, canvasname, file, format='pdf', force=False, is_checksum=False):
        """
        Exports one canvas named {@code canvasname}
        """

        format = format.lower()

        chksum = None
        if os.path.isfile(file) and not force:
            existing_chksum = checksum(file) if format != 'pdf' \
                                             else checksum_pdf(file)
            new_chksum = self.compute_canvas_checksum(canvasname)

            if existing_chksum == new_chksum and existing_chksum != None:
                logging.debug('No exporting - canvas %s not changed' % 
                              canvasname)
                return False
            else:
                chksum = new_chksum

        elif format == 'pdf':
            chksum = self.compute_canvas_checksum(canvasname)

        win = self.og.windows.first()

        canvas = [c for c in self.doc.canvases() if c.name() == canvasname]
        if len(canvas) == 1:
            canvas = canvas[0]
        else:
            logging.warn('Canvas %s does not exist in %s' % 
                         (canvasname, self.schemafile))
            return False

        self.og.set(win.canvas, to=canvas)

        export_format = OmniGraffleSchema.EXPORT_FORMATS[format]
        if (export_format == None):
            self.doc.save(in_=file)
        else:
            self.doc.save(as_=export_format, in_=file)

        if not is_checksum and self.options.verbose:
            print "%s" % file

        logging.debug("Exported `%s' into `%s' as %s" % (canvasname, file, format))

        if format == 'pdf':
            # save the checksum
            url = NSURL.fileURLWithPath_(file)
            pdfdoc = PDFKit.PDFDocument.alloc().initWithURL_(url)
            attrs = NSMutableDictionary.alloc().initWithDictionary_(pdfdoc.documentAttributes())

            attrs[PDFKit.PDFDocumentSubjectAttribute] = \
                '%s%s' % (OmniGraffleSchema.PDF_CHECKSUM_ATTRIBUTE, chksum)

            pdfdoc.setDocumentAttributes_(attrs)
            pdfdoc.writeToFile_(file)

        return True
开发者ID:nhooey,项目名称:omnigraffle-export,代码行数:59,代码来源:__init__.py

示例6: get_version

 def get_version(self, dry=False):
     info = Folder(self.app.path).child('Contents/Info.plist')
     if not File(info).exists:
         self.fail("InfoPlist not found at :" + info)
     from Foundation import NSMutableDictionary
     plist = NSMutableDictionary.dictionaryWithContentsOfFile_(info)
     self.app.build_version = plist['CFBundleVersion']
     self.app.marketing_version = plist.get('CFBundleShortVersionString', self.app.build_version)
开发者ID:lakshmivyas,项目名称:conche,代码行数:8,代码来源:providers.py

示例7: _common_init

 def _common_init(self):
     """_common_init"""
     
     self.userNS = NSMutableDictionary.dictionary()
     self.waitingForEngine = False
     
     self.lines = {}
     self.tabSpaces = 4
     self.tabUsesSpaces = True
     self.currentBlockID = self.next_block_ID()
     self.blockRanges = {} # blockID=>CellBlock
开发者ID:dhomeier,项目名称:ipython-py3k,代码行数:11,代码来源:cocoa_frontend.py

示例8: SetPathValue

 def SetPathValue(self, path, value):
   """Sets the path value for a given path."""
   base = os.path.basename(path)
   if not base:
     raise SysconfigError('Updating %s not permitted.' % path)
   tree = os.path.dirname(path)
   settings = SCPreferencesPathGetValue(self.session, tree)
   if not settings:
     settings = NSMutableDictionary.alloc().init()
   settings[base] = value
   SCPreferencesPathSetValue(self.session, tree, settings)
开发者ID:AaronBurchfield,项目名称:imagr,代码行数:11,代码来源:systemconfig.py

示例9: SetPlistKey

def SetPlistKey(plist, key, value):
  """Sets the value for a given key in a plist.

  Args:
    plist: plist to operate on
    key: key to change
    value: value to set
  Returns:
    boolean: success
  Raises:
    MissingImportsError: if NSMutableDictionary is missing
  """
  if NSMutableDictionary:
    mach_info = NSMutableDictionary.dictionaryWithContentsOfFile_(plist)
    if not mach_info:
      mach_info = NSMutableDictionary.alloc().init()
    mach_info[key] = value
    return mach_info.writeToFile_atomically_(plist, True)
  else:
    raise MissingImportsError('NSMutableDictionary not imported successfully.')
开发者ID:SmithersJr,项目名称:macops,代码行数:20,代码来源:gmacpyutil.py

示例10: increment_release_version

def increment_release_version(filename, version):

    keyToModify = 'CFBundleVersion'
    plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename)
    if keyToModify in plist.allKeys():
        versionString = plist[keyToModify]
        versionList = versionString.split(".")
        versionList.append(version)
        versionString = ".".join(versionList)
        plist[keyToModify] = versionString
        plist.writeToFile_atomically_(filename, 1)
        return versionString
开发者ID:akfreas,项目名称:ios-ci-tools,代码行数:12,代码来源:PlistUtility.py

示例11: _ns_update_attributed_title

 def _ns_update_attributed_title(self):
     if self._color:
         ns_button = self._ns_view
         ns_attrs = NSMutableDictionary.alloc().init()
         ns_attrs[NSFontAttributeName] = ns_button.font()
         ns_attrs[NSForegroundColorAttributeName] = self._color._ns_color
         ns_parstyle = NSMutableParagraphStyle.alloc().init()
         ns_parstyle.setAlignment_(ns_button.alignment())
         ns_attrs[NSParagraphStyleAttributeName] = ns_parstyle
         ns_attstr = NSAttributedString.alloc().initWithString_attributes_(
             ns_button.title(), ns_attrs)
         ns_button.setAttributedTitle_(ns_attstr)
开发者ID:karlmatthew,项目名称:pygtk-craigslist,代码行数:12,代码来源:ButtonBasedControls.py

示例12: userNotificationCenter_didActivateNotification_

 def userNotificationCenter_didActivateNotification_(
     self, center: NSUserNotificationCenter, notification: NSMutableDictionary
 ) -> None:
     info = notification.userInfo()
     if info and "uuid" not in info:
         return
     notifications = self._manager.notification_service.get_notifications()
     if (
         info["uuid"] not in notifications
         or notifications[info["uuid"]].is_discard_on_trigger()
     ):
         center.removeDeliveredNotification_(notification)
     self._manager.notification_service.trigger_notification(info["uuid"])
开发者ID:nuxeo,项目名称:nuxeo-drive,代码行数:13,代码来源:pyNotificationCenter.py

示例13: increment_development_version

def increment_development_version(filename, version):

    keyToModify = 'CFBundleShortVersionString'
    plist = NSMutableDictionary.dictionaryWithContentsOfFile_(filename)
    if keyToModify in plist.allKeys():
        versionString = plist[keyToModify]
        versionList = versionString.split(".")
        lastVersionNumber = int(versionList[-1])
        versionList.append(version)
        versionString = ".".join(versionList)
        plist[keyToModify] = versionString
        plist.writeToFile_atomically_(filename, 1)
        return versionString
开发者ID:akfreas,项目名称:ios-ci-tools,代码行数:13,代码来源:PlistUtility.py

示例14: getItemView

 def getItemView(self):
     array = NSMutableArray.array()
     context = NSMutableDictionary.dictionary()
     context.setObject_forKey_(self, NSNibOwner)
     context.setObject_forKey_(array, NSNibTopLevelObjects)
     path = NSBundle.mainBundle().pathForResource_ofType_("AlertPanelView", "nib")
     if not NSBundle.loadNibFile_externalNameTable_withZone_(path, context, self.zone()):
         raise RuntimeError("Internal Error. Could not find AlertPanelView.nib")
     for obj in array:
         if isinstance(obj, NSBox):
             return obj
     else:
         raise RuntimeError("Internal Error. Could not find NSBox in AlertPanelView.nib")
开发者ID:bitsworking,项目名称:blink-cocoa,代码行数:13,代码来源:AlertPanel.py

示例15: change_provisioning_profile

def change_provisioning_profile(filename, build_conf_name, provisioning_profile):

    pbx_dict = NSMutableDictionary.dictionaryWithContentsOfFile_(filename)
    configurations = [x for x in pbx_dict['objects'] if pbx_dict['objects'][x]['isa'] == "XCBuildConfiguration" and pbx_dict['objects'][x]['name'] == "Release" and "PROVISIONING_PROFILE" in pbx_dict['objects'][x]['buildSettings'].allKeys()]    

    profiles_to_replace = []

    for config in configurations:
        profiles_to_replace.append(pbx_dict['objects'][config]['buildSettings']['PROVISIONING_PROFILE'])
        profiles_to_replace.append(pbx_dict['objects'][config]['buildSettings']['PROVISIONING_PROFILE[sdk=iphoneos*]'])

    for profile in profiles_to_replace:
        print "%s was replaced with %s in %s" % (profile, provisioning_profile, filename)
        replace(filename, profile, provisioning_profile)
开发者ID:akfreas,项目名称:ios-ci-tools,代码行数:14,代码来源:PlistUtility.py


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