ConfigUpdater 4.0__py3-none-any.whl
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/__init__.py +18 -0
- configupdater/block.py +207 -0
- configupdater/builder.py +131 -0
- configupdater/configupdater.py +217 -0
- configupdater/container.py +88 -0
- configupdater/document.py +417 -0
- configupdater/option.py +263 -0
- configupdater/parser.py +576 -0
- configupdater/py.typed +0 -0
- configupdater/section.py +369 -0
- configupdater-4.0.dist-info/METADATA +349 -0
- configupdater-4.0.dist-info/RECORD +14 -0
- configupdater-4.0.dist-info/WHEEL +4 -0
- configupdater-4.0.dist-info/licenses/LICENSE.txt +289 -0
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ConfigUpdater
|
|
3
|
+
Version: 4.0
|
|
4
|
+
Summary: Parser like ConfigParser but for updating configuration files
|
|
5
|
+
Project-URL: Homepage, https://github.com/pyscaffold/configupdater
|
|
6
|
+
Project-URL: Documentation, https://configupdater.readthedocs.io/
|
|
7
|
+
Project-URL: Source, https://github.com/pyscaffold/configupdater/
|
|
8
|
+
Project-URL: Issues, https://github.com/pyscaffold/configupdater/issues
|
|
9
|
+
Project-URL: Changelog, https://configupdater.readthedocs.io/en/latest/changelog.html
|
|
10
|
+
Project-URL: Download, https://pypi.org/project/configupdater/#files
|
|
11
|
+
Project-URL: Conda-Forge, https://anaconda.org/conda-forge/configupdater
|
|
12
|
+
Author-email: Florian Wilhelm <florian.wilhelm@gmail.com>, Anderson Bravalheri <andersonbravalheri@gmail.com>
|
|
13
|
+
License-Expression: MIT
|
|
14
|
+
License-File: LICENSE.txt
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.11
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
<div align="center">
|
|
31
|
+
<img src="https://raw.githubusercontent.com/pyscaffold/configupdater/master/docs/gfx/banner-640x323.png" alt="Configupdater logo" width="500" role="img">
|
|
32
|
+
</div>
|
|
33
|
+
<br/>
|
|
34
|
+
|
|
35
|
+
| | |
|
|
36
|
+
|---------|------------------------------------|
|
|
37
|
+
| CI/CD | [![Tests][Tests-image]][Tests-link] [![Coverage][Coverage-image]][Coverage-link] [![Publish Package][Publish-image]][Publish-link] [![GitHub Sponsors][sponsor-image]][sponsor-link] |
|
|
38
|
+
| Package | [![PyPI - Version][PyPI_ver-image]][PyPI_ver-link] [![Conda - Version][Conda-image]][Conda-link] [![PyPI - Downloads][PyPI_down-image]][PyPI_down-link] [![PyPI - Python Version][PyPI_py-image]][PyPI_py-link] |
|
|
39
|
+
| Details | [![uv][uv-image]][uv-link] [![Linting - Ruff][ruff-image]][ruff-link] [![test - pytest][pytest-image]][pytest-link] [![Pre-Commit][precommit-image]][precommit-link] [![Types - Mypy][mypy-image]][mypy-link] [![License - MIT][MIT-image]][MIT-link] [![Docs - RTD][rtd-image]][rtd-link] |
|
|
40
|
+
|
|
41
|
+
The sole purpose of [ConfigUpdater] is to easily
|
|
42
|
+
update an INI config file with no changes to the original file except
|
|
43
|
+
the intended ones. This means comments, the ordering of sections and
|
|
44
|
+
key/value-pairs as wells as their cases are kept as in the original
|
|
45
|
+
file. Thus ConfigUpdater provides complementary functionality to
|
|
46
|
+
Python\'s [ConfigParser], which is primarily meant for reading config
|
|
47
|
+
files and writing *new* ones.
|
|
48
|
+
|
|
49
|
+
# Features
|
|
50
|
+
|
|
51
|
+
The key differences to [ConfigParser] are:
|
|
52
|
+
|
|
53
|
+
- minimal invasive changes in the update configuration file,
|
|
54
|
+
- proper handling of comments,
|
|
55
|
+
- only a single config file can be updated at a time,
|
|
56
|
+
- the original case of sections and keys are kept,
|
|
57
|
+
- control over the position of a new section/key
|
|
58
|
+
|
|
59
|
+
Following features are **deliberately not** implemented:
|
|
60
|
+
|
|
61
|
+
- interpolation of values,
|
|
62
|
+
- propagation of parameters from the default section,
|
|
63
|
+
- conversions of values,
|
|
64
|
+
- passing key/value-pairs with `default` argument,
|
|
65
|
+
- non-strict mode allowing duplicate sections and keys.
|
|
66
|
+
|
|
67
|
+
# Usage
|
|
68
|
+
|
|
69
|
+
First install the package with either:
|
|
70
|
+
|
|
71
|
+
```console
|
|
72
|
+
pip install configupdater
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
or add it to a project managed with [uv]:
|
|
76
|
+
|
|
77
|
+
```console
|
|
78
|
+
uv add configupdater
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
or:
|
|
82
|
+
|
|
83
|
+
```console
|
|
84
|
+
conda install -c conda-forge configupdater
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Now we can simply do:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from configupdater import ConfigUpdater
|
|
91
|
+
|
|
92
|
+
updater = ConfigUpdater()
|
|
93
|
+
updater.read("setup.cfg")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
which would read the file `setup.cfg` that is found in many projects.
|
|
97
|
+
|
|
98
|
+
To change the value of an existing key we can simply do:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
updater["metadata"]["author"].value = "Alan Turing"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
At any point we can print the current state of the configuration file
|
|
105
|
+
with:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
print(updater)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
To update the read-in file, with the encoding it was read with, just call
|
|
112
|
+
`updater.update_file()` or `updater.write(open('filename','w'))` to write
|
|
113
|
+
the changed configuration file to another destination. Before actually
|
|
114
|
+
writing, ConfigUpdater will automatically check that the updated
|
|
115
|
+
configuration file is still valid by parsing it with the help of ConfigParser.
|
|
116
|
+
|
|
117
|
+
Many of ConfigParser\'s methods still exists and it\'s best to look them
|
|
118
|
+
up in the [module reference]. Let\'s look at some examples.
|
|
119
|
+
|
|
120
|
+
## Adding and removing options
|
|
121
|
+
|
|
122
|
+
Let\'s say we have the following configuration in a string:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
cfg = """
|
|
126
|
+
[metadata]
|
|
127
|
+
author = Ada Lovelace
|
|
128
|
+
summary = The Analytical Engine
|
|
129
|
+
"""
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
We can add an *license* option, i.e. a key/value pair, in the same way
|
|
133
|
+
we would do with ConfigParser:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
updater = ConfigUpdater()
|
|
137
|
+
updater.read_string(cfg)
|
|
138
|
+
updater["metadata"]["license"] = "MIT"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A simple `print(updater)` will give show you that the new option was
|
|
142
|
+
appended to the end:
|
|
143
|
+
|
|
144
|
+
```ini
|
|
145
|
+
[metadata]
|
|
146
|
+
author = Ada Lovelace
|
|
147
|
+
summary = The Analytical Engine
|
|
148
|
+
license = MIT
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Since the license is really important to us let\'s say we want to add it
|
|
152
|
+
before the `summary` and even add a short comment before it:
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
updater = ConfigUpdater()
|
|
156
|
+
updater.read_string(cfg)
|
|
157
|
+
(
|
|
158
|
+
updater["metadata"]["summary"]
|
|
159
|
+
.add_before.comment("Ada would have loved MIT")
|
|
160
|
+
.option("license", "MIT")
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
which would result in:
|
|
165
|
+
|
|
166
|
+
```ini
|
|
167
|
+
[metadata]
|
|
168
|
+
author = Ada Lovelace
|
|
169
|
+
# Ada would have loved MIT
|
|
170
|
+
license = MIT
|
|
171
|
+
summary = The Analytical Engine
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Using `add_after` would give the same result and looks like:
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
updater = ConfigUpdater()
|
|
178
|
+
updater.read_string(cfg)
|
|
179
|
+
(
|
|
180
|
+
updater["metadata"]["author"]
|
|
181
|
+
.add_after.comment("Ada would have loved MIT")
|
|
182
|
+
.option("license", "MIT")
|
|
183
|
+
)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Let\'s say we want to rename `summary` to the more common
|
|
187
|
+
`description`:
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
updater = ConfigUpdater()
|
|
191
|
+
updater.read_string(cfg)
|
|
192
|
+
updater["metadata"]["summary"].key = "description"
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
If we wanted no summary at all, we could just do
|
|
196
|
+
`del updater["metadata"]["summary"]`.
|
|
197
|
+
|
|
198
|
+
## Adding and removing sections
|
|
199
|
+
|
|
200
|
+
Adding and remove sections just works like adding and removing options
|
|
201
|
+
but on a higher level. Sticking to our *Ada Lovelace* example, let\'s
|
|
202
|
+
say we want to add a section `options` just before `metadata` with a
|
|
203
|
+
comment and two new lines to separate it from `metadata`:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
updater = ConfigUpdater()
|
|
207
|
+
updater.read_string(cfg)
|
|
208
|
+
(
|
|
209
|
+
updater["metadata"]
|
|
210
|
+
.add_before.comment("Some specific project options")
|
|
211
|
+
.section("options")
|
|
212
|
+
.space(2)
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
As expected, this results in:
|
|
217
|
+
|
|
218
|
+
```ini
|
|
219
|
+
# Some specific project options
|
|
220
|
+
[options]
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
[metadata]
|
|
224
|
+
author = Ada Lovelace
|
|
225
|
+
summary = The Analytical Engine
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
We could now fill the new section with options like we learnt before. If
|
|
229
|
+
we wanted to rename an existing section we could do this with the help
|
|
230
|
+
of the `name` attribute:
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
updater["metadata"].name = "MetaData"
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Sometimes it might be useful to inject a new section not in a
|
|
237
|
+
programmatic way but more declarative. Let\'s assume we have thus
|
|
238
|
+
defined our new section in a multi-line string:
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
sphinx_sect_str = """
|
|
242
|
+
[build_sphinx]
|
|
243
|
+
source_dir = docs
|
|
244
|
+
build_dir = docs/_build
|
|
245
|
+
"""
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
With the help of two ConfigUpdater objects we can easily inject this
|
|
249
|
+
section into our example:
|
|
250
|
+
|
|
251
|
+
```python
|
|
252
|
+
sphinx = ConfigUpdater()
|
|
253
|
+
sphinx.read_string(sphinx_sect_str)
|
|
254
|
+
sphinx_sect = sphinx["build_sphinx"]
|
|
255
|
+
|
|
256
|
+
updater = ConfigUpdater()
|
|
257
|
+
updater.read_string(cfg)
|
|
258
|
+
|
|
259
|
+
(updater["metadata"].add_after.space().section(sphinx_sect.detach()))
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
The `detach` method will remove the `build_sphinx` section from the
|
|
263
|
+
first object and add it to the second object. This results in:
|
|
264
|
+
|
|
265
|
+
```ini
|
|
266
|
+
[metadata]
|
|
267
|
+
author = Ada Lovelace
|
|
268
|
+
summary = The Analytical Engine
|
|
269
|
+
|
|
270
|
+
[build_sphinx]
|
|
271
|
+
source_dir = docs
|
|
272
|
+
build_dir = docs/_build
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Alternatively, if you want to preserve `build_sphinx` in both
|
|
276
|
+
`ConfigUpdater` objects (i.e., prevent it from being removed from the
|
|
277
|
+
first while still adding a copy to the second), you call also rely on
|
|
278
|
+
stdlib\'s `copy.deepcopy` function instead of `detach`:
|
|
279
|
+
|
|
280
|
+
```python
|
|
281
|
+
from copy import deepcopy
|
|
282
|
+
|
|
283
|
+
sphinx = ConfigUpdater()
|
|
284
|
+
sphinx.read_string(sphinx_sect_str)
|
|
285
|
+
sphinx_sect = sphinx["build_sphinx"]
|
|
286
|
+
|
|
287
|
+
updater = ConfigUpdater()
|
|
288
|
+
updater.read_string(cfg)
|
|
289
|
+
|
|
290
|
+
(updater["metadata"].add_after.space().section(deepcopy(sphinx_sect)))
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
This technique can be used for all objects inside ConfigUpdater:
|
|
294
|
+
sections, options, comments and blank spaces.
|
|
295
|
+
|
|
296
|
+
Shallow copies are discouraged in the context of ConfigUpdater because
|
|
297
|
+
each configuration block keeps a reference to its container to allow
|
|
298
|
+
easy document editing. When doing editions (such as adding or changing
|
|
299
|
+
options and comments) based on a shallow copy, the results can be
|
|
300
|
+
unreliable and unexpected.
|
|
301
|
+
|
|
302
|
+
For more examples on how the API of ConfigUpdater works it\'s best to
|
|
303
|
+
take a look into the [unit tests] and read the references.
|
|
304
|
+
|
|
305
|
+
# Notes
|
|
306
|
+
|
|
307
|
+
ConfigUpdater started out as a helper for [PyScaffold], which still uses
|
|
308
|
+
it to update the `setup.cfg` of existing projects. Since then it has
|
|
309
|
+
become a useful tool in its own right for everyone who needs to change
|
|
310
|
+
configuration files programmatically without losing the comments and
|
|
311
|
+
formatting that humans put into them.
|
|
312
|
+
|
|
313
|
+
[ConfigUpdater]: https://configupdater.readthedocs.io/
|
|
314
|
+
[ConfigParser]: https://docs.python.org/3/library/configparser.html
|
|
315
|
+
[PyScaffold]: https://pyscaffold.org/
|
|
316
|
+
[uv]: https://docs.astral.sh/uv/
|
|
317
|
+
[module reference]: https://configupdater.readthedocs.io/en/latest/api.html#configupdater.configupdater.ConfigUpdater
|
|
318
|
+
[unit tests]: https://github.com/pyscaffold/configupdater/blob/main/tests/test_configupdater.py
|
|
319
|
+
|
|
320
|
+
[Tests-image]: https://github.com/pyscaffold/configupdater/actions/workflows/ci.yml/badge.svg
|
|
321
|
+
[Tests-link]: https://github.com/pyscaffold/configupdater/actions/workflows/ci.yml
|
|
322
|
+
[Coverage-image]: https://img.shields.io/coveralls/github/pyscaffold/configupdater/main.svg
|
|
323
|
+
[Coverage-link]: https://coveralls.io/r/pyscaffold/configupdater
|
|
324
|
+
[Publish-image]: https://github.com/pyscaffold/configupdater/actions/workflows/publish-package.yml/badge.svg
|
|
325
|
+
[Publish-link]: https://github.com/pyscaffold/configupdater/actions/workflows/publish-package.yml
|
|
326
|
+
[PyPI_ver-image]:https://img.shields.io/pypi/v/configupdater.svg?logo=pypi&label=PyPI&logoColor=gold
|
|
327
|
+
[PyPI_ver-link]: https://pypi.org/project/configupdater/
|
|
328
|
+
[Conda-image]: https://img.shields.io/conda/vn/conda-forge/configupdater.svg?logo=Anaconda&label=Conda-Forge&logoColor=44A833
|
|
329
|
+
[Conda-link]: https://anaconda.org/conda-forge/configupdater/
|
|
330
|
+
[PyPI_down-image]: https://img.shields.io/pypi/dm/configupdater.svg?color=blue&label=Downloads&logo=pypi&logoColor=gold
|
|
331
|
+
[PyPI_down-link]: https://clickpy.clickhouse.com/dashboard/configupdater
|
|
332
|
+
[PyPI_py-image]: https://img.shields.io/pypi/pyversions/configupdater.svg?logo=python&label=Python&logoColor=gold
|
|
333
|
+
[PyPI_py-link]: https://pypi.org/project/configupdater/
|
|
334
|
+
[uv-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json
|
|
335
|
+
[uv-link]: https://github.com/astral-sh/uv
|
|
336
|
+
[ruff-image]: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
|
|
337
|
+
[ruff-link]: https://github.com/charliermarsh/ruff
|
|
338
|
+
[mypy-image]: https://img.shields.io/badge/Types-mypy-blue.svg
|
|
339
|
+
[mypy-link]: https://mypy-lang.org/
|
|
340
|
+
[pytest-image]: https://img.shields.io/static/v1?label=&message=Pytest&logo=Pytest&color=0A9EDC&logoColor=white
|
|
341
|
+
[pytest-link]: https://docs.pytest.org/
|
|
342
|
+
[rtd-image]: https://readthedocs.org/projects/configupdater/badge/?version=latest
|
|
343
|
+
[rtd-link]: https://configupdater.readthedocs.io/
|
|
344
|
+
[precommit-image]: https://img.shields.io/static/v1?label=&message=pre-commit&logo=pre-commit&color=76877c
|
|
345
|
+
[precommit-link]: https://pre-commit.com/
|
|
346
|
+
[MIT-image]: https://img.shields.io/badge/License-MIT-9400d3.svg
|
|
347
|
+
[MIT-link]: LICENSE.txt
|
|
348
|
+
[sponsor-image]: https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=ff69b4
|
|
349
|
+
[sponsor-link]: https://github.com/sponsors/FlorianWilhelm
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
configupdater/__init__.py,sha256=Waiyjx25q2Xa_NRlZ9GBuqyrCvPx7n3OG2rnYtTFDZA,526
|
|
2
|
+
configupdater/block.py,sha256=5GICM-FCKzAMOfZq7EfsSm9SiPR7JkwoIg7PCwR47h8,6674
|
|
3
|
+
configupdater/builder.py,sha256=TE5RZySHeaaaHCC0eZZSP0b4xulxpJoYll3DDNr7Psk,4144
|
|
4
|
+
configupdater/configupdater.py,sha256=_PIgIzVStKvOOdyJKtpc0X4m1X_YDWlO-7V-nmnScR4,8233
|
|
5
|
+
configupdater/container.py,sha256=pqPerih6m0sG6ET9PeDch0kjyZ3hipoJ_Fb28H3ZTIY,2736
|
|
6
|
+
configupdater/document.py,sha256=69rtaATQj8zRpm6Zd54tQvBsEHP7l4773wbJJbRL9I8,15002
|
|
7
|
+
configupdater/option.py,sha256=iEogFOyFRny2K2G-UieJcmtAPN2QutkJ_DdQwIM-dZg,9272
|
|
8
|
+
configupdater/parser.py,sha256=O6ujmzq7QOcm-IQ0h3tq5lfbBJEHrUvuH4Rr_VuTpmE,25009
|
|
9
|
+
configupdater/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
configupdater/section.py,sha256=BjuVmEuT03VBEInS_me9G9RmTsOFQSZS1oA3pu6zFBQ,13049
|
|
11
|
+
configupdater-4.0.dist-info/METADATA,sha256=2YKXjQjlhVEdaWCEfjgRMeGWBl0e_HT-9gX44bIybC4,12124
|
|
12
|
+
configupdater-4.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
13
|
+
configupdater-4.0.dist-info/licenses/LICENSE.txt,sha256=t_IAs6aOhF6A7JaCD91OZ7bNsZ2IjmavMoFtQDXtRBY,14402
|
|
14
|
+
configupdater-4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
ConfigUpdater is licensed under the MIT license; see below for details.
|
|
2
|
+
|
|
3
|
+
ConfigUpdater includes code derived from the Python standard library, which is
|
|
4
|
+
licensed under the Python license, a permissive open source license.
|
|
5
|
+
The copyright and license are included at the bottom of this file for compliance
|
|
6
|
+
with Python's terms.
|
|
7
|
+
|
|
8
|
+
----------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
The MIT License (MIT)
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2018 Florian Wilhelm
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
|
|
32
|
+
----------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
Copyright (c) 2001-present Python Software Foundation; All Rights Reserved
|
|
35
|
+
|
|
36
|
+
A. HISTORY OF THE SOFTWARE
|
|
37
|
+
==========================
|
|
38
|
+
|
|
39
|
+
Python was created in the early 1990s by Guido van Rossum at Stichting
|
|
40
|
+
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
|
|
41
|
+
as a successor of a language called ABC. Guido remains Python's
|
|
42
|
+
principal author, although it includes many contributions from others.
|
|
43
|
+
|
|
44
|
+
In 1995, Guido continued his work on Python at the Corporation for
|
|
45
|
+
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
|
|
46
|
+
in Reston, Virginia where he released several versions of the
|
|
47
|
+
software.
|
|
48
|
+
|
|
49
|
+
In May 2000, Guido and the Python core development team moved to
|
|
50
|
+
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
|
51
|
+
year, the PythonLabs team moved to Digital Creations, which became
|
|
52
|
+
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
|
53
|
+
https://www.python.org/psf/) was formed, a non-profit organization
|
|
54
|
+
created specifically to own Python-related Intellectual Property.
|
|
55
|
+
Zope Corporation was a sponsoring member of the PSF.
|
|
56
|
+
|
|
57
|
+
All Python releases are Open Source (see http://www.opensource.org for
|
|
58
|
+
the Open Source Definition). Historically, most, but not all, Python
|
|
59
|
+
releases have also been GPL-compatible; the table below summarizes
|
|
60
|
+
the various releases.
|
|
61
|
+
|
|
62
|
+
Release Derived Year Owner GPL-
|
|
63
|
+
from compatible? (1)
|
|
64
|
+
|
|
65
|
+
0.9.0 thru 1.2 1991-1995 CWI yes
|
|
66
|
+
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
|
67
|
+
1.6 1.5.2 2000 CNRI no
|
|
68
|
+
2.0 1.6 2000 BeOpen.com no
|
|
69
|
+
1.6.1 1.6 2001 CNRI yes (2)
|
|
70
|
+
2.1 2.0+1.6.1 2001 PSF no
|
|
71
|
+
2.0.1 2.0+1.6.1 2001 PSF yes
|
|
72
|
+
2.1.1 2.1+2.0.1 2001 PSF yes
|
|
73
|
+
2.1.2 2.1.1 2002 PSF yes
|
|
74
|
+
2.1.3 2.1.2 2002 PSF yes
|
|
75
|
+
2.2 and above 2.1.1 2001-now PSF yes
|
|
76
|
+
|
|
77
|
+
Footnotes:
|
|
78
|
+
|
|
79
|
+
(1) GPL-compatible doesn't mean that we're distributing Python under
|
|
80
|
+
the GPL. All Python licenses, unlike the GPL, let you distribute
|
|
81
|
+
a modified version without making your changes open source. The
|
|
82
|
+
GPL-compatible licenses make it possible to combine Python with
|
|
83
|
+
other software that is released under the GPL; the others don't.
|
|
84
|
+
|
|
85
|
+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
|
86
|
+
because its license has a choice of law clause. According to
|
|
87
|
+
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
|
88
|
+
is "not incompatible" with the GPL.
|
|
89
|
+
|
|
90
|
+
Thanks to the many outside volunteers who have worked under Guido's
|
|
91
|
+
direction to make these releases possible.
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
|
95
|
+
===============================================================
|
|
96
|
+
|
|
97
|
+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
|
98
|
+
--------------------------------------------
|
|
99
|
+
|
|
100
|
+
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
|
101
|
+
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
|
102
|
+
otherwise using this software ("Python") in source or binary form and
|
|
103
|
+
its associated documentation.
|
|
104
|
+
|
|
105
|
+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
|
106
|
+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
|
107
|
+
analyze, test, perform and/or display publicly, prepare derivative works,
|
|
108
|
+
distribute, and otherwise use Python alone or in any derivative version,
|
|
109
|
+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
|
110
|
+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
|
111
|
+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation;
|
|
112
|
+
All Rights Reserved" are retained in Python alone or in any derivative version
|
|
113
|
+
prepared by Licensee.
|
|
114
|
+
|
|
115
|
+
3. In the event Licensee prepares a derivative work that is based on
|
|
116
|
+
or incorporates Python or any part thereof, and wants to make
|
|
117
|
+
the derivative work available to others as provided herein, then
|
|
118
|
+
Licensee hereby agrees to include in any such work a brief summary of
|
|
119
|
+
the changes made to Python.
|
|
120
|
+
|
|
121
|
+
4. PSF is making Python available to Licensee on an "AS IS"
|
|
122
|
+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
|
123
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
|
124
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
|
125
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
|
126
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
|
127
|
+
|
|
128
|
+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
|
129
|
+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
|
130
|
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
|
131
|
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
|
132
|
+
|
|
133
|
+
6. This License Agreement will automatically terminate upon a material
|
|
134
|
+
breach of its terms and conditions.
|
|
135
|
+
|
|
136
|
+
7. Nothing in this License Agreement shall be deemed to create any
|
|
137
|
+
relationship of agency, partnership, or joint venture between PSF and
|
|
138
|
+
Licensee. This License Agreement does not grant permission to use PSF
|
|
139
|
+
trademarks or trade name in a trademark sense to endorse or promote
|
|
140
|
+
products or services of Licensee, or any third party.
|
|
141
|
+
|
|
142
|
+
8. By copying, installing or otherwise using Python, Licensee
|
|
143
|
+
agrees to be bound by the terms and conditions of this License
|
|
144
|
+
Agreement.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
|
148
|
+
-------------------------------------------
|
|
149
|
+
|
|
150
|
+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
|
151
|
+
|
|
152
|
+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
|
153
|
+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
|
154
|
+
Individual or Organization ("Licensee") accessing and otherwise using
|
|
155
|
+
this software in source or binary form and its associated
|
|
156
|
+
documentation ("the Software").
|
|
157
|
+
|
|
158
|
+
2. Subject to the terms and conditions of this BeOpen Python License
|
|
159
|
+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
|
160
|
+
royalty-free, world-wide license to reproduce, analyze, test, perform
|
|
161
|
+
and/or display publicly, prepare derivative works, distribute, and
|
|
162
|
+
otherwise use the Software alone or in any derivative version,
|
|
163
|
+
provided, however, that the BeOpen Python License is retained in the
|
|
164
|
+
Software, alone or in any derivative version prepared by Licensee.
|
|
165
|
+
|
|
166
|
+
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
|
167
|
+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
|
168
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
|
169
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
|
170
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
|
171
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
|
172
|
+
|
|
173
|
+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
|
174
|
+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
|
175
|
+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
|
176
|
+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
|
177
|
+
|
|
178
|
+
5. This License Agreement will automatically terminate upon a material
|
|
179
|
+
breach of its terms and conditions.
|
|
180
|
+
|
|
181
|
+
6. This License Agreement shall be governed by and interpreted in all
|
|
182
|
+
respects by the law of the State of California, excluding conflict of
|
|
183
|
+
law provisions. Nothing in this License Agreement shall be deemed to
|
|
184
|
+
create any relationship of agency, partnership, or joint venture
|
|
185
|
+
between BeOpen and Licensee. This License Agreement does not grant
|
|
186
|
+
permission to use BeOpen trademarks or trade names in a trademark
|
|
187
|
+
sense to endorse or promote products or services of Licensee, or any
|
|
188
|
+
third party. As an exception, the "BeOpen Python" logos available at
|
|
189
|
+
http://www.pythonlabs.com/logos.html may be used according to the
|
|
190
|
+
permissions granted on that web page.
|
|
191
|
+
|
|
192
|
+
7. By copying, installing or otherwise using the software, Licensee
|
|
193
|
+
agrees to be bound by the terms and conditions of this License
|
|
194
|
+
Agreement.
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
|
198
|
+
---------------------------------------
|
|
199
|
+
|
|
200
|
+
1. This LICENSE AGREEMENT is between the Corporation for National
|
|
201
|
+
Research Initiatives, having an office at 1895 Preston White Drive,
|
|
202
|
+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
|
203
|
+
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
|
204
|
+
source or binary form and its associated documentation.
|
|
205
|
+
|
|
206
|
+
2. Subject to the terms and conditions of this License Agreement, CNRI
|
|
207
|
+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
|
208
|
+
license to reproduce, analyze, test, perform and/or display publicly,
|
|
209
|
+
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
|
210
|
+
alone or in any derivative version, provided, however, that CNRI's
|
|
211
|
+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
|
212
|
+
1995-2001 Corporation for National Research Initiatives; All Rights
|
|
213
|
+
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
|
214
|
+
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
|
215
|
+
Agreement, Licensee may substitute the following text (omitting the
|
|
216
|
+
quotes): "Python 1.6.1 is made available subject to the terms and
|
|
217
|
+
conditions in CNRI's License Agreement. This Agreement together with
|
|
218
|
+
Python 1.6.1 may be located on the Internet using the following
|
|
219
|
+
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
|
220
|
+
Agreement may also be obtained from a proxy server on the Internet
|
|
221
|
+
using the following URL: http://hdl.handle.net/1895.22/1013".
|
|
222
|
+
|
|
223
|
+
3. In the event Licensee prepares a derivative work that is based on
|
|
224
|
+
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
|
225
|
+
the derivative work available to others as provided herein, then
|
|
226
|
+
Licensee hereby agrees to include in any such work a brief summary of
|
|
227
|
+
the changes made to Python 1.6.1.
|
|
228
|
+
|
|
229
|
+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
|
230
|
+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
|
231
|
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
|
232
|
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
|
233
|
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
|
234
|
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
|
235
|
+
|
|
236
|
+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
|
237
|
+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
|
238
|
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
|
239
|
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
|
240
|
+
|
|
241
|
+
6. This License Agreement will automatically terminate upon a material
|
|
242
|
+
breach of its terms and conditions.
|
|
243
|
+
|
|
244
|
+
7. This License Agreement shall be governed by the federal
|
|
245
|
+
intellectual property law of the United States, including without
|
|
246
|
+
limitation the federal copyright law, and, to the extent such
|
|
247
|
+
U.S. federal law does not apply, by the law of the Commonwealth of
|
|
248
|
+
Virginia, excluding Virginia's conflict of law provisions.
|
|
249
|
+
Notwithstanding the foregoing, with regard to derivative works based
|
|
250
|
+
on Python 1.6.1 that incorporate non-separable material that was
|
|
251
|
+
previously distributed under the GNU General Public License (GPL), the
|
|
252
|
+
law of the Commonwealth of Virginia shall govern this License
|
|
253
|
+
Agreement only as to issues arising under or with respect to
|
|
254
|
+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
|
255
|
+
License Agreement shall be deemed to create any relationship of
|
|
256
|
+
agency, partnership, or joint venture between CNRI and Licensee. This
|
|
257
|
+
License Agreement does not grant permission to use CNRI trademarks or
|
|
258
|
+
trade name in a trademark sense to endorse or promote products or
|
|
259
|
+
services of Licensee, or any third party.
|
|
260
|
+
|
|
261
|
+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
|
262
|
+
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
|
263
|
+
bound by the terms and conditions of this License Agreement.
|
|
264
|
+
|
|
265
|
+
ACCEPT
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
|
269
|
+
--------------------------------------------------
|
|
270
|
+
|
|
271
|
+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
|
272
|
+
The Netherlands. All rights reserved.
|
|
273
|
+
|
|
274
|
+
Permission to use, copy, modify, and distribute this software and its
|
|
275
|
+
documentation for any purpose and without fee is hereby granted,
|
|
276
|
+
provided that the above copyright notice appear in all copies and that
|
|
277
|
+
both that copyright notice and this permission notice appear in
|
|
278
|
+
supporting documentation, and that the name of Stichting Mathematisch
|
|
279
|
+
Centrum or CWI not be used in advertising or publicity pertaining to
|
|
280
|
+
distribution of the software without specific, written prior
|
|
281
|
+
permission.
|
|
282
|
+
|
|
283
|
+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
|
284
|
+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
285
|
+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
|
286
|
+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
287
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
288
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
289
|
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|