Skip to content

fix(etl): replace str.format with regex to avoid brace conflicts - #138

Open
C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/config-args-brace-conflict
Open

C1-BA-B1-F3 wants to merge 2 commits into
geopython:masterfrom
C1-BA-B1-F3:fix/config-args-brace-conflict

Conversation

@C1-BA-B1-F3

Copy link
Copy Markdown

Summary

Config argument substitution used str.format(), which interprets any {} in the config string as a format placeholder. Config values like converter_args that contain dict literals trigger KeyError on the dict keys:

KeyError: "\n    'root_tag'"

Fix

Replace str.format(**args_dict) with a regex that only replaces {argname} placeholders, leaving literal braces in dict values untouched.

Test plan

  • Verified with a sample config: {foo} placeholders are substituted while {'root_tag': ...} dict literals remain intact.

Fixes #124

base64.encodestring was removed in Python 3.9 and expected a str in
Python 3 (raising TypeError: expected bytes-like object, not str).
Use base64.b64encode with explicit UTF-8 encode/decode, which works
on all Python 3 versions.

Fixes geopython#130
Config argument substitution used str.format(), which interprets any
{} in the config string as a format placeholder. Config values like
converter_args that contain dict literals (e.g. {'root_tag': ...})
triggered KeyError on the dict keys.

Use a regex that only replaces {argname} placeholders, leaving literal
braces untouched.

Fixes geopython#124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format string and dictionary options are incompatible

1 participant