本文整理汇总了Python中pyjavaproperties.Properties.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.getProperty方法的具体用法?Python Properties.getProperty怎么用?Python Properties.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjavaproperties.Properties
的用法示例。
在下文中一共展示了Properties.getProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import getProperty [as 别名]
def parse(settingsdir=None):
if settingsdir == None:
settingsdir = JitsiProperties.path
p = Properties()
p.load(open(os.path.join(settingsdir, JitsiProperties.propertiesfile)))
keydict = dict()
for item in p.items():
propkey = item[0]
name = ""
if re.match("net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc[0-9]+\.ACCOUNT_UID", propkey):
name = JitsiProperties._parse_account_uid(item[1])
if name in keydict:
key = keydict[name]
else:
key = dict()
key["name"] = name
key["protocol"] = "prpl-jabber"
keydict[name] = key
propkey_base = "net.java.sip.communicator.plugin.otr." + re.sub("[^a-zA-Z0-9_]", "_", item[1])
private_key = p.getProperty(propkey_base + "_privateKey").strip()
public_key = p.getProperty(propkey_base + "_publicKey").strip()
numdict = util.ParsePkcs8(private_key)
key["x"] = numdict["x"]
numdict = util.ParseX509(public_key)
for num in ("y", "g", "p", "q"):
key[num] = numdict[num]
key["fingerprint"] = util.fingerprint((key["y"], key["g"], key["p"], key["q"]))
verifiedkey = (
"net.java.sip.communicator.plugin.otr."
+ re.sub("[^a-zA-Z0-9_]", "_", key["name"])
+ "_publicKey_verified"
)
if p.getProperty(verifiedkey).strip() == "true":
key["verification"] = "verified"
elif re.match("net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey_verified", propkey):
name, protocol = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
if name != None:
if name not in keydict:
key = dict()
key["name"] = name
keydict[name] = key
if protocol and "protocol" not in keydict[name]:
keydict[name]["protocol"] = protocol
keydict[name]["verification"] = "verified"
# if the protocol name is included in the property name, its a local account with private key
elif re.match("net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey", propkey) and not re.match(
"net\.java\.sip\.communicator\.plugin\.otr\.(Jabber_|Google_Talk_)", propkey
):
name, ignored = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
if name not in keydict:
key = dict()
key["name"] = name
key["protocol"] = "prpl-jabber"
keydict[name] = key
numdict = util.ParseX509(item[1])
for num in ("y", "g", "p", "q"):
key[num] = numdict[num]
key["fingerprint"] = util.fingerprint((key["y"], key["g"], key["p"], key["q"]))
return keydict
示例2: parse
# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import getProperty [as 别名]
def parse(settingsdir=None):
if settingsdir == None:
settingsdir = JitsiProperties.path
p = Properties()
p.load(open(os.path.join(settingsdir, JitsiProperties.propertiesfile)))
keydict = dict()
for item in p.items():
propkey = item[0]
name = ''
if re.match('net\.java\.sip\.communicator\.impl\.protocol\.jabber\.acc[0-9]+\.ACCOUNT_UID', propkey):
name = JitsiProperties._parse_account_uid(item[1])
if name in keydict:
key = keydict[name]
else:
key = dict()
key['name'] = name
key['protocol'] = 'prpl-jabber'
keydict[name] = key
propkey_base = ('net.java.sip.communicator.plugin.otr.'
+ re.sub('[^a-zA-Z0-9_]', '_', item[1]))
private_key = p.getProperty(propkey_base + '_privateKey').strip()
public_key = p.getProperty(propkey_base + '_publicKey').strip()
numdict = util.ParsePkcs8(private_key)
key['x'] = numdict['x']
numdict = util.ParseX509(public_key)
for num in ('y', 'g', 'p', 'q'):
key[num] = numdict[num]
key['fingerprint'] = util.fingerprint((key['y'], key['g'], key['p'], key['q']))
verifiedkey = ('net.java.sip.communicator.plugin.otr.'
+ re.sub('[^a-zA-Z0-9_]', '_', key['name'])
+ '_publicKey_verified')
if p.getProperty(verifiedkey).strip() == 'true':
key['verification'] = 'verified'
elif (re.match('net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey_verified', propkey)):
name, protocol = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
if name != None:
if name not in keydict:
key = dict()
key['name'] = name
keydict[name] = key
if protocol and 'protocol' not in keydict[name]:
keydict[name]['protocol'] = protocol
keydict[name]['verification'] = 'verified'
# if the protocol name is included in the property name, its a local account with private key
elif (re.match('net\.java\.sip\.communicator\.plugin\.otr\..*_publicKey', propkey) and not
re.match('net\.java\.sip\.communicator\.plugin\.otr\.(Jabber_|Google_Talk_)', propkey)):
name, ignored = JitsiProperties._parse_account_from_propkey(settingsdir, propkey)
if name not in keydict:
key = dict()
key['name'] = name
key['protocol'] = 'prpl-jabber'
keydict[name] = key
numdict = util.ParseX509(item[1])
for num in ('y', 'g', 'p', 'q'):
key[num] = numdict[num]
key['fingerprint'] = util.fingerprint((key['y'], key['g'], key['p'], key['q']))
return keydict
示例3: main
# 需要导入模块: from pyjavaproperties import Properties [as 别名]
# 或者: from pyjavaproperties.Properties import getProperty [as 别名]
def main():
properties = Properties()
properties.load(open("/home/khepry/home/distributions/PyDataGenerator/PyDataGenerator.properties"))
properties.list()
maxRows = 100
maxXlsRows = 10000
globalPath = '/home/khepry/home/distributions/PyDataGenerator/temp/'
targetName = 'dataGenerator.csv'
maxRows = int(properties.getProperty('maxRows', maxRows))
maxXlsRows = int(properties.getProperty('maxXlsRows', maxXlsRows))
globalPath = properties.getProperty('globalPath', globalPath)
targetName = properties.getProperty('targetName', targetName)
print("-- operating system --")
print(platform.system())
print("-- processing messages --")
if platform.system() == 'Windows':
xlsPgmPath = '"/Program Files/Microsoft Office 15/root/office15/EXCEL.EXE"'
txtPgmPath = '"/Program Files (x86)/Notepad++/notepad++.exe"'
else:
xlsPgmPath = "libreoffice"
txtPgmPath = "gedit"
tgtFileFullPath = os.path.abspath(globalPath + targetName)
tgtFile = open(tgtFileFullPath, 'w', newline='')
bgnTime = tyme.time()
rows = 0
try:
writer = csv.writer(tgtFile, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for i in range(0, maxRows):
rows += 1
record = Record()
record.addField("UUID4", "UUID4").random()
record.addField("Alpha", "Alpha").random(20, 25)
record.addField("AlphaNumeric", "AlphaNumeric").random()
record.addField("Numeric", "Numeric").random()
record.addField("String", "String").random()
record.addField("Range", "Range").random(12, 24)
record.addField("Date", "Date").random(date(1980,1,1), date(2000,12,31))
record.addField("DateTime", "DateTime").random(date(1980,1,1), date(2000,12,31))
record.addField("AgeInYears","Numeric").years(date.today(), record.getField("Date").value)
record.addField("AgeInMonths","Numeric").months(date.today(), record.getField("Date").value)
record.addField("AgeInDays","Numeric").days(date.today(), record.getField("Date").value)
if (i == 0):
writer.writerow([key for key in record.fields.keys()])
writer.writerow([field.text for field in record.fields.values()])
finally:
tgtFile.close()
endTime = tyme.time()
elapsedTime = endTime - bgnTime
print("{:,}".format(rows) + ' records processed in ' + "{:,.4f}".format(elapsedTime) + ' seconds at ' + "{:,.4f}".format(rows / elapsedTime) + ' rows/second.')
if (platform.system() == 'Windows'):
if (rows < maxXlsRows):
subprocess.call(xlsPgmPath + ' "' + tgtFileFullPath + '"')
else:
subprocess.call(txtPgmPath + ' "' + tgtFileFullPath + '"')
else:
if (rows < maxXlsRows):
subprocess.call([xlsPgmPath, tgtFileFullPath])
else:
subprocess.call([txtPgmPath, tgtFileFullPath])