当前位置: 首页>>代码示例>>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;未经允许,请勿转载。