Python plistlib 模块,writePlist() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用plistlib.writePlist()

项目:munki-enrollment-client    作者:gerritdewitt    | 项目源码 | 文件源码
def do_transaction():
    '''Wrapping method.
    Try just transaction A; if that fails, then enroll and
    then do transaction A again.'''
    enrollment_required = False
    enrollment_completed = False
    transaction_a_result_dict = do_transaction_only()
    if not transaction_a_result_dict['result']:
        enrollment_required = True
        enrollment_completed = enroll_only()
        transaction_a_result_dict = do_transaction_only()
    # Add enrollment_status dict to transaction A dict:
    transaction_a_result_dict['enrollment_status'] = {"required":enrollment_required,
                                                    "completed":enrollment_completed,
                                                    "result":(not enrollment_required) or enrollment_completed}
    transaction_a_result_dict['transaction_completed_date'] = datetime.utcnow()
    # Write result:
    plistlib.writePlist(transaction_a_result_dict, config_paths.RESULT_TRANSACTION_A_FILE_PATH)
项目:logbook-packager    作者:rsky    | 项目源码 | 文件源码
def make_plist(self, version=None):
        """
        ?????????????Info.plist?????
        """
        info = {
            'CFBundleDisplayName': DISPLAY_NAME,
            'CFBundleExecutable': EXECUTABLE_NAME,
            'CFBundleIconFile': ICON_FILE_NAME,
            'CFBundleIdentifier': self.bundle_identifier,
            'CFBundleInfoDictionaryVersion': '6.0',
            'CFBundleLocalizations': list(LOCALIZED_BUNDLE_NAMES.keys()),
            'CFBundleName': self.bundle_name,
            'CFBundlePackageType': 'APPL',
            'CFBundleShortVersionString': '1',
            'CFBundleSignature': '???',
            'CFBundleVersion': '1',
            'LSHasLocalizedDisplayName': True,
        }
        if version:
            info['CFBundleShortVersionString'] = version
        path = os.path.join(self.contents_dir, 'Info.plist')
        plistlib.writePlist(info, path)
项目:inter    作者:rsms    | 项目源码 | 文件源码
def renameUFOLib(ufoPath, newNames, dryRun=False, print=print):
  filename = os.path.join(ufoPath, 'lib.plist')
  plist = plistlib.readPlist(filename)

  glyphOrder = plist.get('public.glyphOrder')
  if glyphOrder is not None:
    plist['public.glyphOrder'] = renameStrings(glyphOrder, newNames)

  roboSort = plist.get('com.typemytype.robofont.sort')
  if roboSort is not None:
    for entry in roboSort:
      if isinstance(entry, dict) and entry.get('type') == 'glyphList':
        asc = entry.get('ascending')
        desc = entry.get('descending')
        if asc is not None:
          entry['ascending'] = renameStrings(asc, newNames)
        if desc is not None:
          entry['descending'] = renameStrings(desc, newNames)

  print('Writing', filename)
  if not dryRun:
    plistlib.writePlist(plist, filename)
项目:inter    作者:rsms    | 项目源码 | 文件源码
def renameUFOGroups(ufoPath, newNames, dryRun=False, print=print):
  filename = os.path.join(ufoPath, 'groups.plist')

  plist = None
  try:
    plist = plistlib.readPlist(filename)
  except:
    return

  didChange = False

  for groupName, glyphNames in plist.items():
    for i in range(len(glyphNames)):
      name = glyphNames[i]
      if name in newNames:
        didChange = True
        glyphNames[i] = newNames[name]

  if didChange:
    print('Writing', filename)
    if not dryRun:
      plistlib.writePlist(plist, filename)
