Skip to content

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

@jtniehof

Description

@jtniehof

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 (5acdfa8)

Closure condition

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions