6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-11-13 16:56:29 +00:00

Merge remote-tracking branch 'origin/master' into nightly

This commit is contained in:
Overhang.IO 2023-09-06 10:12:16 +00:00
commit d58df5c70c
3 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1 @@
- [Bugfix] Correctly parse strings prefixed with pound "#" key in `tutor config save --set KEY=#value` commands. (by @regisb)

View File

@ -41,6 +41,10 @@ class SerializeTests(unittest.TestCase):
"x=key1:\n subkey: value\nkey2:\n subkey: value"
),
)
self.assertEqual(
("INDIGO_PRIMARY_COLOR", "#225522"),
serialize.parse_key_value("INDIGO_PRIMARY_COLOR=#225522"),
)
def test_str_format(self) -> None:
self.assertEqual("true", serialize.str_format(True))

View File

@ -73,4 +73,8 @@ def parse_key_value(text: str) -> t.Optional[tuple[str, t.Any]]:
if not value:
# Empty strings are interpreted as null values, which is incorrect.
value = "''"
elif "\n" not in value and value.startswith("#"):
# Single-line string that starts with a pound # key
# We need to escape the string, otherwise pound will be interpreted as a comment.
value = f'"{value}"'
return key, parse(value)