Skip to main content

Application-Profiles

This project brings (at least partially) the ability of providing properties files like Spring Framework but now in whatever Python context.

How to use it

pip install application-profiles

Import

from application_profiles import ApplicationProfiles
...
profiles = ApplicationProfiles()
...
a_prop :ApplicationProfiles = profiles.properties['a_prop']

Select the desired profile(s) by using Environment Variable

One profile

export APP_PROFILES=dev

List of profile

export APP_PROFILES=dev,red,south

Select the desired profile(s) by constructor argument

One profile

profiles = ApplicationProfiles(profiles="dev")

List of profile

profiles = ApplicationProfiles(profiles="dev,red,south")

How it work?

'profiles' Python module

Before moving on, there are several requirements to accomplish, the first one is having in the root of your project a module called profiles, where your properties files will be placed. Like this

profiles/
    __init__.py
    application.yaml
    application-dev.yaml
    ...

Properties Files

Inside the profiles module, you must place all the properties files to be included in your project. There is a convention required to name them, like in Spring, the prefix of all the files must be application followed by the name of the desired profile, like for example dev, test etc., joined by a hyphen -, here you go a list of common examples

  • application-dev.yaml
  • application-prod.yaml
  • application-int.yaml

Important

The default profile is application.yaml (without a profile name), this file is optional but it is consedered the "default" profile.

Load Precedence

This is something crucial for the library, there is a precedence in how the files are loaded. The profiles files are loaded in the following order:

1.- default profile.

2.- All the profiles in the provided order by the profile constructor argument.

3.- All the profiles in the provided order by the APP_PROFILES environment variable.

Properties are merged in that order, then they are consumables through the ApplicationProfiles object.

How the properties are merged?

This point is extremely important, because there are a couple of restrictions in how this library works

  • Lists : if there is a variable in more than one profile that contains a list, it is replaced entirely with the corresponding value.

  • Dictionaries: all dictionaries are scanned in deep replacing coincidences for native raw data types like numbers, strings, booleans. It includes nested dictionaries.

Run it in local

This project uses Poetry , in case you don't have it just run make install-poetry

Create a local env & Install dependencies*

make install

Run the Tests Suite

make test

Metadata

Release files for application-profiles 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for application-profiles 0.2.0
File Interpreter ABI Platform
application_profiles-0.2.0-py3-none-any.whl Python 3 none any Details

Release files / application_profiles-0.2.0-py3-none-any.whl

Download URL application_profiles-0.2.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df36ed2a6cbcb5e677c2c38ac53530fba0c93ac3d2467ad324b5aeae93e61efc
BLAKE2b-256 checksum
How to use checksums
51ec83911b61a57bb0f1715dc66aca6145ea8bff32932012a6b404b6a35594c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1015-azure

Security for application-profiles 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page