當前位置: 首頁>>代碼示例>>Python>>正文


Python plistlib.writePlist方法代碼示例

本文整理匯總了Python中plistlib.writePlist方法的典型用法代碼示例。如果您正苦於以下問題:Python plistlib.writePlist方法的具體用法?Python plistlib.writePlist怎麽用?Python plistlib.writePlist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plistlib的用法示例。


在下文中一共展示了plistlib.writePlist方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: prepworkdir

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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 
開發者ID:bruienne,項目名稱:autonbi,代碼行數:25,代碼來源:AutoNBI.py

示例2: writePlist

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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 
開發者ID:NetEaseGame,項目名稱:iOS-private-api-checker,代碼行數:23,代碼來源:__init__.py

示例3: plist_save

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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
#---------------------------------------------------------------------- 
開發者ID:skywind3000,項目名稱:collection,代碼行數:19,代碼來源:shell.py

示例4: configure

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def configure(self):
        """Prompt user for config and write to plist

        Uses preferences_file argument from JSSPrefs.__init__ as path
        to write.
        """
        prefs = {}
        print ("It seems like you do not have a preferences file configured. "
               "Please answer the following questions to generate a plist at "
               "%s for use with python-jss." % self.preferences_file)

        prefs["jss_url"] = raw_input(
            "The complete URL to your JSS, with port (e.g. "
            "'https://mycasperserver.org:8443')\nURL: ")

        prefs["jss_user"] = raw_input("API Username: ")
        prefs["jss_pass"] = getpass.getpass("API User's Password: ")
        verify_prompt = ("Do you want to verify that traffic is encrypted by "
                         "a certificate that you trust?: (Y|N) ")
        prefs["verify"] = loop_until_valid_response(verify_prompt)
        prefs["repos"] = self._handle_repos(prefs)

        plistlib.writePlist(prefs, self.preferences_file)
        print("Preferences created.\n") 
開發者ID:jssimporter,項目名稱:python-jss,代碼行數:26,代碼來源:jss_prefs.py

示例5: create_plist

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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() 
開發者ID:tensorlang,項目名稱:tensorlang,代碼行數:19,代碼來源:macdist.py

示例6: modplist

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def modplist(self, targetFile, targetKey, newValue):
        '''Modify the value of a particular key in a Mac OS X property list file
        
        @author: Eric Ball

        :param targetFile: Path to the plist to be modified
        :param targetKey: The particular key within the plist to be modified
        :param newValue: The new value for the targetKey within the targetFile

        '''
        try:
            mypl = pl.readPlist(targetFile)
            mypl[targetKey] = newValue
            pl.writePlist(mypl, targetFile)
        except Exception:
            raise 
開發者ID:CSD-Public,項目名稱:stonix,代碼行數:18,代碼來源:buildlib.py

示例7: Save

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def Save(self, path):
    """Save the profile to disk.

    Args:
      path: str, the path to save the profile to.

    Raises:
      ProfileValidationError: profile data was not valid.
      ProfileSaveError: profile could not be saved.
    """
    self._ValidateProfile()
    try:
      plistlib.writePlist(self._profile, path)
    except (IOError, TypeError) as e:
      raise ProfileSaveError('The profile could not be saved: %s' % e) 
開發者ID:google,項目名稱:macops,代碼行數:17,代碼來源:profiles.py

示例8: test_io

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_plistlib.py

示例9: test_stringio

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_plistlib.py

示例10: test_cstringio

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_plistlib.py

示例11: generate_manifest

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def generate_manifest(self, app_name):
		filename = self.info_plist_filename()
		info_plist_filepath = os.path.join(options.app_bundle, filename)
		info_plist_xml_filename = 'info_plist.xml'
		# Use plutil to ensure that we are dealing with XML rather than the binary format
		subprocess.Popen('plutil -convert xml1 -o ' + info_plist_xml_filename + ' ' + "'" + info_plist_filepath + "'", shell=True).wait()
		info_plist_xml_file = open(info_plist_xml_filename, 'r')
		app_plist = plistlib.readPlist(info_plist_xml_file)
		os.remove(info_plist_xml_filename)
		MANIFEST_FILENAME = 'manifest.plist'
		manifest_plist = {
				'items' : [
					{
						'assets' : [
							{
								'kind' : 'software-package',
								'url' : urlparse.urljoin(options.deployment_address, app_name + '.ipa'),
								}
							],
						'metadata' : {
							'bundle-identifier' : app_plist['CFBundleIdentifier'],
							'bundle-version' : app_plist['CFBundleVersion'],
							'kind' : 'software',
							'title' : app_plist['CFBundleName'],
							}
						}
					]
				}
		plistlib.writePlist(manifest_plist, MANIFEST_FILENAME)
		return MANIFEST_FILENAME 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:32,代碼來源:generate-manifest.py

示例12: write

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def write(self, data):
        """
        Serializes specified settings to file
        """
        with self.lock.acquire():
            plistlib.writePlist(data, self.file) 
開發者ID:univ-of-utah-marriott-library-apple,項目名稱:aeios,代碼行數:8,代碼來源:config.py

示例13: ExecMergeInfoPlist

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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) 
開發者ID:refack,項目名稱:GYP3,代碼行數:9,代碼來源:mac_tool.py

示例14: _InstallEntitlements

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
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 
開發者ID:refack,項目名稱:GYP3,代碼行數:35,代碼來源:mac_tool.py

示例15: write_config

# 需要導入模塊: import plistlib [as 別名]
# 或者: from plistlib import writePlist [as 別名]
def write_config(conf, path_or_file):
    """Write a property list config file."""
    plistlib.writePlist(conf, path_or_file) 
開發者ID:kdart,項目名稱:pycopia,代碼行數:5,代碼來源:plistconfig.py


注:本文中的plistlib.writePlist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。