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


Python plistlib.Data方法代码示例

本文整理汇总了Python中plistlib.Data方法的典型用法代码示例。如果您正苦于以下问题:Python plistlib.Data方法的具体用法?Python plistlib.Data怎么用?Python plistlib.Data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在plistlib的用法示例。


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

示例1: AddAnchorCertificate

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def AddAnchorCertificate(self, certificate):
    """Adds a certificate payload to the profile for server identification.

    Args:
      certificate: str, PEM-formatted certificate.

    Raises:
      CertificateError: there was an error processing the certificate
    """
    try:
      cert = certs.Certificate(certificate)
    except certs.CertError as e:
      raise CertificateError(e)

    payload = {PAYLOADKEYS_IDENTIFIER: self._GenerateID(cert.osx_fingerprint),
               PAYLOADKEYS_TYPE: 'com.apple.security.pkcs1',
               PAYLOADKEYS_DISPLAYNAME: cert.subject_cn,
               PAYLOADKEYS_CONTENT: plistlib.Data(certificate)}

    # Validate payload to generate its UUID
    ValidatePayload(payload)
    self._anchor_certs.append(payload.get(PAYLOADKEYS_UUID))
    self.AddPayload(payload) 
开发者ID:google,项目名称:macops,代码行数:25,代码来源:profiles.py

示例2: _create

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def _create(self):
        pl = dict(
            aString="Doodah",
            aList=["A", "B", 12, 32.5, [1, 2, 3]],
            aFloat = 0.5,
            anInt = 728,
            aDict=dict(
                anotherString="<hello & 'hi' there!>",
                aUnicodeValue=u'M\xe4ssig, Ma\xdf',
                aTrueValue=True,
                aFalseValue=False,
                deeperDict=dict(a=17, b=32.5, c=[1, 2, "text"]),
            ),
            someData = plistlib.Data("<binary gunk>"),
            someMoreData = plistlib.Data("<lots of binary gunk>\0\1\2\3" * 10),
            nestedData = [plistlib.Data("<lots of binary gunk>\0\1\2\3" * 10)],
            aDate = datetime.datetime(2004, 10, 26, 10, 33, 33),
        )
        pl[u'\xc5benraa'] = "That was a unicode key."
        return pl 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_plistlib.py

示例3: wrapDataObject

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def wrapDataObject(o, for_binary=False):
    if isinstance(o, Data) and not for_binary:
        v = sys.version_info
        if not (v[0] >= 3 and v[1] >= 4):
            o = plistlib.Data(o)
    elif isinstance(o, (bytes, plistlib.Data)) and for_binary:
        if hasattr(o, 'data'):
            o = Data(o.data)
    elif isinstance(o, tuple):
        o = wrapDataObject(list(o), for_binary)
        o = tuple(o)
    elif isinstance(o, list):
        for i in range(len(o)):
            o[i] = wrapDataObject(o[i], for_binary)
    elif isinstance(o, dict):
        for k in o:
            o[k] = wrapDataObject(o[k], for_binary)
    return o 
开发者ID:NetEaseGame,项目名称:iOS-private-api-checker,代码行数:20,代码来源:__init__.py

示例4: test_dataobject_deprecated

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def test_dataobject_deprecated(self):
        in_data = { 'key': plistlib.Data(b'hello') }
        out_data = { 'key': b'hello' }

        buf = plistlib.dumps(in_data)

        cur = plistlib.loads(buf)
        self.assertEqual(cur, out_data)
        self.assertNotEqual(cur, in_data)

        cur = plistlib.loads(buf, use_builtin_types=False)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data)

        with self.assertWarns(DeprecationWarning):
            cur = plistlib.readPlistFromBytes(buf)
        self.assertNotEqual(cur, out_data)
        self.assertEqual(cur, in_data) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_plistlib.py

示例5: get_type

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def get_type(self, value):
        if isinstance(value, dict):
            return self.menu_code + " Dictionary"
        elif isinstance(value, list):
            return self.menu_code + " Array"
        elif isinstance(value, datetime.datetime):
            return self.menu_code + " Date"
        elif self.is_data(value):
            return self.menu_code + " Data"
        elif isinstance(value, bool):
            return self.menu_code + " Boolean"
        elif isinstance(value, (int,float,long)):
            return self.menu_code + " Number"
        elif isinstance(value, (str,unicode)):
            return self.menu_code + " String"
        else:
            return self.menu_code + str(type(value)) 
开发者ID:corpnewt,项目名称:ProperTree,代码行数:19,代码来源:plistwindow.py

示例6: get_data

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def get_data(self, value):
        if sys.version_info < (3,0) and isinstance(value, plistlib.Data):
            value = value.data
        if not len(value):
            return "<>" if self.data_display == "hex" else ""
        if self.data_display == "hex":
            h = binascii.hexlify(value)
            if sys.version_info >= (3,0):
                h = h.decode("utf-8")
            return "<{}>".format(" ".join((h[0+i:8+i] for i in range(0, len(h), 8))).upper())
        else:
            h = base64.b64encode(value)
            if sys.version_info >= (3,0):
                h = h.decode("utf-8")
            return h

    ###                   ###
    # Node Update Functions #
    ###                   ### 
开发者ID:corpnewt,项目名称:ProperTree,代码行数:21,代码来源:plistwindow.py

