Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getselect(file, key, defaults, default_value, encoding, escaped):
if escaped:
key = list(map(unescape, key))
if default_value is not None:
default_value = unescape(default_value)
with click.open_file(file, encoding=encoding) as fp:
props = getproperties(fp, key)
if defaults is not None:
with click.open_file(defaults, encoding=encoding) as fp:
defaults = getproperties(fp, key)
else:
defaults = {}
for k in key:
v = default_value
if k in props:
v = props[k]
elif k in defaults:
v = defaults[k]
yield (k,v)
def setprop(escaped, separator, outfile, preserve_timestamp, file, key, value,
encoding):
""" Set values in a Java .properties file """
if escaped:
key = unescape(key)
value = unescape(value)
with click.open_file(file, encoding=encoding) as fpin:
with click.open_file(outfile, 'w', encoding=encoding) as fpout:
setproperties(fpin, fpout, {key: value}, preserve_timestamp,
separator)
def setprop(escaped, separator, outfile, preserve_timestamp, file, key, value,
encoding):
""" Set values in a Java .properties file """
if escaped:
key = unescape(key)
value = unescape(value)
with click.open_file(file, encoding=encoding) as fpin:
with click.open_file(outfile, 'w', encoding=encoding) as fpout:
setproperties(fpin, fpout, {key: value}, preserve_timestamp,
separator)