text
stringlengths
0
828
else:
query[k] = [u, v]
return query"
1696,"def value2url_param(value):
""""""
:param value:
:return: ascii URL
""""""
if value == None:
Log.error(""Can not encode None into a URL"")
if is_data(value):
value_ = wrap(value)
output = ""&"".join([
value2url_param(k) + ""="" + (value2url_param(v) if is_text(v) else value2url_param(value2json(v)))
for k, v in value_.leaves()
])
elif is_text(value):
output = """".join(_map2url[c] for c in value.encode('utf8'))
elif is_binary(value):
output = """".join(_map2url[c] for c in value)
elif hasattr(value, ""__iter__""):
output = "","".join(value2url_param(v) for v in value)
else:
output = str(value)
return output"
1697,"def configfile_from_path(path, strict=True):
""""""Get a ConfigFile object based on a file path.
This method will inspect the file extension and return the appropriate
ConfigFile subclass initialized with the given path.
Args:
path (str): The file path which represents the configuration file.
strict (bool): Whether or not to parse the file in strict mode.
Returns:
confpy.loaders.base.ConfigurationFile: The subclass which is
specialized for the given file path.
Raises:
UnrecognizedFileExtension: If there is no loader for the path.
""""""
extension = path.split('.')[-1]
conf_type = FILE_TYPES.get(extension)
if not conf_type:
raise exc.UnrecognizedFileExtension(
""Cannot parse file of type {0}. Choices are {1}."".format(
extension,
FILE_TYPES.keys(),
)
)
return conf_type(path=path, strict=strict)"
1698,"def configuration_from_paths(paths, strict=True):
""""""Get a Configuration object based on multiple file paths.
Args:
paths (iter of str): An iterable of file paths which identify config
files on the system.
strict (bool): Whether or not to parse the files in strict mode.
Returns:
confpy.core.config.Configuration: The loaded configuration object.
Raises:
NamespaceNotRegistered: If a file contains a namespace which is not
defined.
OptionNotRegistered: If a file contains an option which is not defined
but resides under a valid namespace.
UnrecognizedFileExtension: If there is no loader for a path.
""""""
for path in paths:
cfg = configfile_from_path(path, strict=strict).config
return cfg"
1699,"def set_environment_var_options(config, env=None, prefix='CONFPY'):
""""""Set any configuration options which have an environment var set.
Args:
config (confpy.core.config.Configuration): A configuration object which
has been initialized with options.
env (dict): Optional dictionary which contains environment variables.
The default is os.environ if no value is given.
prefix (str): The string prefix prepended to all environment variables.
This value will be set to upper case. The default is CONFPY.
Returns:
confpy.core.config.Configuration: A configuration object with
environment variables set.
The pattern to follow when setting environment variables is:
<PREFIX>_<SECTION>_<OPTION>
Each value should be upper case and separated by underscores.
""""""