Skip to main content

A simple TOML configuration for EWS settings

Project description

ews-core-config

PyPI version PyPI - License PyPI - Python Version PyPI - Wheel

Ruff Precommit

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ews_core_config-20240412.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

ews_core_config-20240412-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file ews_core_config-20240412.tar.gz.

File metadata

  • Download URL: ews_core_config-20240412.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for ews_core_config-20240412.tar.gz
Algorithm Hash digest
SHA256 3caa0e4a43cb5f4d7ead6f7eb6eedb08a9ad14c0c1b1cc7081e4f981e6d85455
MD5 083f7a6d29ca1e54dde593f9740f9851
BLAKE2b-256 9edd6617a0040bb5f1896d15c115260a3868b692862f59d23f3e62d11922667a

See more details on using hashes here.

File details

Details for the file ews_core_config-20240412-py3-none-any.whl.

File metadata

File hashes

Hashes for ews_core_config-20240412-py3-none-any.whl
Algorithm Hash digest
SHA256 529fc03be9b7df9b506e01b2a8f36d6d2c60ebcb9b96e138ac22856ec6e291d0
MD5 291630645dfa4e360174d030fa42fdbe
BLAKE2b-256 d72bc6ffde4f9c1a2e4a768e98817501de2bdb20e668ef72d3698f2bcb38da08

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page