项目:build-calibre    作者:kovidgoyal    | 项目源码 | 文件源码
def create_app_clone(self, name, specialise_plist, remove_doc_types=True):
        print('\nCreating ' + name)
        cc_dir = os.path.join(self.contents_dir, name, 'Contents')
        exe_dir = join(cc_dir, 'MacOS')
        os.makedirs(exe_dir)
        for x in os.listdir(self.contents_dir):
            if x.endswith('.app'):
                continue
            if x == 'Info.plist':
                plist = plistlib.readPlist(join(self.contents_dir, x))
                specialise_plist(plist)
                if remove_doc_types:
                    plist.pop('CFBundleDocumentTypes')
                exe = plist['CFBundleExecutable']
                # We cannot symlink the bundle executable as if we do,
                # codesigning fails
                nexe = plist['CFBundleExecutable'] = exe + '-placeholder-for-codesigning'
                shutil.copy2(join(self.contents_dir, 'MacOS', exe), join(exe_dir, nexe))
                exe = join(exe_dir, plist['CFBundleExecutable'])
                plistlib.writePlist(plist, join(cc_dir, x))
            elif x == 'MacOS':
                for item in os.listdir(join(self.contents_dir, 'MacOS')):
                    os.symlink('../../../MacOS/' + item, join(exe_dir, item))
            else:
                os.symlink(join('../..', x), join(cc_dir, x))
