@@ -26,7 +26,6 @@ def fixed_get_attr(self, item):
2626 except KeyError :
2727 return ""
2828
29-
3029 pyparsing .ParseResults .__getattr__ = fixed_get_attr
3130
3231from pyhocon .config_tree import (ConfigInclude , ConfigList , ConfigQuotedString ,
@@ -50,6 +49,7 @@ def find_package_dirs(name):
5049 raise ImportError ('No module named {!r}' .format (name ))
5150 return spec .submodule_search_locations
5251
52+
5353logger = logging .getLogger (__name__ )
5454
5555
@@ -350,7 +350,7 @@ def set_default_white_spaces():
350350 false_expr = Keyword ("false" , case_insensitive = True ).set_parse_action (replace_with (False ))
351351 null_expr = Keyword ("null" , case_insensitive = True ).set_parse_action (replace_with (NoneValue ()))
352352 key = QuotedString ('"""' , esc_char = '\\ ' , unquote_results = False ) | \
353- QuotedString ('"' , esc_char = '\\ ' , unquote_results = False ) | Word (alphanums + alphas8bit + '._- /' )
353+ QuotedString ('"' , esc_char = '\\ ' , unquote_results = False ) | Word (alphanums + alphas8bit + '._- /' )
354354
355355 eol = Word ('\n \r ' ).suppress ()
356356 eol_comma = Word ('\n \r ,' ).suppress ()
@@ -377,15 +377,16 @@ def set_default_white_spaces():
377377 value_expr = get_period_expr () | number_expr | true_expr | false_expr | null_expr | string_expr
378378
379379 include_content = (
380- quoted_string | ((Keyword ('url' ) | Keyword ('file' ) | Keyword ('package' )) - Literal (
381- '(' ).suppress () - quoted_string - Literal (')' ).suppress ())
380+ quoted_string | ((Keyword ('url' ) | Keyword ('file' ) | Keyword ('package' ))
381+ - Literal ('(' ).suppress () - quoted_string
382+ - Literal (')' ).suppress ())
382383 )
383384 include_expr = (
384- Keyword ("include" , case_insensitive = True ).suppress () + (
385+ Keyword ("include" , case_insensitive = True ).suppress () + (
385386 include_content | (
386- Keyword ("required" ) - Literal ('(' ).suppress () - include_content - Literal (')' ).suppress ()
387- )
388- )
387+ Keyword ("required" ) - Literal ('(' ).suppress () - include_content - Literal (')' ).suppress ()
388+ )
389+ )
389390 ).set_parse_action (include_config )
390391
391392 root_dict_expr = Forward ()
@@ -407,19 +408,20 @@ def set_default_white_spaces():
407408 # special case when we have a value assignment where the string can potentially be the remainder of the line
408409 assign_expr << Group (
409410 key - ZeroOrMore (comment_no_comma_eol ) - (
410- dict_expr | (Literal ('=' ) | Literal (':' ) | Literal ('+=' )) - ZeroOrMore (
411- comment_no_comma_eol ) - ConcatenatedValueParser (multi_value_expr ))
411+ dict_expr | (Literal ('=' ) | Literal (':' ) | Literal ('+=' )) - ZeroOrMore (
412+ comment_no_comma_eol ) - ConcatenatedValueParser (multi_value_expr ))
412413 )
413414
414415 # the file can be { ... } where {} can be omitted or []
415416 config_expr = ZeroOrMore (comment_eol | eol ) + (
416- list_expr | root_dict_expr | inside_root_dict_expr ) + ZeroOrMore (
417+ list_expr | root_dict_expr | inside_root_dict_expr
418+ ) + ZeroOrMore (
417419 comment_eol | eol_comma )
418420 config = config_expr .parse_string (content , parse_all = True )[0 ]
419421
420422 if resolve :
421- allow_unresolved = resolve and unresolved_value is not DEFAULT_SUBSTITUTION \
422- and unresolved_value is not MANDATORY_SUBSTITUTION
423+ allow_unresolved = resolve and unresolved_value is not DEFAULT_SUBSTITUTION
424+ allow_unresolved = allow_unresolved and unresolved_value is not MANDATORY_SUBSTITUTION
423425 has_unresolved = cls .resolve_substitutions (config , allow_unresolved )
424426 if has_unresolved and unresolved_value is MANDATORY_SUBSTITUTION :
425427 raise ConfigSubstitutionException (
@@ -535,8 +537,8 @@ def _do_substitute(cls, substitution, resolved_value, is_optional_resolved=True)
535537 # if it is a string, then add the extra ws that was present in the original string after the substitution
536538 formatted_resolved_value = resolved_value \
537539 if resolved_value is None \
538- or isinstance (resolved_value , (dict , list )) \
539- or substitution .index == len (config_values .tokens ) - 1 \
540+ or isinstance (resolved_value , (dict , list )) \
541+ or substitution .index == len (config_values .tokens ) - 1 \
540542 else (str (resolved_value ) + substitution .ws )
541543 # use a deepcopy of resolved_value to avoid mutation
542544 config_values .put (substitution .index , copy .deepcopy (formatted_resolved_value ))
@@ -606,11 +608,11 @@ def resolve_substitutions(cls, config, accept_unresolved=False):
606608
607609 is_optional_resolved , resolved_value = cls ._resolve_variable (config , substitution )
608610
609- if isinstance (resolved_value , ConfigValues ) :
611+ if isinstance (resolved_value , ConfigValues ):
610612 resolved_value = resolved_value .transform ()
611613 value_to_be_substitute = resolved_value
612614 if overridden_value and not isinstance (overridden_value , ConfigValues ):
613- value_to_be_substitute = overridden_value
615+ value_to_be_substitute = overridden_value
614616 unresolved , _ , _ = cls ._do_substitute (substitution , value_to_be_substitute , is_optional_resolved )
615617
616618 any_unresolved = unresolved or any_unresolved
0 commit comments