pyhocon icon indicating copy to clipboard operation
pyhocon copied to clipboard

Keeping unresolved string substitutions doesn't work

Open juls858 opened this issue 5 years ago • 0 comments

Changing unresolved_value parameter to use STR_SUBSTITUTION does not work.

ConfigFactory.parse_file(file, resolve=False,unresolved_value=STR_SUBSTITUTION)

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/repos/amf-datapipeline-hotel/src/Untitled-1.py in 
----> 22 pprint.pprint(ConfigFactory.parse_file(config["analytic.results.datacalculations.json"], resolve=False, unresolved_value=STR_SUBSTITUTION))

~/miniconda3/envs/amf-datapipeline-hotel/lib/python3.8/site-packages/pyhocon/config_parser.py in parse_file(cls, filename, encoding, required, resolve, unresolved_value)
     97             with codecs.open(filename, 'r', encoding=encoding) as fd:
     98                 content = fd.read()
---> 99                 return cls.parse_string(content, os.path.dirname(filename), resolve, unresolved_value)
    100         except IOError as e:
    101             if required:

~/miniconda3/envs/amf-datapipeline-hotel/lib/python3.8/site-packages/pyhocon/config_parser.py in parse_string(cls, content, basedir, resolve, unresolved_value)
    148         :type return: Config
    149         """
--> 150         return ConfigParser().parse(content, basedir, resolve, unresolved_value)
    151 
    152     @classmethod

~/miniconda3/envs/amf-datapipeline-hotel/lib/python3.8/site-packages/pyhocon/config_parser.py in parse(cls, content, basedir, resolve, unresolved_value)
    426 
    427             if unresolved_value is not NO_SUBSTITUTION and unresolved_value is not DEFAULT_SUBSTITUTION:
--> 428                 cls.unresolve_substitutions_to_value(config, unresolved_value)
    429         return config
    430 

~/miniconda3/envs/amf-datapipeline-hotel/lib/python3.8/site-packages/pyhocon/config_parser.py in unresolve_substitutions_to_value(cls, config, unresolved_value)
    572         for substitution in cls._find_substitutions(config):
    573             if unresolved_value is STR_SUBSTITUTION:
--> 574                 value = substitution.raw_str()
    575             elif unresolved_value is None:
    576                 value = NoneValue()

AttributeError: 'ConfigSubstitution' object has no attribute 'raw_str'

juls858 avatar Sep 18 '20 20:09 juls858