spacepy / dbprocessing

Automated processing controller for heliophysics data
5 stars 4 forks source link

DBformatter.re doesn't work with double-braces #125

Open jtniehof opened 2 years ago

jtniehof commented 2 years ago

The DBformatter.re method doesn't work with double-braces (i.e., "do not expand this").

This is documented but someone might reasonably expect to, say, include these to allow curly-braces in their configuration files and be surprised by it.

Minimal example to reproduce issue:

import dbprocessing.DBstrings
fmtr = dbprocessing.DBstrings.DBformatter()
fmtr.re('{{Y}}')  # should return '{Y}'

Error message/Traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jtniehof/.local//lib//python3.6/site-packages/dbprocessing/DBstrings.py", line 93, in re
    self.expand_format(format_string, kwargs), *args, **kwargs)
  File "/usr/lib/python3.6/string.py", line 190, in format
    return self.vformat(format_string, args, kwargs)
  File "/usr/lib/python3.6/string.py", line 194, in vformat
    result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/usr/lib/python3.6/string.py", line 234, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "/usr/lib/python3.6/string.py", line 299, in get_field
    obj = self.get_value(first, args, kwargs)
  File "/usr/lib/python3.6/string.py", line 256, in get_value
    return kwargs[key]
KeyError: 'Y'

OS, Python version, and dependency version information:

Linux-4.15.0-167-generic-x86_64-with-Ubuntu-18.04-bionic
sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)
sqlalchemy=1.1.11

Version of dbprocessing

Current git master (5acdfa8d6d33d7001660120790b634f5079148d5)

Closure condition

This issue should be closed when a test for double-braces is committed with code that makes it pass.