A simple TOML configuration for EWS settings
Project description
ews-core-config
Installation
Install with
pipx install ews-core-config[cli]
What does it do
It looks for a ~/.config/ews/ews_config.toml
file.
See an example configuration in this discussion.
The default config is found in the file config.py.
Usage
Libraries developed by EWS Consulting can require this package as an optional
dependency under the extra ews
.
This can be done in the pyproject.toml
file.
[project.optional-dependencies]
ews = ["ews-core-config"]
This installation will be like:
pip install ews-my-awesome-library[ews]
Then, in the code:
import contextlib
with contextlib.suppress(ImportError):
from ews_core_config.config import read_settings
read_settings()
my_password = os.getenv("EWS_SHAREPOINT_USERNAME", "")
This will read your config file and set all the environment variables.
For instance, other libraries (like the one used to retrieve files on our SharePoint) will have access to the env. variable EWS_SHAREPOINT_USERNAME
and EWS_SHAREPOINT_PASSWORD
.
Alternatively, you can directly retrieve the settings
from the module.
from ews_core_config.config import read_settings
EWSSettings = read_settings()
username = EWSSettings.sharepoint_username
assert username != "", "Please set your SharePoint user name!"
This is not the preferred way. Indeed, it might be easier to refractor libraries to make them independent of our library if they just use environment variables.
Installation with pipx
pipx install .[cli] --editable --force
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ews_core_config-20240416.tar.gz
.
File metadata
- Download URL: ews_core_config-20240416.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b1e57e5e0788a9e9c2081332c5b29155ce552ed910ae50387fa3a469aa8fb32 |
|
MD5 | 7892d7c87349bd67f5b2f678b4cd7745 |
|
BLAKE2b-256 | 9d15d65b3de723494d7310fc72ec08a727453fc320e9905ac70caa26347eb0c0 |
File details
Details for the file ews_core_config-20240416-py3-none-any.whl
.
File metadata
- Download URL: ews_core_config-20240416-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7823d1c690c9406dfb1c093a07700aa401164bc89386f3ab23449d518c4d3443 |
|
MD5 | ece8ab5130b165ce7573c82a4411a170 |
|
BLAKE2b-256 | ab332f021031c6adc3bf841a3ee5e2d4d413576271733b19bde22b32c84d8d42 |