polite-config 1.0.0__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.
- polite_config-1.0.0/LICENSE.txt +21 -0
- polite_config-1.0.0/LICENSES/APPDIRS_LICENSE.txt +23 -0
- polite_config-1.0.0/PKG-INFO +106 -0
- polite_config-1.0.0/README.md +86 -0
- polite_config-1.0.0/pyproject.toml +46 -0
- polite_config-1.0.0/src/polite_config/__init__.py +1 -0
- polite_config-1.0.0/src/polite_config/appdirs.py +603 -0
- polite_config-1.0.0/src/polite_config/configuration.py +363 -0
- polite_config-1.0.0/src/polite_config/paths.py +322 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-2018 Mathew Bernard Robert Topper
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This is the MIT license
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010 ActiveState Software Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
|
6
|
+
copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included
|
|
14
|
+
in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
17
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: polite-config
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Easy functions for paths, logging and configuration files
|
|
5
|
+
Home-page: https://github.com/DTOcean/dtocean
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: Mathew Toppper
|
|
8
|
+
Author-email: damm_horse@yahoo.co.uk
|
|
9
|
+
Requires-Python: >=3.13,<4.0
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Requires-Dist: configobj (>=5.0.9,<6.0.0)
|
|
15
|
+
Requires-Dist: pyyaml (>=6.0.2,<7.0.0)
|
|
16
|
+
Project-URL: Bug Tracker, https://github.com/DTOcean/dtocean/issues
|
|
17
|
+
Project-URL: Repository, https://github.com/DTOcean/dtocean
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# polite-config
|
|
21
|
+
|
|
22
|
+
Easy functions for paths, logging and configuration files.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Installation and development of polite-config uses the [Poetry](https://python-poetry.org/)
|
|
27
|
+
dependency manager. Poetry must be installed and available on the command line.
|
|
28
|
+
|
|
29
|
+
To install:
|
|
30
|
+
|
|
31
|
+
```console
|
|
32
|
+
poetry install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Tests
|
|
36
|
+
|
|
37
|
+
A test suite is provided with the source code that uses [pytest](https://docs.pytest.org).
|
|
38
|
+
|
|
39
|
+
Install the testing dependencies:
|
|
40
|
+
|
|
41
|
+
```console
|
|
42
|
+
poetry install --with test
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Run the tests:
|
|
46
|
+
|
|
47
|
+
```console
|
|
48
|
+
poetry run pytest
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
An example of setting up [logging](https://docs.python.org/3/library/logging.html)
|
|
54
|
+
using a user-specific [yaml configuration file](https://docs.python.org/3/howto/logging.html#configuring-logging).
|
|
55
|
+
|
|
56
|
+
Copy the default logging file from the module source code to the user's data
|
|
57
|
+
directory (`C:\Users\<USERNAME>\AppData\Roaming\DTOcean\polite`):
|
|
58
|
+
|
|
59
|
+
```pycon
|
|
60
|
+
>>> from polite_config.paths import (DirectoryMap, ModPath, UserDataPath)
|
|
61
|
+
|
|
62
|
+
>>> objdir = ModPath("polite", "config")
|
|
63
|
+
>>> datadir = UserDataPath("polite", "DTOcean")
|
|
64
|
+
>>> dirmap = DirectoryMap(datadir, objdir)
|
|
65
|
+
>>> dirmap.copy_file("logging.yaml", overwrite=True)
|
|
66
|
+
>>> datadir.isfile("logging.yaml")
|
|
67
|
+
True
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Use the copied configuration file to set up logging:
|
|
71
|
+
|
|
72
|
+
```pycon
|
|
73
|
+
>>> from polite_config.configuration import Logger
|
|
74
|
+
|
|
75
|
+
>>> log = Logger(datadir)
|
|
76
|
+
>>> log_config_dict = log.read()
|
|
77
|
+
>>> log.configure_logger(log_config_dict)
|
|
78
|
+
>>> logger = log.add_named_logger("polite")
|
|
79
|
+
>>> logger.info("Hello World")
|
|
80
|
+
INFO - polite - Hello World
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Note that classes such as `ModPath` and `UserDataPath` are subclasses of
|
|
84
|
+
`pathlib.Path`.
|
|
85
|
+
|
|
86
|
+
## Contributing
|
|
87
|
+
|
|
88
|
+
Pull requests are welcome. For major changes, please open an issue first to
|
|
89
|
+
discuss what you would like to change.
|
|
90
|
+
|
|
91
|
+
See [this blog post](https://www.dataonlygreater.com/blog/post/dtocean-development-change-management/)
|
|
92
|
+
for information regarding development of the DTOcean ecosystem.
|
|
93
|
+
|
|
94
|
+
Please make sure to update tests as appropriate.
|
|
95
|
+
|
|
96
|
+
## Credits
|
|
97
|
+
|
|
98
|
+
This package was initially created as part of the [EU DTOcean project](https://cordis.europa.eu/project/id/608597)
|
|
99
|
+
by Mathew Topper at [TECNALIA](https://www.tecnalia.com).
|
|
100
|
+
|
|
101
|
+
It is now maintained by Mathew Topper at [Data Only Greater](https://www.dataonlygreater.com/).
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
106
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# polite-config
|
|
2
|
+
|
|
3
|
+
Easy functions for paths, logging and configuration files.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Installation and development of polite-config uses the [Poetry](https://python-poetry.org/)
|
|
8
|
+
dependency manager. Poetry must be installed and available on the command line.
|
|
9
|
+
|
|
10
|
+
To install:
|
|
11
|
+
|
|
12
|
+
```console
|
|
13
|
+
poetry install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Tests
|
|
17
|
+
|
|
18
|
+
A test suite is provided with the source code that uses [pytest](https://docs.pytest.org).
|
|
19
|
+
|
|
20
|
+
Install the testing dependencies:
|
|
21
|
+
|
|
22
|
+
```console
|
|
23
|
+
poetry install --with test
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Run the tests:
|
|
27
|
+
|
|
28
|
+
```console
|
|
29
|
+
poetry run pytest
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
An example of setting up [logging](https://docs.python.org/3/library/logging.html)
|
|
35
|
+
using a user-specific [yaml configuration file](https://docs.python.org/3/howto/logging.html#configuring-logging).
|
|
36
|
+
|
|
37
|
+
Copy the default logging file from the module source code to the user's data
|
|
38
|
+
directory (`C:\Users\<USERNAME>\AppData\Roaming\DTOcean\polite`):
|
|
39
|
+
|
|
40
|
+
```pycon
|
|
41
|
+
>>> from polite_config.paths import (DirectoryMap, ModPath, UserDataPath)
|
|
42
|
+
|
|
43
|
+
>>> objdir = ModPath("polite", "config")
|
|
44
|
+
>>> datadir = UserDataPath("polite", "DTOcean")
|
|
45
|
+
>>> dirmap = DirectoryMap(datadir, objdir)
|
|
46
|
+
>>> dirmap.copy_file("logging.yaml", overwrite=True)
|
|
47
|
+
>>> datadir.isfile("logging.yaml")
|
|
48
|
+
True
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Use the copied configuration file to set up logging:
|
|
52
|
+
|
|
53
|
+
```pycon
|
|
54
|
+
>>> from polite_config.configuration import Logger
|
|
55
|
+
|
|
56
|
+
>>> log = Logger(datadir)
|
|
57
|
+
>>> log_config_dict = log.read()
|
|
58
|
+
>>> log.configure_logger(log_config_dict)
|
|
59
|
+
>>> logger = log.add_named_logger("polite")
|
|
60
|
+
>>> logger.info("Hello World")
|
|
61
|
+
INFO - polite - Hello World
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Note that classes such as `ModPath` and `UserDataPath` are subclasses of
|
|
65
|
+
`pathlib.Path`.
|
|
66
|
+
|
|
67
|
+
## Contributing
|
|
68
|
+
|
|
69
|
+
Pull requests are welcome. For major changes, please open an issue first to
|
|
70
|
+
discuss what you would like to change.
|
|
71
|
+
|
|
72
|
+
See [this blog post](https://www.dataonlygreater.com/blog/post/dtocean-development-change-management/)
|
|
73
|
+
for information regarding development of the DTOcean ecosystem.
|
|
74
|
+
|
|
75
|
+
Please make sure to update tests as appropriate.
|
|
76
|
+
|
|
77
|
+
## Credits
|
|
78
|
+
|
|
79
|
+
This package was initially created as part of the [EU DTOcean project](https://cordis.europa.eu/project/id/608597)
|
|
80
|
+
by Mathew Topper at [TECNALIA](https://www.tecnalia.com).
|
|
81
|
+
|
|
82
|
+
It is now maintained by Mathew Topper at [Data Only Greater](https://www.dataonlygreater.com/).
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "polite-config"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
authors = ["Mathew Toppper <damm_horse@yahoo.co.uk>"]
|
|
5
|
+
description = "Easy functions for paths, logging and configuration files"
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
repository = "https://github.com/DTOcean/dtocean"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Python :: 3",
|
|
11
|
+
"License :: OSI Approved :: MIT License",
|
|
12
|
+
"Operating System :: OS Independent",
|
|
13
|
+
]
|
|
14
|
+
packages = [{include = "polite_config", from="src"}]
|
|
15
|
+
|
|
16
|
+
[tool.poetry.urls]
|
|
17
|
+
"Bug Tracker" = "https://github.com/DTOcean/dtocean/issues"
|
|
18
|
+
|
|
19
|
+
[tool.poetry.group.test]
|
|
20
|
+
optional = true
|
|
21
|
+
|
|
22
|
+
[tool.poetry.dependencies]
|
|
23
|
+
python = "^3.13"
|
|
24
|
+
configobj = "^5.0.9"
|
|
25
|
+
pyyaml = "^6.0.2"
|
|
26
|
+
|
|
27
|
+
[tool.poetry.group.test.dependencies]
|
|
28
|
+
pytest = "^8.3.4"
|
|
29
|
+
pytest-cov = "^6.0.0"
|
|
30
|
+
pytest-mock = "^3.14.0"
|
|
31
|
+
|
|
32
|
+
[tool.coverage.run]
|
|
33
|
+
branch = true
|
|
34
|
+
omit = [
|
|
35
|
+
"src/polite_config/appdirs.py" # omit appdirs as developed externally
|
|
36
|
+
]
|
|
37
|
+
source = [
|
|
38
|
+
"src"
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
line-length = 80
|
|
43
|
+
|
|
44
|
+
[build-system]
|
|
45
|
+
requires = ["poetry-core"]
|
|
46
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__all__ = ["abc", "configuration", "paths"]
|