Compare commits

..

No commits in common. "develop" and "0.1.0a0" have entirely different histories.

3046 changed files with 1206 additions and 8097 deletions
CHANGELOG.mdpyproject.toml
src/rougail/user_data_environment
tests/results
00_0empty
00_0version_underscore
00_1empty_variable
00_2default_calculated
00_2default_calculated_multi
00_2default_calculated_variable_transitive
00_4load_subfolder
00_5load_notype
00_6boolean
00_6boolean_no_mandatory
00_6choice
00_6choice_variable
00_6custom
00_6domainname/errors

View file

@ -1,36 +1,3 @@
## 0.1.0a5 (2025-04-09)
### Fix
- version
## 0.1.0a4 (2025-04-01)
### Fix
- update tests
## 0.1.0a3 (2025-03-30)
### Fix
- update tests
- update tests, some errors are now in warnings level
## 0.1.0a2 (2025-02-10)
### Fix
- rename source
- add test without namespace
- update tests
## 0.1.0a1 (2024-11-27)
### Fix
- NAMESPACE. instead of NAMESPACE_
## 0.1.0a0 (2024-11-25)
### Feat

View file

@ -4,7 +4,7 @@ requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail.user_data_environment"
version = "0.1.0a5"
version = "0.1.0a0"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "Rougail user_data environment"
@ -18,8 +18,6 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Natural Language :: English",
@ -38,9 +36,5 @@ name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "pep440"
version_provider = "pep621"
version_files = [
"src/rougail/user_data_environment/__version__.py",
"pyproject.toml:version"
]
update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -1,6 +1,3 @@
from .data import RougailUserDataEnvironment
from .__version__ import __version__
RougailUserData = RougailUserDataEnvironment
__all__ = ('RougailUserDataEnvironment',)

View file

@ -1 +0,0 @@
__version__ = "0.1.0a5"

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license

View file

@ -2,7 +2,7 @@
Config file for Rougail-user-data-environment
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license
@ -37,8 +37,10 @@ environment:
description: Name of the default environment prefix
default: rougail
disabled:
variable: main_namespace
when_not: null
jinja: |
{% if main_namespace %}
use namespaces
{% endif %}
"""
return {'name': 'environment',
'process': 'user data',

View file

@ -1,6 +1,6 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2025
Copyright (C) 2024
distribued with GPL-2 or later license
@ -21,10 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
from rougail.object_model import CONVERT_OPTION
from rougail.config import RougailConfig
from rougail.error import ExtentionError
from tiramisu.error import ValueOptionError
class RougailUserDataEnvironment:
def __init__(self,
config: 'Config',
@ -42,13 +40,13 @@ class RougailUserDataEnvironment:
user_data = rougailconfig['step.user_data']
self.rougailconfig = rougailconfig
if 'environment' not in user_data:
raise ExtentionError('environment is not set in step.user_data')
raise Exception('environment is not set in step.user_data')
self.errors = []
self.warnings = []
def run(self):
values = self.parse()
return [{'source': 'environment variable',
return [{'source': 'environment',
'errors': self.errors,
'warnings': self.warnings,
'values': values,
@ -59,29 +57,36 @@ class RougailUserDataEnvironment:
def parse(self):
variables = {}
found_ns = False
for option in self.config:
if not option.isoptiondescription() or option.group_type() != "namespace":
break
variables.update(get_rougail_environment(option.name()))
else:
return variables
return get_rougail_environment(None, self.rougailconfig['environment.default_environment_name'])
if option.group_type() == "namespace":
found_ns = True
variables.update(get_rougail_environment(option.name()))
if not found_ns:
if self.rougailconfig['main_namespace'] is None:
return get_rougail_environment(self.rougailconfig['environment.default_environment_name'])
return get_rougail_environment(self.rougailconfig['main_namespace'])
return variables
def get_rougail_environment(namespace, environment_name=None):
def get_rougail_environment(namespace):
"""gets all the rougail environment variables and their values
:sample: {'VARINT': '5', 'VARNAME34': '58, 22', 'VARNAME2': 'tata',
'VARNAME1': 'titi', 'MYFAMILY.VARNAME3': 'spam'}
:returns: rougail environment variables as a key/value dict
"""
# first we look at all environment variables
all_envvar = os.environ
# then we filter the ROUGAIL_ environment variables
if namespace is None:
rougail_environment_var = environment_name.upper() + '_'
len_env = len(rougail_environment_var)
rougail_environment_var = rougail_default_environment_var.upper() + '_'
len_env = len(rougail_environment_var) + 1
root = ''
else:
rougail_environment_var = namespace.upper() + '.'
len_env = 0
return {envvar[len_env:].lower(): envval
for envvar, envval in os.environ.items()
rougail_environment_var = namespace.upper() + '_'
len_env = len(rougail_environment_var)
root = namespace.lower() + '.'
return {root + envvar[len_env:].lower(): envval
for envvar, envval in all_envvar.items()
if envvar.startswith(rougail_environment_var)}

View file

@ -0,0 +1,3 @@
{
"rougail.var1": "string1"
}

View file

@ -0,0 +1,3 @@
{
"rougail.var1": "string1"
}

View file

@ -0,0 +1,6 @@
{
"errors": [
"\"1\" est une valeur invalide pour l'option \"rougail.var6 (the sixth variable)\" de type choice, seul \"1\", \"2\" et \"3\" sont autoris\u00e9es"
],
"warnings": []
}

Some files were not shown because too many files have changed in this diff Show more