示例7: test_dataobject_deprecated

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def test_dataobject_deprecated(self):
        in_data = { 'key': plistlib.Data(b'hello') }
        out_data = { 'key': b'hello' }

        buf = plistlib.dumps(in_data)

        cur = plistlib.loads(buf)
        self.assertEqual(cur, out_data)
        self.assertEqual(cur, in_data)

        cur = plistlib.loads(buf, use_builtin_types=False)
        self.assertEqual(cur, out_data)
        self.assertEqual(cur, in_data)

        with self.assertWarns(DeprecationWarning):
            cur = plistlib.readPlistFromBytes(buf)
        self.assertEqual(cur, out_data)
        self.assertEqual(cur, in_data) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:20,代码来源:test_plistlib.py

示例8: RemoveProfile

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def RemoveProfile(self, ident):
        profiles = self.GetProfileList()
        if not profiles:
            return
        if not profiles["ProfileMetadata"].has_key(ident):
            self.logger.info("Trying to remove not installed profile %s", ident)
            return
        meta = profiles["ProfileMetadata"][ident]
        pprint(meta)
        data = plistlib.writePlistToString({"PayloadType": "Configuration",
             "PayloadIdentifier": ident,
             "PayloadUUID": meta["PayloadUUID"],
             "PayloadVersion": meta["PayloadVersion"]
         })
        self.service.sendPlist({"RequestType":"RemoveProfile", "ProfileIdentifier": plistlib.Data(data)})
        return self.service.recvPlist() 
开发者ID:iOSForensics,项目名称:pymobiledevice,代码行数:18,代码来源:mobile_config.py

示例9: _sanitize_args_single_value

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def _sanitize_args_single_value(value, arg=None):
        """Makes a single value easier to read."""
        if isinstance(value, plistlib.Data):
            try: # Does it seem to be ASCII ?
                return value.data.encode('ascii')
            except UnicodeDecodeError: # No => base64 encode it
                return value.asBase64(maxlinelength=1000000).strip()
        elif isinstance(value, datetime.datetime):
            # Keychain items can contain a date. We just store a string representation of it
            return str(value)
        else:
            # Try to replace this value with a more meaningful string
            if arg in IOS_ENUM_LIST:
                try:
                    if 'mask' in IOS_ENUM_LIST[arg]:
                        has_flag = value & IOS_ENUM_LIST[arg]['mask']
                        if has_flag:
                            return IOS_ENUM_LIST[arg][value]
                    else:
                        return IOS_ENUM_LIST[arg][value]
                except KeyError:
                    return value
            else:
                return value 
开发者ID:Naville,项目名称:WTFJH,代码行数:26,代码来源:DBParser.py

示例10: AddMachineCertificate

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def AddMachineCertificate(self, certificate, private_key):
    """Adds a machine certificate payload to the profile.

    Args:
      certificate: str, PEM-formatted certificate.
      private_key: str, PEM-formatted private key.

    Raises:
      CertificateError: there was an error processing the certificate/key
    """
    try:
      cert = certs.Certificate(certificate)

      pkcs12 = crypto.PKCS12Type()
      pkcs12.set_certificate(crypto.load_certificate(
          crypto.FILETYPE_PEM, certificate))
      pkcs12.set_privatekey(crypto.load_privatekey(
          crypto.FILETYPE_PEM, private_key))
    except (certs.CertError, crypto.Error) as e:
      raise CertificateError(e)

    payload = {PAYLOADKEYS_IDENTIFIER: self._GenerateID('machine_cert'),
               PAYLOADKEYS_TYPE: 'com.apple.security.pkcs12',
               PAYLOADKEYS_DISPLAYNAME: cert.subject_cn,
               'Password': cert.osx_fingerprint}

    try:
      payload[PAYLOADKEYS_CONTENT] = plistlib.Data(
          pkcs12.export(cert.osx_fingerprint))
    except crypto.Error as e:
      raise CertificateError(e)

    # Validate payload to generate its UUID
    ValidatePayload(payload)
    self._auth_cert = payload.get(PAYLOADKEYS_UUID)
    self.AddPayload(payload) 
开发者ID:google,项目名称:macops,代码行数:38,代码来源:profiles.py

示例11: test_indentation_array

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def test_indentation_array(self):
        data = [[[[[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]]]]
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_plistlib.py

示例12: test_indentation_dict

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def test_indentation_dict(self):
        data = {'1': {'2': {'3': {'4': {'5': {'6': {'7': {'8': {'9': plistlib.Data(b'aaaaaa')}}}}}}}}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_plistlib.py

示例13: test_indentation_dict_mix

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def test_indentation_dict_mix(self):
        data = {'1': {'2': [{'3': [[[[[{'test': plistlib.Data(b'aaaaaa')}]]]]]}]}}
        self.assertEqual(plistlib.readPlistFromString(plistlib.writePlistToString(data)), data) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_plistlib.py

示例14: _getrefnum

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def _getrefnum(self, value):
        if isinstance(value, _scalars):
            return self._objtable[(type(value), value)]
        elif isinstance(value, plistlib.Data):
            return self._objtable[(type(value.data), value.data)]
        else:
            return self._objidtable[id(value)] 
开发者ID:corpnewt,项目名称:USBMap,代码行数:9,代码来源:plist.py

示例15: setUp

# 需要导入模块: import plistlib [as 别名]
# 或者: from plistlib import Data [as 别名]
def setUp(self):
        self.path = os.path.join(TMPDIR, 'delete')
        self.config = config.Manager(id='test', path=self.path)
        template = {'string':'string', 'list':[], 'dict':{}, 
                    'integer': 1, 'boolean': True, 
                    'date': dt.datetime.now(), 'float': 0.5,
                    'data': plistlib.Data('data')}
        self.config.write(template) 
开发者ID:univ-of-utah-marriott-library-apple,项目名称:aeios,代码行数:10,代码来源:test_config.py


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