ConfigUpdater 4.0.2__tar.gz → 4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {configupdater-4.0.2 → configupdater-4.1}/CHANGELOG.rst +9 -0
- {configupdater-4.0.2 → configupdater-4.1}/PKG-INFO +1 -1
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/option.py +5 -3
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_option.py +25 -2
- {configupdater-4.0.2 → configupdater-4.1}/.gitignore +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/AUTHORS.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/CONTRIBUTING.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/LICENSE.txt +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/README.md +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/_static/.gitignore +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/api.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/authors.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/changelog.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/conf.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/contributing.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/README.md +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/banner-1280x645.png +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/banner-640x323.png +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/configupdater.svg +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/configupdater_plain.svg +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/favicon.ico +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/icon-92x128.png +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/icon.svg +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/gfx/sidebar-254x128.png +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/index.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/license.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/docs/usage.rst +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/pyproject.toml +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/__init__.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/block.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/builder.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/configupdater.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/container.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/document.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/parser.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/py.typed +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/src/configupdater/section.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/conftest.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_configupdater.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_optionxform.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_parser.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_readme.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_section.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tests/test_setup.cfg +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tools/__init__.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tools/release_notes.py +0 -0
- {configupdater-4.0.2 → configupdater-4.1}/tools/stdlib_diff.py +0 -0
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
Version 4.1
|
|
6
|
+
===========
|
|
7
|
+
|
|
8
|
+
- **Behavior change:** ``Option.as_list()`` returns an empty list instead of
|
|
9
|
+
``[""]`` for an empty value, e.g. ``key =`` or after ``set_values([])``. An
|
|
10
|
+
empty list and a single empty value are written the same way, so ``set_values([])``
|
|
11
|
+
now round-trips and a later ``append()`` no longer adds an empty first entry,
|
|
12
|
+
PR #182
|
|
13
|
+
|
|
5
14
|
Version 4.0.2
|
|
6
15
|
=============
|
|
7
16
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: ConfigUpdater
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.1
|
|
4
4
|
Summary: Parser like ConfigParser but for updating configuration files
|
|
5
5
|
Project-URL: Homepage, https://github.com/pyscaffold/configupdater
|
|
6
6
|
Project-URL: Documentation, https://configupdater.readthedocs.io/
|
|
@@ -203,14 +203,16 @@ class Option(Block):
|
|
|
203
203
|
def as_list(self, separator: str = "\n") -> list[str]:
|
|
204
204
|
"""Returns the (multi-line/element) value as a list
|
|
205
205
|
|
|
206
|
-
Empty list if value is None
|
|
207
|
-
value and an element for each line in a
|
|
206
|
+
Empty list if value is None or empty (only whitespace), single-element
|
|
207
|
+
list for a one-element value and an element for each line in a
|
|
208
|
+
multi-element value. Since an empty list and a list with a single empty
|
|
209
|
+
string are written the same way, ``set_values([])`` round-trips to ``[]``.
|
|
208
210
|
|
|
209
211
|
Args:
|
|
210
212
|
separator (str): separator for values, default: line separator
|
|
211
213
|
"""
|
|
212
214
|
value = self.value
|
|
213
|
-
if value is None:
|
|
215
|
+
if value is None or not value.strip():
|
|
214
216
|
return []
|
|
215
217
|
else:
|
|
216
218
|
return [v.strip() for v in value.strip().split(separator)]
|
|
@@ -91,7 +91,7 @@ def test_as_list_after_scalar_assignment(initial):
|
|
|
91
91
|
parser.read_string(f"[build]\n{initial}\n")
|
|
92
92
|
for value in [None, "", "beta", None, "gamma"]:
|
|
93
93
|
option.value = value
|
|
94
|
-
assert option.as_list() == ([] if value
|
|
94
|
+
assert option.as_list() == ([value] if value else [])
|
|
95
95
|
parser.set("build", "plugins", value)
|
|
96
96
|
output = StringIO()
|
|
97
97
|
cfg.write(output)
|
|
@@ -109,8 +109,31 @@ def test_as_list_after_setting_empty_values(initial):
|
|
|
109
109
|
option = Option("plugins", initial)
|
|
110
110
|
option.set_values([])
|
|
111
111
|
assert option.value == ""
|
|
112
|
-
assert option.as_list() == [
|
|
112
|
+
assert option.as_list() == []
|
|
113
113
|
assert str(option) == "plugins = \n"
|
|
114
|
+
option.append("beta")
|
|
115
|
+
assert option.as_list() == ["beta"]
|
|
116
|
+
assert str(option) == "plugins =\n beta\n"
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@pytest.mark.parametrize("value", ["", " ", "\n ", "\n \n "])
|
|
120
|
+
@pytest.mark.parametrize("separator", ["\n", ","])
|
|
121
|
+
def test_as_list_of_empty_value(value, separator):
|
|
122
|
+
option = Option("plugins", "x")
|
|
123
|
+
option.set_values([value], separator=separator, prepend_newline=False)
|
|
124
|
+
assert option.as_list(separator) == []
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_as_list_of_parsed_empty_value():
|
|
128
|
+
source = "[build]\nplugins =\nother =\n \n"
|
|
129
|
+
cfg = ConfigUpdater().read_string(source)
|
|
130
|
+
parser = ConfigParser()
|
|
131
|
+
parser.read_string(source)
|
|
132
|
+
assert cfg["build"]["plugins"].value == parser["build"]["plugins"] == ""
|
|
133
|
+
assert cfg["build"]["plugins"].as_list() == []
|
|
134
|
+
assert cfg["build"]["other"].as_list() == []
|
|
135
|
+
cfg["build"]["plugins"].append("alpha")
|
|
136
|
+
assert cfg["build"]["plugins"].as_list() == ["alpha"]
|
|
114
137
|
|
|
115
138
|
|
|
116
139
|
def test_append_to_new_valueless_option():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|