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 .ews_config.toml file in your home directory.

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 environnement 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 environnement variables.

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-20240301.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

ews_core_config-20240301.4-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file ews-core-config-20240301.4.tar.gz.

File metadata

  • Download URL: ews-core-config-20240301.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for ews-core-config-20240301.4.tar.gz
Algorithm Hash digest
SHA256 896db856fa5f5cfbf437ee1e2816034946e5031282f9dbcaf28f12666c3fcf42
MD5 c6d11ca0a63030ffe468ceb57a74f63f
BLAKE2b-256 f44c1a9cdf2f03009a268a3e5fd2a9bfca39764a353953edcdcf1be76b93d529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ews_core_config-20240301.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8b46b4b56ef477b8d991139695e3bdd2c7cc4b0f3700ce454d6232ce5d9854f0
MD5 ee47c847e1a35819beb67a83373d8ad0
BLAKE2b-256 e789da6fb21b6471071d563d1667b73c429b92c10b859a28beec349f38072bc6

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