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


Python Properties.setProperty方法代碼示例

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


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

示例1: write

# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import setProperty [as 別名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key:
                suffix2 = ''
                if '@' in key['name']:
                    suffix = re.sub('[^a-zA-Z0-9_]', '_', key['name'].split('@')[1])
                    if 'facebook' in key['name'].split('@')[1]:
                        protocolAcc = 'Facebook_'
                    elif 'gmail' in key['name'].split('@')[1]:
                        protocolAcc = 'Google_Talk_'
                        suffix2 = 'talk_google_com'
                    else:
                        protocolAcc = 'Jabber_'
                elif '@' not in key['name']:
                    if 'icq' in key['protocol']:
                        protocolAcc = 'ICQ_'
                        suffix = 'icq_com'
                    elif 'yahoo' in key['protocol']:
                        protocolAcc = 'Yahoo__'
                        suffix = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_' + suffix + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                           + '_' + suffix + '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
		   
                if suffix2 != '':
                    pubkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                              + '_' + suffix2 + '_publicKey')
                    p.setProperty(pubkey, util.ExportDsaX509(key))
                    privkey = (propkey_base + protocolAcc + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_' + suffix2 + '_privateKey')
                    p.setProperty(privkey, util.ExportDsaPkcs8(key))	
		   		
        p.store(open(savefile, 'w'))
開發者ID:gitter-badger,項目名稱:keysync,代碼行數:60,代碼來源:jitsi.py

示例2: write

# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import setProperty [as 別名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print 'Adium WARNING: "' + loadfile + '" does not exist! Reading from:'
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print '\t"' + loadfile + '"'

        propkey_base = "net.java.sip.communicator.plugin.otr."
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.iteritems():
            if "verification" in key and key["verification"] != "":
                verifiedkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey_verified"
                p[verifiedkey] = "true"
            if "y" in key:
                pubkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey"
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if "x" in key and "@" in key["name"]:
                pubkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_publicKey"
                )
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (
                    propkey_base
                    + "Jabber_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"].split("@")[1])
                    + "_privateKey"
                )
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
        p.store(open(savefile, "w"))
開發者ID:rostendorf,項目名稱:otrfileconverter,代碼行數:43,代碼來源:jitsi.py

示例3: write

# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import setProperty [as 別名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print('Jitsi NOTICE: "' + loadfile + '" does not exist! Reading from:')
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print('\t"' + loadfile + '"')

        propkey_base = 'net.java.sip.communicator.plugin.otr.'
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.items():
            if 'verification' in key and key['verification'] != '':
                verifiedkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_publicKey_verified')
                p[verifiedkey] = 'true'
            if 'y' in key:
                pubkey = (propkey_base + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
            if 'x' in key:
                protocol_id = 'UNKNOWN_'
                domain_id = 'unknown'
                servername = None
                if '@' in key['name']:
                    domainname = key['name'].split('@')[1]
                    domain_id = re.sub('[^a-zA-Z0-9_]', '_', domainname)
                    if domainname == 'chat.facebook.com':
                        protocol_id = 'Facebook_'
                    elif domainname == 'gmail.com' \
                            or domainname == 'google.com' \
                            or domainname == 'googlemail.com':
                        protocol_id = 'Google_Talk_'
                        servername = 'talk_google_com'
                    else:
                        protocol_id = 'Jabber_'
                else:
                    if key['protocol'] == 'prpl-icq':
                        protocol_id = 'ICQ_'
                        domain_id = 'icq_com'
                    elif key['protocol'] == 'prpl-yahoo':
                        protocol_id = 'Yahoo__'
                        domain_id = 'yahoo_com'
                # Writing
                pubkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                          + '_' + domain_id + '_publicKey')
                p.setProperty(pubkey, util.ExportDsaX509(key))
                privkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                           + '_' + domain_id + '_privateKey')
                p.setProperty(privkey, util.ExportDsaPkcs8(key))
		   
                if servername:
                    pubkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                              + '_' + servername + '_publicKey')
                    p.setProperty(pubkey, util.ExportDsaX509(key))
                    privkey = (propkey_base + protocol_id + re.sub('[^a-zA-Z0-9_]', '_', key['name'])
                               + '_' + servername + '_privateKey')
                    p.setProperty(privkey, util.ExportDsaPkcs8(key))	
		   		
        p.store(open(savefile, 'w'))
開發者ID:the-solipsist,項目名稱:keysync,代碼行數:65,代碼來源:jitsi.py

示例4: _testParsePropertiesOutput

# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import setProperty [as 別名]
 def _testParsePropertiesOutput(self, stream):
   properties = Properties()
   properties.setProperty('Key00', 'Value00')
   properties.setProperty('Key01', 'Value01')
   properties.setProperty('Key02', 'Value02')
   properties.setProperty('Key03', 'Value03')
   properties.setProperty('Key04', 'Value04')
   properties.setProperty('Key05', 'Value05a, Value05b, Value05c')
   properties.setProperty('Key06', 'Value06a, Value06b, Value06c',)
   properties.setProperty('Key07', 'Value07b')
   properties.setProperty('Key08',
       'Value08a, Value08b, Value08c, Value08d, Value08e, Value08f')
   properties.setProperty('Key09',
       'Value09a, Value09b, Value09c, Value09d, Value09e, Value09f')
   properties.setProperty('Key10', 'Value10')
   properties.setProperty('Key11', '')
   properties.setProperty('Key12', 'Value12a, Value12b, Value12c')
   properties.setProperty('Key13', 'Value13 With Spaces')
   properties.setProperty('Key14', 'Value14 With Spaces')
   properties.setProperty('Key15', 'Value15 With Spaces')
   properties.setProperty('Key16 With Spaces', 'Value16')
   properties.setProperty('Key17 With Spaces', 'Value17')
   properties.setProperty('Key18', 'Value18 # Not a comment.')
   properties.setProperty('Key19', 'Value19 ! Not a comment.')
   properties.setProperty('Key20=WithEquals', 'Value20')
   properties.setProperty('Key21:WithColon', 'Value21')
   properties.setProperty('Key22', 'Value22')
   properties.store(stream)
開發者ID:Finntack,項目名稱:pyjavaproperties,代碼行數:30,代碼來源:pyjavaproperties_test.py

示例5: write

# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import setProperty [as 別名]
    def write(keydict, savedir):
        if not os.path.exists(savedir):
            raise Exception('"' + savedir + '" does not exist!')

        loadfile = os.path.join(savedir, JitsiProperties.propertiesfile)
        savefile = loadfile
        if not os.path.exists(loadfile) and os.path.exists(JitsiProperties.path):
            print('Jitsi NOTICE: "' + loadfile + '" does not exist! Reading from:')
            loadfile = os.path.join(JitsiProperties.path, JitsiProperties.propertiesfile)
            print('\t"' + loadfile + '"')

        propkey_base = "net.java.sip.communicator.plugin.otr."
        p = Properties()
        p.load(open(loadfile))
        for name, key in keydict.items():
            if "verification" in key and key["verification"] != "":
                verifiedkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey_verified"
                p[verifiedkey] = "true"
            if "y" in key:
                pubkey = propkey_base + re.sub("[^a-zA-Z0-9_]", "_", key["name"]) + "_publicKey"
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
            if "x" in key:
                protocol_id = "UNKNOWN_"
                domain_id = "unknown"
                servername = None
                if "@" in key["name"]:
                    domainname = key["name"].split("@")[1]
                    domain_id = re.sub("[^a-zA-Z0-9_]", "_", domainname)
                    if domainname == "chat.facebook.com":
                        protocol_id = "Facebook_"
                    elif domainname == "gmail.com" or domainname == "google.com" or domainname == "googlemail.com":
                        protocol_id = "Google_Talk_"
                        servername = "talk_google_com"
                    else:
                        protocol_id = "Jabber_"
                else:
                    if key["protocol"] == "prpl-icq":
                        protocol_id = "ICQ_"
                        domain_id = "icq_com"
                    elif key["protocol"] == "prpl-yahoo":
                        protocol_id = "Yahoo__"
                        domain_id = "yahoo_com"
                # Writing
                pubkey = (
                    propkey_base
                    + protocol_id
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + domain_id
                    + "_publicKey"
                )
                p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                privkey = (
                    propkey_base
                    + protocol_id
                    + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                    + "_"
                    + domain_id
                    + "_privateKey"
                )
                p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

                if servername:
                    pubkey = (
                        propkey_base
                        + protocol_id
                        + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                        + "_"
                        + servername
                        + "_publicKey"
                    )
                    p.setProperty(pubkey, otrapps.util.ExportDsaX509(key))
                    privkey = (
                        propkey_base
                        + protocol_id
                        + re.sub("[^a-zA-Z0-9_]", "_", key["name"])
                        + "_"
                        + servername
                        + "_privateKey"
                    )
                    p.setProperty(privkey, otrapps.util.ExportDsaPkcs8(key))

        p.store(open(savefile, "w"))
開發者ID:abeluck,項目名稱:keysync,代碼行數:85,代碼來源:jitsi.py


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