本文整理汇总了Python中java.util.Properties.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Properties.remove方法的具体用法?Python Properties.remove怎么用?Python Properties.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Properties
的用法示例。
在下文中一共展示了Properties.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addPropertiesFromFile
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import remove [as 别名]
def addPropertiesFromFile(props, filename, site_home):
addProps = Properties()
input = FileInputStream(filename)
addProps.load(input)
input.close()
baseFileList = addProps.getProperty('base')
if not baseFileList is None:
baseFiles = baseFileList.split(",")
for baseFile in baseFiles:
baseFileResolved=getBaseFile(baseFile, site_home)
if baseFileResolved=='':
log.error('Configuration inherits from properties file that does not exist: ' + baseFile)
log.info('Suggested Fix: Update the base property within ' + filename + ' to the correct file path')
sys.exit()
log.debug('Attempting to load properties from ' + baseFile)
addPropertiesFromFile(addProps, baseFileResolved, site_home)
addProps.remove('base')
enum = addProps.keys()
while enum.hasMoreElements():
key = enum.nextElement()
if props.getProperty(key) is None:
props.setProperty(key, addProps.getProperty(key))
addDataLinage(key,filename,addProps.getProperty(key))
示例2: loadProperties
# 需要导入模块: from java.util import Properties [as 别名]
# 或者: from java.util.Properties import remove [as 别名]
def loadProperties(cfg_file, extra_props):
props = Properties()
iterated_props = Properties()
inherited_props = Properties()
data_linage = Properties()
redback_reg = redback.load_redback_registry()
site_home = redback_reg.getProperty('site.home')
global_properties = redback_reg.getProperty('global.properties')
if global_properties:
if site_home:
baseFile=getBaseFile(global_properties, site_home)
if baseFile=='':
log.error('Global properties file does not exist: ' + global_properties)
log.info('Suggested Fix: Update the global.properties property within redback.properties to the correct file path')
sys.exit()
global_properties=baseFile
log.info('Loading global configuration from file: ' + global_properties)
addPropertiesFromFile(props, global_properties, site_home)
if cfg_file:
addPropertiesFromFile(props, cfg_file, site_home)
if extra_props:
props.putAll(extra_props)
# resolve property level inheritance and iterations
log.debug('Attempting to resolve property level inheritance')
enum = props.keys()
while enum.hasMoreElements():
key = enum.nextElement()
value = props.getProperty(key)
# Check for property level inheritance
if re.search(r"\.base$", key) is not None:
prop_to_inherit = value
prop_to_extend = key[:-5]
log.debug('Inheriting the properties from the ' + prop_to_inherit + ' section in to the section ' + prop_to_extend)
# Iterate the properties again looking for a match on properties to inherit
enum_inner = props.keys()
while enum_inner.hasMoreElements():
key_inner = enum_inner.nextElement()
value_inner = props.getProperty(key_inner)
log.debug('Checking key_inner [' + key_inner + '] matches ' + prop_to_inherit)
if String.startsWith(String(key_inner),String(prop_to_inherit)):
new_property = prop_to_extend + String.substring(key_inner, len(prop_to_inherit))
# Don't override the property if it has already been defined earlier
if props.getProperty(new_property) is None:
log.debug('Setting inherited property ' + new_property + ' to value ' + value_inner)
inherited_props.setProperty(new_property, value_inner)
addDataLinage(key,cfg_file,value_inner)
# Remove the key that defines the base, just keeps us consistant with the template behaviours
log.debug("About to remove key " + key)
props.remove(key)
props.putAll(inherited_props)
log.debug('Attempting to resolve iterations')
enum = props.keys()
while enum.hasMoreElements():
key = enum.nextElement()
value = props.getProperty(key)
# Check for property set iterations
if re.search(r"\.iterate$", key) is not None:
iteration_key = key
iteration_set = eval(value)
prop_to_iterate = key[:-9]
log.debug('Iterating the properties from the ' + prop_to_iterate + ' section')
# Iterate the properties again looking for a match on properties to iterate
enum_inner = props.keys()
while enum_inner.hasMoreElements():
key_inner = enum_inner.nextElement()
value_inner = props.getProperty(key_inner)
# if the string is part of the set but not the actual iterator then we will check it
if String.startsWith(String(key_inner),String(prop_to_iterate)) and key_inner != iteration_key:
log.debug('Checking if the key [' + key_inner + '] or value = ' + value_inner + ' contains an iterator ')
contains_iterator = 0
iterated_key = String(key_inner)
iterated_value = String(value_inner)
if String.indexOf(String(key_inner),"%") > -1:
log.debug(key_inner + ' contains an iterator, replacing it')
contains_iterator = 1
if String.indexOf(String(value_inner),"%") > -1:
log.debug(value_inner + ' contains an iterator, replacing it')
contains_iterator = 1
for i in iteration_set:
iterated_key = String.replaceAll(String(key_inner),"\%",str(i))
iterated_value = String.replaceAll(String(value_inner),"\%",str(i))
# Don't override the property if it has already been defined earlier
if props.getProperty(iterated_key) is None:
log.debug('Setting iterated property ' + iterated_key + ' to value ' + iterated_value)
iterated_props.setProperty(iterated_key, iterated_value)
addDataLinage(key,cfg_file,iterated_value)
# Remove the key that gets iterated, just keeps us consistant with the template behaviours
#.........这里部分代码省略.........