From 4ad5919b512cd893dca80d1afee0ce4b8e0d49aa Mon Sep 17 00:00:00 2001 From: Cory Nezin Date: Fri, 28 Aug 2020 09:35:42 -0400 Subject: [PATCH] add parse_with option to parse_config() --- gin/config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gin/config.py b/gin/config.py index 4f894bb..c51270f 100644 --- a/gin/config.py +++ b/gin/config.py @@ -1532,7 +1532,7 @@ class ParsedConfigFileIncludesAndImports( pass -def parse_config(bindings, skip_unknown=False): +def parse_config(bindings, skip_unknown=False, with_scope=''): """Parse a file, string, or list of strings containing parameter bindings. Parses parameter binding strings to set up the global configuration. Once @@ -1623,6 +1623,8 @@ def parse_config(bindings, skip_unknown=False): for statement in parser: if isinstance(statement, config_parser.BindingStatement): scope, selector, arg_name, value, location = statement + if with_scope: + scope = '{}/{}'.format(with_scope, scope) if scope else with_scope if not arg_name: macro_name = '{}/{}'.format(scope, selector) if scope else selector with utils.try_with_location(location):