本文整理汇总了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'))