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

pip install ews-core-config

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):
    import ews_core_config # noqa
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 EWSSettings from the module.

from ews_core_config import EWSSettings
username = WSSettings.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.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

ews_core_config-20240301.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ews-core-config-20240301.1.tar.gz
  • Upload date:
  • Size: 6.9 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.1.tar.gz
Algorithm Hash digest
SHA256 66a8d277ebbd6725a575762b5bdd7ed9e253bd4a9416c8d45f7c67b911e9626d
MD5 adfd2818fb83bfafb5b9be0f27e3f3c7
BLAKE2b-256 81e8ed3eeb851e6ff406aba075d2bcb00e8d17e9fbb63aef8af5e93a444ec85d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ews_core_config-20240301.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e4e1325d8d289ddda9e11af486eb1f0fb6dbe6064ad02cdc52c7918fa3876d7
MD5 b576a3ec5f42d0085569c9c6ea27b5a3
BLAKE2b-256 c8c1542f9413257d6b7b82d325d48514a3c42a745972e31e999814b3955a37c5

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