Feature request: custom merge logic or variables
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
Piste de recherche
Start with the dotenv methods that accept the existing override parameter and trace how values from .env are applied to the environment. Define how a variable-to-callable API would coexist with current override and non-override behavior, using the LD_LIBRARY_PATH example as the target case. Done means custom merge logic can extend and normalize a colon-separated value without changing existing defaults.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Hello, this is a feature request for enabling custom merge logic when the environment variables are updated with values read from .env file.
My use case is that I would like to append an element to a colon-separated list of paths. Typical colon-separated environment variables are PATH or LD_LIBRARY_PATH. So the reading of the .env file should neither override, nor leave the original environment variables, instead it should extend the list.
Currently I use the following pseudo-code for this:
cfg = dotenv_values()
path_elems = []
if 'LD_LIBRARY_PATH' in os.environ:
path_elems.extend(os.environ['LD_LIBRARY_PATH'].split(':'))
if 'LD_LIBRARY_PATH' in cfg:
path_elems.append(cfg['LD_LIBRARY_PATH'])
path_elems = list(OrderedDict.fromkeys(path_elems)) # remove duplicates
path = ':'.join(path_elems)
path = path.replace('::', ':') # remove empty elements
os.environ['LD_LIBRARY_PATH'] = path
I think such logic could be integrated into the dotenv library. This would require changing the API: instead of / apart the override parameter the dotenv methods could take a variable name -> callable dictionary, where the callable would take as parameters the current and the new value and handle the merge logic for the specified variable. Senseful default behavior could be configured to simulate the current override/not override functionality.
- Langage dominant
- Python
- Étoiles
- 8.9k
- Forks
- 581
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de theskumar/python-dotenv
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
theskumar/python-dotenv#699 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
theskumar/python-dotenv#697 ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 28/100
theskumar/python-dotenv#693 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
theskumar/python-dotenv#683 · 4 commentaires ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
theskumar/python-dotenv#644 · 2 commentaires ·
Toutes les issues de theskumar/python-dotenv
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
bancolombia/sentinel#23 ·
-
test md OuverteCI
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100