本文整理匯總了Python中pyjavaproperties.Properties.iteritems方法的典型用法代碼示例。如果您正苦於以下問題:Python Properties.iteritems方法的具體用法?Python Properties.iteritems怎麽用?Python Properties.iteritems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyjavaproperties.Properties
的用法示例。
在下文中一共展示了Properties.iteritems方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: len
# 需要導入模塊: from pyjavaproperties import Properties [as 別名]
# 或者: from pyjavaproperties.Properties import iteritems [as 別名]
import sys
import os
if __name__ == '__main__':
if len(sys.argv) != 3:
print "Usage: python prop_util.py <path to runtime.properties> <mydomain replacement>"
sys.exit(1)
runtime_filepath = sys.argv[1]
print "Updating %s" % runtime_filepath
p = Properties()
p.load(open(runtime_filepath))
print "****Properties before****"
p.list()
#Add/replace environment variables that begin with v_
for key, value in [(key[2:], os.environ[key]) for key in os.environ if key.startswith("v_")]:
print "Adding key %s: %s" % (key, value)
p[key] = value
#Replace mydomain in any values
newdomain = sys.argv[2]
for key, value in [(key, value) for (key, value) in p.iteritems() if "mydomain.edu" in value]:
new_value = value.replace("mydomain.edu", newdomain)
print "Changing key %s from %s to %s" % (key, value, new_value)
p[key] = new_value
#Set DB values based on docker-provided environment variables
p['VitroConnection.DataSource.url'] = "http://db:8111/v1/graphs/sparql"
p['VitroConnection.DataSource.username'] = 'admin'
p['VitroConnection.DataSource.password'] = 'admin'
print "****Properties after****"
p.list()
p.store(open(runtime_filepath,'w'))