项目:iOS-private-api-checker    作者:NetEaseGame    | 项目源码 | 文件源码
def writePlist(rootObject, pathOrFile, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if hasattr(plistlib, "dump"):
            if isinstance(pathOrFile, (bytes, unicode)):
                with open(pathOrFile, 'wb') as f:
                    return plistlib.dump(rootObject, f)
            else:
                return plistlib.dump(rootObject, pathOrFile)
        else:
            return plistlib.writePlist(rootObject, pathOrFile)
    else:
        didOpen = False
        if isinstance(pathOrFile, (bytes, unicode)):
            pathOrFile = open(pathOrFile, 'wb')
            didOpen = True
        writer = PlistWriter(pathOrFile)
        result = writer.writeRoot(rootObject)
        if didOpen:
            pathOrFile.close()
        return result
项目:Alfred_SourceTree    作者:yourtion    | 项目源码 | 文件源码
def writePlist(rootObject, pathOrFile, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if hasattr(plistlib, "dump"):
            if isinstance(pathOrFile, (bytes, unicode)):
                with open(pathOrFile, 'wb') as f:
                    return plistlib.dump(rootObject, f)
            else:
                return plistlib.dump(rootObject, pathOrFile)
        else:
            return plistlib.writePlist(rootObject, pathOrFile)
    else:
        didOpen = False
        if isinstance(pathOrFile, (bytes, unicode)):
            pathOrFile = open(pathOrFile, 'wb')
            didOpen = True
        writer = PlistWriter(pathOrFile)
        result = writer.writeRoot(rootObject)
        if didOpen:
            pathOrFile.close()
        return result
项目:alfred-workFlows-iossimulator    作者:sampayo    | 项目源码 | 文件源码
def writePlist(rootObject, pathOrFile, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        if hasattr(plistlib, "dump"):
            if isinstance(pathOrFile, (bytes, unicode)):
                with open(pathOrFile, 'wb') as f:
                    return plistlib.dump(rootObject, f)
            else:
                return plistlib.dump(rootObject, pathOrFile)
        else:
            return plistlib.writePlist(rootObject, pathOrFile)
    else:
        didOpen = False
        if isinstance(pathOrFile, (bytes, unicode)):
            pathOrFile = open(pathOrFile, 'wb')
            didOpen = True
        writer = PlistWriter(pathOrFile)
        result = writer.writeRoot(rootObject)
        if didOpen:
            pathOrFile.close()
        return result
项目:collection    作者:skywind3000    | 项目源码 | 文件源码
def plist_save(filename, data, binary = False):
    import plistlib
    if not binary:
        plistlib.writePlist(data, filename)
        return 0
    import warnings
    warnings.filterwarnings("ignore")
    tmpname = os.tempnam(None, 'plist.')
    plistlib.writePlist(data, tmpname)
    plutil('-convert', 'binary1', '-o', filename, tmpname)
    os.remove(tmpname)
    return 0


#----------------------------------------------------------------------
# testing case
#----------------------------------------------------------------------
项目:cx_Freeze    作者:anthony-tuininga    | 项目源码 | 文件源码
def create_plist(self):
        """Create the Contents/Info.plist file"""
        # Use custom plist if supplied, otherwise create a simple default.
        if self.custom_info_plist:
            contents = plistlib.readPlist(self.custom_info_plist)
        else:
            contents = {
                'CFBundleIconFile': 'icon.icns',
                'CFBundleDevelopmentRegion': 'English',
            }

        # Ensure CFBundleExecutable is set correctly
        contents['CFBundleExecutable'] = self.bundle_executable

        plist = open(os.path.join(self.contentsDir, 'Info.plist'), 'wb')
        plistlib.writePlist(contents, plist)
        plist.close()
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
def create_plist(self):
                """Create the Contents/Info.plist file"""
                import plistlib
                contents = {
                    'CFBundleName': 'BigBrotherBot (B3) %s' % b3_version,
                    'CFBundleGetInfoString': b3_version,
                    'CFBundleShortVersionString': b3_version,
                    'CFBundleVersion': b3_version,
                    'CFBundlePackageType': 'APPL',
                    'CFBundleIconFile': 'icon.icns',
                    'CFBundleIdentifier': 'net.bigbrotherbot.www',
                    'CFBundleInfoDictionaryVersion': '6.0',
                    'CFBundleDevelopmentRegion': 'English',
                    'CFBundleSpokenName': 'Big Brother Bot (B3)',
                    'CFBundleExecutable': self.bundle_executable
                }

                plist = open(os.path.join(self.contentsDir, 'Info.plist'), 'wb')
                plistlib.writePlist(contents, plist)
                plist.close()
项目:sheagcraig_sal_plugins    作者:sheagcraig    | 项目源码 | 文件源码
def main():
    client_manifest_path = (
        "/Library/Managed Installs/manifests/client_manifest.plist")
    if os.path.exists(client_manifest_path):
        client_manifest = plistlib.readPlist(client_manifest_path)
    else:
        client_manifest = {}

    formatted_results = {
        "plugin": "Manifests",
        "historical": False,
        "data": {"included_manifests": "+".join(
            client_manifest.get("included_manifests", []))}}

    if os.path.exists(RESULTS_PATH):
        plugin_results = plistlib.readPlist(RESULTS_PATH)
    else:
        plugin_results = []

    plugin_results.append(formatted_results)

    plistlib.writePlist(plugin_results, RESULTS_PATH)
项目:sheagcraig_sal_plugins    作者:sheagcraig    | 项目源码 | 文件源码
def main():
    client_manifest_path = (
        "/Library/Managed Installs/manifests/client_manifest.plist")
    if os.path.exists(client_manifest_path):
        client_manifest = plistlib.readPlist(client_manifest_path)
    else:
        client_manifest = {}

    formatted_results = {
        "plugin": "Catalogs",
        "historical": False,
        "data": {"Catalogs": "+".join(client_manifest.get("catalogs", []))}}

    if os.path.exists(RESULTS_PATH):
        plugin_results = plistlib.readPlist(RESULTS_PATH)
    else:
        plugin_results = []

    plugin_results.append(formatted_results)

    plistlib.writePlist(plugin_results, RESULTS_PATH)
项目:NewFileHereMenu    作者:liufsd    | 项目源码 | 文件源码
def main():
   translator = Translator()

   fileName=os.path.expanduser('Preferences.strings')

   if os.path.exists(fileName):

      pl=plistlib.readPlist(fileName)
      lst = []
      for key in pl:
        val = pl[key]
        print('key: %s, val: %s' % (key, val))
        translation = translator.translate(val, dest='ru')
        pl[key]=translation.text
        print('translation: %s' % (pl[key]))

      plistlib.writePlist(pl, 'Preferences_ru.strings')
   else:
      print( '%s does not exist, so can\'t be read' % fileName)
项目:autonbi    作者:bruienne    | 项目源码 | 文件源码
def prepworkdir(workdir):
    """Copies in the required Apple-provided createCommon.sh and also creates
        an empty file named createVariables.sh. We actually pass the variables
        this file might contain using environment variables but it is expected
        to be present so we fake out Apple's createNetInstall.sh script."""

    commonsource = os.path.join(BUILDEXECPATH, 'createCommon.sh')
    commontarget = os.path.join(workdir, 'createCommon.sh')

    shutil.copyfile(commonsource, commontarget)
    open(os.path.join(workdir, 'createVariables.sh'), 'a').close()

    if isHighSierra:
        enterprisedict = {}
        enterprisedict['SIU-SIP-setting'] = True
        enterprisedict['SIU-SKEL-setting'] = False
        enterprisedict['SIU-teamIDs-to-add'] = []

        plistlib.writePlist(enterprisedict, os.path.join(workdir, '.SIUSettings'))

# Example usage of the function:
# decompress('PayloadJava.cpio.xz', 'PayloadJava.cpio')
# Decompresses a xz compressed file from the first input file path to the second output file path
项目:iOSTemplate    作者:ZeroFengLee    | 项目源码 | 文件源码
def changeBuildVersion(self):
        plist = plistlib.readPlist(self.plist_path)
        plist['CFBundleVersion'] = self.build_date

        if self.build_version is not None:
            build_version_list = self.build_version.split('.')
            CFBundleShortVersionString = '.'.join(build_version_list[:3])
            plist['CFBundleShortVersionString'] = CFBundleShortVersionString.rstrip('.0')
        else:
            self.build_version = plist['CFBundleShortVersionString']

        plistlib.writePlist(plist, self.plist_path)
项目:nojs    作者:chrisdickinson    | 项目源码 | 文件源码
def WriteTo(self, target_path):
    plistlib.writePlist(self._data, target_path)
项目:nojs    作者:chrisdickinson    | 项目源码 | 文件源码
def SavePList(path, format, data):
  """Saves |data| as a Plist to |path| in the specified |format|."""
  fd, name = tempfile.mkstemp()
  try:
    with os.fdopen(fd, 'w') as f:
      plistlib.writePlist(data, f)
    subprocess.check_call(['plutil', '-convert', format, '-o', path, name])
  finally:
    os.unlink(name)
项目:mac-admin    作者:jacobfgrant    | 项目源码 | 文件源码
def generate_buildinfo_plist(launchdinfo, pkg_directory):
    """Generate pkg build-info.plist"""
    buildinfo = {
        'postinstall_action': 'none',
        'name': launchdinfo['pkgname'],
        'distribution_style': False,
        'install_location': '/',
        'version': launchdinfo['version'],
        'identifier': launchdinfo['pkgid']
    }
    output = os.path.join(pkg_directory, 'build-info.plist')

    plistlib.writePlist(buildinfo, output)
项目:qt-xcodeproj-embeded-frameworks    作者:lukevear    | 项目源码 | 文件源码
def save_format_xml(self, file_name=None):
        """Saves in old (xml) format"""
        if not file_name:
            file_name = self.pbxproj_path

        # This code is adapted from plistlib.writePlist
        with open(file_name, "w") as f:
            writer = PBXWriter(f)
            writer.writeln("<plist version=\"1.0\">")
            writer.writeValue(self.data)
            writer.writeln("</plist>")
项目:inter    作者:rsms    | 项目源码 | 文件源码
def save(self):
    if self.plist is not None:
      plistlib.writePlist(self.plist, self.filename)
项目:inter    作者:rsms    | 项目源码 | 文件源码
def renameUFOKerning(ufoPath, newNames, dryRun=False, print=print):
  filename = os.path.join(ufoPath, 'kerning.plist')

  plist = None
  try:
    plist = plistlib.readPlist(filename)
  except:
    return

  didChange = False

  newPlist = {}
  for leftName, right in plist.items():
    if leftName in newNames:
      didChange = True
      leftName = newNames[leftName]
    newRight = {}
    for rightName, kernValue in plist.items():
      if rightName in newNames:
        didChange = True
        rightName = newNames[rightName]
      newRight[rightName] = kernValue
    newPlist[leftName] = right

  if didChange:
    print('Writing', filename)
    if not dryRun:
      plistlib.writePlist(newPlist, filename)
项目:inter    作者:rsms    | 项目源码 | 文件源码
def fixupGroups(fontPath, dstGlyphNames, srcToDstMap, dryRun, stats):
  filename = os.path.join(fontPath, 'groups.plist')
  groups = plistlib.readPlist(filename)
  groups2 = {}
  glyphToGroups = {}

  for groupName, glyphNames in groups.iteritems():
    glyphNames2 = []
    for glyphName in glyphNames:
      if glyphName in srcToDstMap:
        gn2 = srcToDstMap[glyphName]
        stats.renamedGlyphs[glyphName] = gn2
        glyphName = gn2
      if glyphName in dstGlyphNames:
        glyphNames2.append(glyphName)
        glyphToGroups[glyphName] = glyphToGroups.get(glyphName, []) + [groupName]
      else:
        stats.removedGlyphs.add(glyphName)
    if len(glyphNames2) > 0:
      groups2[groupName] = glyphNames2
    else:
      stats.removedGroups.add(groupName)

  print('Writing', filename)
  if not dryRun:
    plistlib.writePlist(groups2, filename)

  return groups2, glyphToGroups
项目:chromium-build    作者:discordapp    | 项目源码 | 文件源码
def WriteTo(self, target_path):
    plistlib.writePlist(self._data, target_path)
项目:chromium-build    作者:discordapp    | 项目源码 | 文件源码
def SavePList(path, format, data):
  """Saves |data| as a Plist to |path| in the specified |format|."""
  fd, name = tempfile.mkstemp()
  try:
    with os.fdopen(fd, 'w') as f:
      plistlib.writePlist(data, f)
    subprocess.check_call(['plutil', '-convert', format, '-o', path, name])
  finally:
    os.unlink(name)
项目:build-calibre    作者:kovidgoyal    | 项目源码 | 文件源码
def create_plist(self):
        BOOK_EXTENSIONS = calibre_constants['book_extensions']
        env = dict(**ENV)
        env['CALIBRE_LAUNCHED_FROM_BUNDLE'] = '1'
        docs = [{'CFBundleTypeName': 'E-book',
                 'CFBundleTypeExtensions': list(BOOK_EXTENSIONS),
                 'CFBundleTypeIconFile': 'book.icns',
                 'CFBundleTypeRole': 'Viewer',
                 }]

        pl = dict(
            CFBundleDevelopmentRegion='English',
            CFBundleDisplayName=APPNAME,
            CFBundleName=APPNAME,
            CFBundleIdentifier='net.kovidgoyal.calibre',
            CFBundleVersion=VERSION,
            CFBundleShortVersionString=VERSION,
            CFBundlePackageType='APPL',
            CFBundleSignature='????',
            CFBundleExecutable='calibre',
            CFBundleDocumentTypes=docs,
            LSMinimumSystemVersion='10.9.5',
            LSRequiresNativeExecution=True,
            NSAppleScriptEnabled=False,
            NSHumanReadableCopyright=time.strftime('Copyright %Y, Kovid Goyal'),
            CFBundleGetInfoString=('calibre, an E-book management '
                                   'application. Visit https://calibre-ebook.com for details.'),
            CFBundleIconFile='calibre.icns',
            NSHighResolutionCapable=True,
            LSApplicationCategoryType='public.app-category.productivity',
            LSEnvironment=env
        )
        plistlib.writePlist(pl, join(self.contents_dir, 'Info.plist'))
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_io(self):
        pl = self._create()
        plistlib.writePlist(pl, support.TESTFN)
        pl2 = plistlib.readPlist(support.TESTFN)
        self.assertEqual(dict(pl), dict(pl2))
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_bytesio(self):
        from io import BytesIO
        b = BytesIO()
        pl = self._create()
        plistlib.writePlist(pl, b)
        pl2 = plistlib.readPlist(BytesIO(b.getvalue()))
        self.assertEqual(dict(pl), dict(pl2))
项目:node-ninja    作者:CodeJockey    | 项目源码 | 文件源码
def ExecMergeInfoPlist(self, output, *inputs):
    """Merge multiple .plist files into a single .plist file."""
    merged_plist = {}
    for path in inputs:
      plist = self._LoadPlistMaybeBinary(path)
      self._MergePlist(merged_plist, plist)
    plistlib.writePlist(merged_plist, output)
项目:node-ninja    作者:CodeJockey    | 项目源码 | 文件源码
def _InstallEntitlements(self, entitlements, substitutions, overrides):
    """Generates and install the ${BundleName}.xcent entitlements file.

    Expands variables "$(variable)" pattern in the source entitlements file,
    add extra entitlements defined in the .mobileprovision file and the copy
    the generated plist to "${BundlePath}.xcent".

    Args:
      entitlements: string, optional, path to the Entitlements.plist template
        to use, defaults to "${SDKROOT}/Entitlements.plist"
      substitutions: dictionary, variable substitutions
      overrides: dictionary, values to add to the entitlements

    Returns:
      Path to the generated entitlements file.
    """
    source_path = entitlements
    target_path = os.path.join(
        os.environ['BUILT_PRODUCTS_DIR'],
        os.environ['PRODUCT_NAME'] + '.xcent')
    if not source_path:
      source_path = os.path.join(
          os.environ['SDKROOT'],
          'Entitlements.plist')
    shutil.copy2(source_path, target_path)
    data = self._LoadPlistMaybeBinary(target_path)
    data = self._ExpandVariables(data, substitutions)
    if overrides:
      for key in overrides:
        if key not in data:
          data[key] = overrides[key]
    plistlib.writePlist(data, target_path)
    return target_path
项目:gn_build    作者:realcome    | 项目源码 | 文件源码
def WriteTo(self, target_path):
    plistlib.writePlist(self._data, target_path)
项目:gn_build    作者:realcome    | 项目源码 | 文件源码
def SavePList(path, format, data):
  """Saves |data| as a Plist to |path| in the specified |format|."""
  fd, name = tempfile.mkstemp()
  try:
    with os.fdopen(fd, 'w') as f:
      plistlib.writePlist(data, f)
    subprocess.check_call(['plutil', '-convert', format, '-o', path, name])
  finally:
    os.unlink(name)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_io(self):
        pl = self._create()
        plistlib.writePlist(pl, test_support.TESTFN)
        pl2 = plistlib.readPlist(test_support.TESTFN)
        self.assertEqual(dict(pl), dict(pl2))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_stringio(self):
        from StringIO import StringIO
        f = StringIO()
        pl = self._create()
        plistlib.writePlist(pl, f)
        pl2 = plistlib.readPlist(StringIO(f.getvalue()))
        self.assertEqual(dict(pl), dict(pl2))
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_cstringio(self):
        from cStringIO import StringIO
        f = StringIO()
        pl = self._create()
        plistlib.writePlist(pl, f)
        pl2 = plistlib.readPlist(StringIO(f.getvalue()))
        self.assertEqual(dict(pl), dict(pl2))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_io(self):
        pl = self._create()
        plistlib.writePlist(pl, test_support.TESTFN)
        pl2 = plistlib.readPlist(test_support.TESTFN)
        self.assertEqual(dict(pl), dict(pl2))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_stringio(self):
        from StringIO import StringIO
        f = StringIO()
        pl = self._create()
        plistlib.writePlist(pl, f)
        pl2 = plistlib.readPlist(StringIO(f.getvalue()))
        self.assertEqual(dict(pl), dict(pl2))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_cstringio(self):
        from cStringIO import StringIO
        f = StringIO()
        pl = self._create()
        plistlib.writePlist(pl, f)
        pl2 = plistlib.readPlist(StringIO(f.getvalue()))
        self.assertEqual(dict(pl), dict(pl2))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def writePlist(plist, path):
        plist.write(path)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def makeMpkgPlist(path):

    vers = getFullVersion()
    major, minor = getVersionMajorMinor()

    pl = Plist(
            CFBundleGetInfoString="Python %s"%(vers,),
            CFBundleIdentifier='org.python.Python',
            CFBundleName='Python',
            CFBundleShortVersionString=vers,
            IFMajorVersion=major,
            IFMinorVersion=minor,
            IFPkgFlagComponentDirectory="Contents/Packages",
            IFPkgFlagPackageList=[
                dict(
                    IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
                    IFPkgFlagPackageSelection=item.get('selected', 'selected'),
                )
                for item in pkg_recipes()
            ],
            IFPkgFormatVersion=0.10000000149011612,
            IFPkgFlagBackgroundScaling="proportional",
            IFPkgFlagBackgroundAlignment="left",
            IFPkgFlagAuthorizationAction="RootAuthorization",
        )

    writePlist(pl, path)
项目:timer-workflow    作者:5fth    | 项目源码 | 文件源码
def writePlist(rootObject, pathOrFile, binary=True):
    if not binary:
        rootObject = wrapDataObject(rootObject, binary)
        return plistlib.writePlist(rootObject, pathOrFile)
    else:
        didOpen = False
        if isinstance(pathOrFile, (six.binary_type, six.text_type)):
            pathOrFile = open(pathOrFile, 'wb')
            didOpen = True
        writer = PlistWriter(pathOrFile)
        result = writer.writeRoot(rootObject)
        if didOpen:
            pathOrFile.close()
        return result
项目:LBHue    作者:nriley    | 项目源码 | 文件源码
def update_bundle_info(bundle_path, version, repo):
    info_plist_path = os.path.join(bundle_path, 'Contents', 'Info.plist')
    info_plist = plistlib.readPlist(info_plist_path)
    info_plist['CFBundleVersion'] = version
    info_plist['LBDescription']['LBDownloadURL'] = expand_url_template(
        'https://github.com/%s/releases/download/%s/%s', repo,
        tag_for_version(version), archive_dir_name(bundle_path, version)[1])

    plistlib.writePlist(info_plist, info_plist_path)
项目:WTFJH    作者:Naville    | 项目源码 | 文件源码
def BuildPF():
    CustomPrefList = buildlistdir("./Preferences")
    Plist = plistlib.readPlist('./BasePreferences.plist')
    #Sort Modules
    for key in ModuleDict.keys():
        ModuleDict[key].sort()
    #Start
    SortedKeys=ModuleDict.keys()
    for key in SortedKeys:
        if len(ModuleDict[key])<=0:
            continue
        Dict = {
        "cell": "PSGroupCell",
        "label": key
        }
        Plist["items"].append(Dict)
        for x in ModuleDict[key]:
            CustomPrefPath = x + ".plist"
            if (CustomPrefPath in CustomPrefList):
                custom = plistlib.readPlist('./Preferences/' + CustomPrefPath)
                Plist["items"].append(custom)
            Dict = {
                "cell": "PSSwitchCell",
                "label": x,
                "key": x,
                "default": False,
                "defaults": "naville.wtfjh"
            }
            Plist["items"].append(Dict)


    Dict = {
        "cell": "PSGroupCell",
        "footerText": "https://github.com/Naville/WTFJH"
    }
    Plist["items"].append(Dict)
    plistlib.writePlist(Plist, "./layout/Library/PreferenceLoader/Preferences/WTFJHPreferences.plist")
项目:rules_apple    作者:bazelbuild    | 项目源码 | 文件源码
def _write_plist(self, plist):
    """Writes the given plist to the output file.

    This method also converts it to binary format if "binary" is True in the
    control struct.

    Args:
      plist: The plist to write to the output path in the control struct.
    """
    path_or_file = self._control['output']
    plistlib.writePlist(plist, path_or_file)

    if self._control.get('binary') and isinstance(path_or_file, basestring):
      subprocess.check_call(['plutil', '-convert', 'binary1', path_or_file])
项目:munki-enrollment-server    作者:gerritdewitt    | 项目源码 | 文件源码
def make_computer_manifest(given_serial):
    '''Checks for the presence and validity of an existing manifest for this client in the repository.
        Creates a new manifest if an existing one is not found or is invalid.'''
    # Filesystem path for this computer's manifest:
    computer_manifest_name = given_serial.upper() # if not already
    computer_manifest_path = os.path.join(munki_repo.COMPUTER_MANIFESTS_PATH,computer_manifest_name)
    # Control variable: should a new manifest be created?
    # Assume yes, unless an existing manifest is found and is valid.
    should_create_new_client_manifest = True

    # Catch missing computer manifests directory:
    if not os.path.exists(munki_repo.COMPUTER_MANIFESTS_PATH):
        common.logging_error("Computers manifests directory not found at %s." % munki_repo.COMPUTER_MANIFESTS_PATH)
        raise

    # Check existing manifest for this client:
    if os.path.exists(computer_manifest_path):
        common.logging_info("Manifest for %s already in repository. Checking it." % computer_manifest_name)
        try:
            computer_manifest_dict = plistlib.readPlist(computer_manifest_path)
            # Manifest already exists; do not overwrite if it's a valid dict!
            if computer_manifest_dict:
                should_create_new_client_manifest = False
                common.logging_info("Manifest for %s should be left alone." % computer_manifest_name)
        except xml.parsers.expat.ExpatError:
            common.logging_error("Manifest for %s is invalid. Will recreate." % computer_manifest_name)

    # Build a new client manifest if required:
    if should_create_new_client_manifest:
        common.logging_info("Creating new manifest for %s." % computer_manifest_name)
        computer_manifest_dict = {}
        computer_manifest_dict['managed_installs'] = []
        computer_manifest_dict['managed_uninstalls'] = []
        computer_manifest_dict['catalogs'] = munki_repo.CATALOG_ARRAY
        computer_manifest_dict['included_manifests'] = ['groups/%s' % munki_repo.DEFAULT_GROUP]
        try:
            plistlib.writePlist(computer_manifest_dict,computer_manifest_path)
        except TypeError:
            common.logging_error("Failed to write manifest for %s." % computer_manifest_name)
项目:munki-enrollment-server    作者:gerritdewitt    | 项目源码 | 文件源码
def write_metadata_to_manifest(given_computer_manifest_name,given_metadata_key,given_metadata_value):
    '''Modifes the given computer manifest's _metadata dict, adding (overwriting) the given key and value.
        Given manifest must be present and a valid plist.  Returns true if successful, false otherwise.'''
    # Filesystem paths for the manifest:
    given_computer_manifest_name = given_computer_manifest_name.upper() # if not already
    computer_manifest_path = os.path.join(munki_repo.COMPUTER_MANIFESTS_PATH,given_computer_manifest_name)

    # Catch missing manifest:
    if not os.path.exists(computer_manifest_path):
        common.logging_error("Computer manifest not found at %s." % computer_manifest_path)
        return False

    # Load manifest:
    try:
        computer_manifest_dict = plistlib.readPlist(computer_manifest_path)
    except xml.parsers.expat.ExpatError:
        common.logging_error("Computer manifest %s is invalid." % given_computer_manifest_name)
        return False

    # Load manifest metadata or start with blank:
    try:
        manifest_metadata_dict = computer_manifest_dict['_metadata']
    except KeyError:
        manifest_metadata_dict = {}

    # Modify metadata dict:
    common.logging_info("Adding %(key)s to %(manifest)s." % {'key':given_metadata_key,'manifest':given_computer_manifest_name})
    manifest_metadata_dict[given_metadata_key] = given_metadata_value
    computer_manifest_dict['_metadata'] = manifest_metadata_dict

    # Save manifest:
    try:
        plistlib.writePlist(computer_manifest_dict,computer_manifest_path)
        return True
    except TypeError:
        common.logging_error("Failed to write manifest for %s." % given_computer_manifest_name)
        return False
项目:sublime-bem-create    作者:bem-tools    | 项目源码 | 文件源码
def ExecMergeInfoPlist(self, output, *inputs):
    """Merge multiple .plist files into a single .plist file."""
    merged_plist = {}
    for path in inputs:
      plist = self._LoadPlistMaybeBinary(path)
      self._MergePlist(merged_plist, plist)
    plistlib.writePlist(merged_plist, output)
项目:sublime-bem-create    作者:bem-tools    | 项目源码 | 文件源码
def _InstallEntitlements(self, entitlements, substitutions, overrides):
    """Generates and install the ${BundleName}.xcent entitlements file.

    Expands variables "$(variable)" pattern in the source entitlements file,
    add extra entitlements defined in the .mobileprovision file and the copy
    the generated plist to "${BundlePath}.xcent".

    Args:
      entitlements: string, optional, path to the Entitlements.plist template
        to use, defaults to "${SDKROOT}/Entitlements.plist"
      substitutions: dictionary, variable substitutions
      overrides: dictionary, values to add to the entitlements

    Returns:
      Path to the generated entitlements file.
    """
    source_path = entitlements
    target_path = os.path.join(
        os.environ['BUILT_PRODUCTS_DIR'],
        os.environ['PRODUCT_NAME'] + '.xcent')
    if not source_path:
      source_path = os.path.join(
          os.environ['SDKROOT'],
          'Entitlements.plist')
    shutil.copy2(source_path, target_path)
    data = self._LoadPlistMaybeBinary(target_path)
    data = self._ExpandVariables(data, substitutions)
    if overrides:
      for key in overrides:
        if key not in data:
          data[key] = overrides[key]
    plistlib.writePlist(data, target_path)
    return target_path
项目:PyTexturePacker    作者:wo1fsea    | 项目源码 | 文件源码
def save_plist(data_dict, file_path):
    """
    save a dict as a plist file
    :param data_dict: dict data
    :param file_path: plist file path to save
    :return:
    """
    import plistlib

    if hasattr(plistlib, "dump"):
        with open(file_path, 'wb') as fp:
            plistlib.dump(data_dict, fp)
    else:
        plistlib.writePlist(data_dict, file_path)
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_io(self):
        pl = self._create()
        plistlib.writePlist(pl, support.TESTFN)
        pl2 = plistlib.readPlist(support.TESTFN)
        self.assertEqual(dict(pl), dict(pl2))