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

Uploaded Source

Built Distribution

ews_core_config-20240310-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ews-core-config-20240310.tar.gz
  • Upload date:
  • Size: 10.4 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-20240310.tar.gz
Algorithm Hash digest
SHA256 2fb893a1253c2e7302d57c6b73d9022d0f6d833ac15acc4a5cd9d75b2456a817
MD5 24b958b27abd7b5a46e950aa020e06a6
BLAKE2b-256 630a7e275f573e92b31f3eeaeecce02089d68eb90d8376ea380f183b50dcba6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ews_core_config-20240310-py3-none-any.whl
Algorithm Hash digest
SHA256 d7dccefa3e3833267ea72a86a4680c0f353180a109b0bb876b07dcd09f5ef12e
MD5 f156f89efbc62d508860e55a225e8f56
BLAKE2b-256 bca6092ebd3d512a5486b6cc142e7281d4a91062a0fba6aad29934bdd2ec4c1f

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