Compare commits

..

349 commits

Author SHA1 Message Date
gwen
5c22f47547 docs(tutorial): fix
broken links
2026-06-21 10:56:15 +02:00
eb569a8705 fix: 2026-06-21 09:42:02 +02:00
be4162d603 doc: fix 2026-06-21 09:22:55 +02:00
gwen
ebdeeec3af docs(tutorial): modes
ready for proofreading
2026-06-20 22:09:33 +02:00
gwen
dad13466be docs(tutorial): modes 2026-06-20 19:25:10 +02:00
2c50bc60c8 doc: redefine 2026-06-20 14:32:35 +02:00
abb0ec7063 fix: mode 2026-06-20 10:32:36 +02:00
gwen
26362769ac docs(tutorial): namespaces
add multiple namespaces foxyproxy use case
2026-06-19 16:41:35 +02:00
f134e96257 fix: 2026-06-19 07:38:02 +02:00
gwen
afa1cf3493 docs(consitency-definition): proof reading structured data and attempt to set a correct definition 2026-06-19 07:16:56 +02:00
b9ed3235a5 doc: requirements.txt 2026-06-19 05:36:16 +02:00
4440c96b6d doc: requirements.txt 2026-06-18 07:41:58 +02:00
8103ff2ff4 doc(update requirements) 2026-06-16 08:38:37 +02:00
2557e9e2da doc(calculation) 2026-06-15 22:15:09 +02:00
3be1324da3 fix(validation) 2026-06-15 19:32:28 +02:00
2e826db3f4 doc(tutorial): redefine + regexp + auto_save 2026-06-14 21:45:36 +02:00
a71a68a02a doc(rename) 2026-06-14 09:41:53 +02:00
200a05f942 docs: add tutorial/variable_propertyerror.rst 2026-06-14 06:31:13 +02:00
4c812ae299 docs(propertyerror) 2026-06-13 21:43:41 +02:00
215827f288 docs(fix): data_integrity 2026-06-13 19:25:47 +02:00
335e971aea docs(fix): sequence 2026-06-13 19:16:24 +02:00
c733743048 doc(practice2) 2026-06-13 17:59:59 +02:00
3a32dd15af doc(practice2) 2026-06-13 17:43:57 +02:00
gwen
a621c1ed23 docs(sequence): multiple values
ready for proofreading
2026-06-13 17:11:27 +02:00
gwen
d73e0ee259 docs(sequence): fix
forgot that I have defined the term
2026-06-13 10:28:42 +02:00
gwen
c15ed38624 docs(sequence;data-integrity): sequence: remove fixme; data integrity : consitency and coherence 2026-06-13 09:39:07 +02:00
gwen
37f146e314 docs(namespace): foxyproxy namespace 2026-06-12 16:43:54 +02:00
gwen
7200b16fa1 docs(fix): sequence
wrong url
2026-06-11 18:35:12 +02:00
gwen
4ba57ca6d6 docs(tutorial-190-sequence): homogeneous elements sequence 2026-06-11 17:59:32 +02:00
gwen
e6c46fcd1b docs(fix): typo, format_content/index, rename in tutorial/index 2026-06-11 16:16:24 +02:00
gwen
ccbd056c80 docs(fix): typo 2026-06-11 14:55:14 +02:00
4cad2ce30f doc(rename) 2026-06-10 22:32:44 +02:00
gwen
570b22525b docs(refactoring): refactoring indexes (continuation) 2026-06-10 21:59:10 +02:00
a18a39425d doc(fix): user_datas => user_data 2026-06-10 21:14:02 +02:00
53c3cf316f doc: leadership => sequence 2026-06-10 21:06:46 +02:00
gwen
2508087841 docs(refactoring): refactoring indexes 2026-06-10 20:11:15 +02:00
gwen
01504bb244 docs(fix): proofreading 2026-06-10 19:50:21 +02:00
gwen
623d6ce584 docs(fix): add term structure file != structured file 2026-06-10 15:36:45 +02:00
bcf4ff16ff doc(refactoring) 2026-06-10 08:38:49 +02:00
gwen
84286156ba docs(fix): typo 2026-06-09 11:29:51 +02:00
gwen
383c485c7a docs(structured-data): proofreading 2 2026-06-08 21:59:52 +02:00
gwen
c50ce5bcc5 docs(structured-data): proofreading 2026-06-08 18:48:12 +02:00
5386fa5178 doc: 2026-06-08 11:43:51 +02:00
40dadd6cba doc(improvement) 2026-06-07 21:08:47 +02:00
fa2297ec88 doc(user data and output) 2026-06-06 23:22:00 +02:00
64d0bfa802 doc: datas => data 2026-06-06 20:28:11 +02:00
efcdc496ec doc(condition) 2026-06-06 19:23:24 +02:00
gwen
6a641af563 docs(path): relative and full path proofreading 2026-06-06 19:07:58 +02:00
c324ac8913 doc(path): define relative path 2026-06-06 17:54:09 +02:00
gwen
ba8d3939fe docs(doc-design): underline role 2026-06-06 17:29:46 +02:00
gwen
d0bc7eabc7 docs(structured_data): proofreading 2026-06-06 13:05:58 +02:00
a2804aacf6 doc(data documentation) 2026-06-06 12:11:56 +02:00
gwen
5c415fcac6 docs(sphinx-extension): sphinxnotes 2026-06-06 09:50:30 +02:00
gwen
a923f496a0 docs(devnotes): precommit 2026-06-06 09:34:17 +02:00
322f1acd98 doc(structured data concepts) 2026-06-06 08:12:07 +02:00
3b6fa2630b code(VaC): complet the explaination 2026-06-05 22:25:34 +02:00
gwen
d92fd177a8 docs(concepts-vac): proofreading 2026-06-05 16:57:41 +02:00
gwen
8696821442 docs(VaC-Concepts): def of VaC 2026-06-05 15:19:18 +02:00
gwen
13738fd4bf docs(vac): VaaC definition 2026-06-05 14:55:05 +02:00
gwen
7b58d9a774 docs(namespace): typos 2026-06-05 10:22:04 +02:00
gwen
b259da3aef docs(namespace): link 2026-06-05 09:47:59 +02:00
786eda74ce doc(vac + user data yaml) 2026-06-05 08:36:40 +02:00
484a4ad92c doc: various changes 2026-06-04 20:43:51 +02:00
gwen
9dfdf908f0 docs(namespace-sequence): begining of these two sections 2026-06-04 17:32:36 +02:00
4fb075b451 docs(abstract): tables 2026-06-04 13:33:22 +02:00
gwen
fc480ef248 docs(concepts): fix typo 2026-06-04 12:18:04 +02:00
gwen
009136fa10 docs(doc-build): update requirements for the html build 2026-06-04 11:57:18 +02:00
gwen
66bf59fe58 docs(concepts): proofreading 2026-06-04 11:40:15 +02:00
gwen
9f28248903 docs(concepts): concepts page proofreading 2026-06-04 11:26:47 +02:00
gwen
26b5d8dd10 docs(Tiramisu): tiramisu page proofreading 2026-06-04 11:10:06 +02:00
f89fb5ac7f docs(abstract): properties, .. 2026-06-04 08:27:11 +02:00
5be6baab1a docs(abstract): rewrite 2026-06-03 22:41:14 +02:00
gwen
311b046f2b docs(validator-170): ready for proofreading 2026-06-03 21:57:51 +02:00
gwen
441260bea3 docs(132-practice-url-error): and validators continuation 2026-06-03 21:03:57 +02:00
3372d45abc docs(validators): fix titles 2026-06-03 18:01:27 +02:00
gwen
800a61bbf4 docs(documentation-standards): detailled use of sphinx 2026-06-03 09:56:44 +02:00
gwen
af513c6608 docs(commitizen-pyproject): restore the old pyproject.toml 2026-06-03 08:17:58 +02:00
gwen
838a3c70e7 docs(170-validators): begining (not ready) 2026-06-02 13:47:05 +02:00
gwen
c36830d258 docs(fix-typo): column number error row 12 in the list-table 2026-06-02 12:03:38 +02:00
gwen
af57c8349c docs(release): release procedure with commitizen
add commitizen conf in the pyproject.toml
2026-06-02 11:41:44 +02:00
gwen
7afb2c860c docs(v1.1_210): s/attribute/parameter/ 2026-06-02 09:03:12 +02:00
c72b34cbf9 doc(variable): document variable 2026-06-01 19:47:34 +02:00
gwen
4039e01769 docs(cli): there was some french, translated now 2026-06-01 18:15:25 +02:00
647eb7c45d doc(conflict): sync title 2026-06-01 17:45:41 +02:00
gwen
eb38aefdee docs(underscore_parameter): proofreading2 2026-06-01 17:13:22 +02:00
gwen
2edf7bd91c docs(underscore_parameter): proofreading 2026-06-01 15:05:47 +02:00
gwen
e40ade0b64 docs(proofreading): doc release preparation 2026-06-01 12:36:47 +02:00
c0308145d5 doc(variable): adjust parameters 2026-06-01 08:55:35 +02:00
4756e84d2e doc(family): 2026-05-31 21:22:53 +02:00
2d2adf8972 docs(naming-convention): clarification 2026-05-30 19:49:27 +02:00
6825996918 docs(naming-convention): clarify 2026-05-30 15:51:52 +02:00
gwen
fade50baf5 docs(file-naming-convention): file naming for dynamic families 2026-05-30 11:36:04 +02:00
gwen
bc509a6fcf docs(file-naming): file naming policy reference 2026-05-30 10:36:11 +02:00
gwen
d6dcc712fb docs(multi-help): modifications after proofreading 2026-05-30 08:10:43 +02:00
gwen
93800b558b docs(110-web_address): (fix) add the web address page to the index 2026-05-29 17:41:33 +02:00
gwen
a7af31bb50 docs(split-10X-and-11X): split the web_address type from the multi, following the tuto repo order 2026-05-29 17:38:02 +02:00
gwen
28d2200915 docs(multi-examples): modifications after proofreading 2026-05-29 16:02:09 +02:00
gwen
58900a412b docs(v1.3X-practice): reread first pratice1 revision 2026-05-28 16:05:12 +02:00
b349ac5b1e docs(v1.1_13*): practice 2026-05-27 11:46:05 +02:00
gwen
88b7d46f60 docs(v1.1_121): help string fix 2026-05-22 17:59:46 +02:00
gwen
a44087e3b3 docs(v1.1_121): help string 2026-05-22 17:46:28 +02:00
gwen
f3cd0a03e9 docs(docs(v1.1_120):-examples-parameter): example param next and the multi v1.1_111 default value fix 2026-05-22 16:39:17 +02:00
gwen
bfdb4d3046 docs(v1.1_120): examples parameter 2026-05-22 16:13:48 +02:00
gwen
d7e1794648 docs(v1.1_11): multi variable definition 2026-05-21 15:32:25 +02:00
gwen
f37c8f19d2 docs(v1.1_11*): multi variable definition 2026-05-21 15:13:12 +02:00
gwen
e07e2c618c docs(v1.1_110): conditional disabled non mandatory variable 2026-05-18 21:28:35 +02:00
gwen
8cc24d8ee4 docs(v1.1_100): conditional disabled variable with type web_address 2026-05-18 17:55:43 +02:00
gwen
a2b02a8552 docs(multi): add auto configuration variable 2026-05-18 17:30:02 +02:00
gwen
d339aebd63 docs(nullabe): fix typos 2026-05-14 12:03:26 +02:00
gwen
15bda31c7c docs(fix-404-extinclude-urls): fix urls depending on the new tag structure 2026-05-13 15:33:32 +02:00
gwen
250f63d8e1 doc: fix: nullable 09* 2026-05-13 15:02:35 +02:00
gwen
81c40d6eb2 fix: nullable 091 2026-05-13 12:24:13 +02:00
gwen
65009bb6f7 nullable 2026-05-12 12:04:47 +02:00
gwen
7962c35628 version to tutorial:version: 2026-05-07 17:49:58 +02:00
gwen
820fb9c736 fix: tuto 08* and add tutorial links 2026-05-05 13:37:23 +02:00
gwen
64229f9169 conf 2026-05-04 20:04:57 +02:00
d68641410d fix: maj 2026-05-04 18:28:25 +02:00
06d36d0a36 fix: maj 2026-05-04 18:26:20 +02:00
gwen
3a9545c9cf tiramisu does not take into account an empty family 2026-05-04 16:28:33 +02:00
gwen
40f59e83a6 custom types 084 et 085 2026-05-04 15:57:50 +02:00
fe0488b8d3 fix: 08* 2026-05-02 19:51:11 +02:00
gwen
38fad60219 what's next 2026-05-02 10:53:13 +02:00
gwen
1c91020981 whatsnext 2026-05-02 10:34:38 +02:00
gwen
fed4e414d0 empty family 2026-05-02 10:15:50 +02:00
gwen
f2473f85f8 type definition, end of relecture 2026-05-02 09:48:18 +02:00
gwen
9c0ee92892 type declarations 2026-05-01 12:48:24 +02:00
gwen
2608958574 custom types 81 2026-04-16 12:30:15 +02:00
gwen
00d17badf8 types 80 2026-04-16 11:47:06 +02:00
gwen
c9d32dce9f type definition 2026-04-14 11:01:36 +02:00
gwen
9a834b637b jinja page ok 2026-03-27 19:10:36 +01:00
gwen
186a3269d3 update jinja page 2026-03-27 18:25:53 +01:00
gwen
3293800c4c custom type update 2026-03-23 18:18:24 +01:00
gwen
847205938d update custom type 2026-03-23 17:46:27 +01:00
gwen
5039060012 custom type update 2026-03-21 17:33:46 +01:00
gwen
e840bc5289 begin custom type 2026-03-20 17:55:15 +01:00
gwen
cb425ed7f7 custom types 2026-03-19 16:57:13 +01:00
gwen
c7156ea638 add jinja section 2026-03-18 12:23:04 +01:00
f5f52b176a fix: renommage disabled => properties 2026-03-07 15:58:39 +01:00
e3e9ebac12 fix: renommage domainname => types 2026-03-07 15:35:07 +01:00
7878716ea1 correction git clone 2026-03-07 14:33:09 +01:00
gwen
3bfb517087 jinja ok 2026-02-26 16:36:43 +01:00
gwen
7b5c7b80ec end jinja 2026-02-22 11:46:47 +01:00
gwen
480b5dbafb doc output 2026-02-22 11:08:32 +01:00
gwen
f85d95e599 jinja 2026-02-21 21:50:09 +01:00
gwen
78aa9a057a jinja 2026-02-17 11:03:13 +01:00
gwen
13b77b38f6 jinja 2026-02-16 18:55:51 +01:00
gwen
4585d1aa66 update cli 2026-02-12 11:12:22 +01:00
gwen
887f5794af ok up to dynfam 2026-01-28 16:15:02 +01:00
gwen
c368334d05 corrections 2026-01-28 11:50:37 +01:00
gwen
4f87d9d5b9 all commentaries ok 2026-01-26 09:51:38 +01:00
gwen
096925eba7 modifs dynfam 2026-01-26 09:36:25 +01:00
gwen
9a78088cc6 dynamically built fam 2026-01-23 16:54:36 +01:00
gwen
ed09bfd4ae update dynfam 2026-01-22 18:50:29 +01:00
gwen
10eee79dc2 dynfam 2026-01-22 17:47:24 +01:00
gwen
c08a1fca3a rename 2026-01-21 11:30:33 +01:00
08c6a9e027 fix: requirements.txt 2026-01-21 11:27:37 +01:00
gwen
26a9a7edf9 remarques ok 2026-01-20 12:12:44 +01:00
gwen
9d0f0e9ae9 15 ok 2026-01-20 11:55:47 +01:00
gwen
1e6331f477 commentaires jusqu'au 15 2026-01-19 22:05:27 +01:00
gwen
a346e23af6 calculated comments ok 2026-01-19 14:33:11 +01:00
gwen
9c9c313681 cli.unknown_user_data_error dans la sortie 2026-01-10 09:18:14 +01:00
gwen
2cf3b0e752 update 2 2026-01-10 09:16:00 +01:00
gwen
095f0be622 update 2026-01-10 08:45:20 +01:00
gwen
ff9c0650fc calculated ok 2026-01-09 13:01:49 +01:00
gwen
3823642352 https domainname 2026-01-09 11:27:00 +01:00
gwen
7faf7c4310 disabled/hidden ok 2026-01-08 16:31:33 +01:00
gwen
b1f0e7e3de hidden 2026-01-08 15:47:23 +01:00
gwen
c0a6ef2223 calculated default value ok 2026-01-08 11:48:54 +01:00
gwen
44d848b943 add calculated 040 2026-01-08 10:44:35 +01:00
gwen
6da067f206 typos 2026-01-07 16:42:21 +01:00
gwen
eeba802047 disabled ok 2026-01-06 11:48:15 +01:00
gwen
9f2299ee3e disabled / hidden 2026-01-06 10:41:35 +01:00
gwen
0008d03772 disabled 2026-01-05 13:59:56 +01:00
gwen
d47405c61d disabled family 2025-12-15 08:42:43 +01:00
8b02c79dcc review 2025-12-11 21:45:56 +01:00
gwen
aabc937d1c last review 2025-12-10 08:22:18 +01:00
gwen
fe4e98624a last review 2025-12-10 08:07:34 +01:00
gwen
c850c11e98 derniere relecture 2025-12-10 06:35:17 +01:00
gwen
01c4325b86 2025-12-05 review 2025-12-05 20:30:16 +01:00
gwen
01d99cbd01 domain name ok 2025-12-04 21:27:36 +01:00
gwen
0a10dfbd7d domain name 2025-12-04 20:36:51 +01:00
gwen
b437572de9 choice 2025-12-04 19:30:01 +01:00
gwen
921fc0f481 family -> reviewed 2025-12-04 18:26:08 +01:00
gwen
a9b6a00087 choice.rst -> reviewed 2025-12-04 18:02:32 +01:00
gwen
d9ac902740 preliminary -> reviewed 2025-12-04 18:00:09 +01:00
gwen
b22c1817b9 git switch --detach 2025-12-04 14:21:12 +01:00
gwen
8e2fcd073d debut 040 2025-12-04 14:20:18 +01:00
gwen
9413831037 domainname page ok 2025-12-03 22:12:08 +01:00
gwen
9d5ca18bdc cleaning 2025-12-03 21:13:38 +01:00
gwen
8bc7c9b04d domainname and port ok 2025-12-03 18:58:41 +01:00
gwen
40df27bf90 domain name ok 2025-12-03 15:04:23 +01:00
gwen
65d4440694 push 2025-12-02 11:52:21 +01:00
gwen
be4983e524 domain name type 2025-12-02 11:08:54 +01:00
gwen
920780384d family OK 2025-12-01 21:35:27 +01:00
gwen
e61ff106eb family user value 2025-12-01 20:03:52 +01:00
gwen
cb9b534669 configuration and user data file in preliminary 2025-12-01 18:16:24 +01:00
gwen
50bf8e696d family 2025-11-30 18:22:56 +01:00
gwen
76e59b22dd prerequisites 2025-11-30 10:02:03 +01:00
gwen
4057ef6fc7 prerequisites 2025-11-30 09:41:08 +01:00
gwen
f1af25d11a choice ok 2025-11-27 19:15:02 +01:00
gwen
9ca4f31986 preliminary + choice 2025-11-27 18:26:09 +01:00
gwen
b5c919dc8d familiy 2025-11-27 16:59:21 +01:00
gwen
1364b3b4f2 typo 2025-11-27 11:49:07 +01:00
gwen
2e99a30e38 choice 2025-11-27 11:30:55 +01:00
1cd89747de fix: 2025-11-25 07:14:09 +01:00
gwen
22c7472297 preliminary : fist page ok 2025-11-24 16:00:54 +01:00
gwen
778a8f5e48 add image 2025-11-24 13:54:16 +01:00
gwen
7980e9f034 rewrite of the choice type 2025-11-22 13:42:28 +01:00
gwen
dbe78f2334 remote terminal CLI command 2025-11-22 12:57:17 +01:00
gwen
7fc56b2429 separation of the choice 2025-11-22 12:24:54 +01:00
gwen
4da1408c7f typos and wrong urls 2025-11-22 11:27:24 +01:00
gwen
99394348b5 wrong url links 2025-11-22 11:11:45 +01:00
gwen
cb52c774be add modif 2025-11-22 08:08:14 +01:00
gwen
2b0dd5e5bd add extinclude warning in directive 2025-11-22 08:04:51 +01:00
9c2885ce94 fix: update versions 2025-11-21 08:36:39 +01:00
d3bfa99ee4 fix: hidden/disabled 2025-11-19 20:29:56 +01:00
543d33a29b fix: controle acces 2025-11-19 17:41:22 +01:00
6c210f3c33 fix: types 2025-11-19 15:57:55 +01:00
1adae63e18 fix: caracteristique.md 2025-11-19 12:31:29 +01:00
gwen
9d6778ce4f unexisting file (need to raise a warning with extinclude) 2025-11-19 07:57:01 +01:00
gwen
f0018fcf93 adding titles corresponding to the git repo tutorial 2025-11-19 07:52:37 +01:00
gwen
043038526d add links tutorial 2025-11-13 16:22:23 +01:00
gwen
20b90f7c70 update requirements.txt 2025-11-08 10:32:32 +01:00
gwen
9d67d93107 installation 2025-11-08 09:50:20 +01:00
gwen
947ae2a029 moving the type definition in the variable's page instead of the tutorial 2025-11-08 09:45:56 +01:00
gwen
55213e18db third party libraries 2025-11-07 22:02:28 +01:00
gwen
638442273b add download links 2025-11-07 17:26:23 +01:00
gwen
a0e556e7c1 added git repo links 2025-11-07 09:05:44 +01:00
aca97a3e92 update link 2025-11-07 06:45:46 +01:00
bc0de749c7 feat: add multi parameters 2025-11-06 21:54:48 +01:00
gwen
9961d1c958 renaming structure files 2025-11-06 11:49:14 +01:00
gwen
8912e6dd63 getting started removal 2025-11-06 11:46:31 +01:00
gwen
f3c3fe4df0 typo 2025-11-05 17:34:12 +01:00
gwen
c378fbbf89 typos 2025-11-05 17:00:19 +01:00
gwen
82b934db02 begin meld getting started and tutorial 2025-11-05 16:38:44 +01:00
gwen
7f4efef0be add link to the rougail-tuto repo 2025-11-05 15:16:45 +01:00
gwen
e511f07932 calculation typos 2025-11-05 10:18:35 +01:00
gwen
e64a89990d diff for dynamic family 2025-11-05 09:47:42 +01:00
gwen
5cc1e50669 typos 2025-11-05 09:38:36 +01:00
gwen
7a20515114 user datas 2025-11-05 08:59:46 +01:00
5b1356970f modifs 2025-11-05 08:30:00 +01:00
bc415deba9 modifs 2025-11-05 06:54:03 +01:00
gwen
6a87c23e2b doc(typo): YAML sphinx coding standards 2025-10-29 17:18:55 +01:00
gwen
42d5762a5f doc(typo): wrong image relative path 2025-10-27 18:22:40 +01:00
gwen
22a5621c5d relative path 2025-10-27 09:20:33 +01:00
9d856f9de0 feat: user_datas/output 2025-10-27 06:50:10 +01:00
2eeedd70e2 feat: start user_datas/output documentation 2025-10-26 22:21:21 +01:00
4bb50361d5 feat: tags 2025-10-26 14:31:48 +01:00
360c97c581 feat: number => integer in documentation 2025-10-26 13:31:47 +01:00
1277cce9d9 feat: library documentation 2025-10-26 13:29:29 +01:00
96975461d0 fix: update rougailconfig parameters 2025-10-26 09:35:55 +01:00
gwen
961cee372e add image 2025-09-29 16:59:25 +02:00
gwen
16af68e9c8 add pages 2025-09-29 16:58:12 +02:00
gwen
6505ac9ab9 jinja calculation 2025-09-19 16:30:07 +02:00
gwen
6b6aeceb6e calcuation and dynamic family 2025-09-18 17:17:02 +02:00
gwen
91112a905a jinja and calculations 2025-09-16 18:51:35 +02:00
gwen
1da10b7970 dynfam and identifier 2025-09-03 15:35:37 +02:00
gwen
15bd2c4986 add dynfam image 2025-07-28 14:50:01 +02:00
gwen
8a7959ed11 dynamic family 2025-07-28 14:49:01 +02:00
gwen
ad80093520 struct file in image 2025-06-26 18:31:01 +02:00
gwen
7e163e56f0 proofreading 2025-06-26 17:53:37 +02:00
gwen
f7701917d0 proofreader 2025-06-26 17:17:06 +02:00
gwen
a3d7258a64 proofreading 2025-06-26 12:54:33 +02:00
gwen
c2e8e3fd5a typos 2025-05-31 14:42:14 +02:00
gwen
8d7dde7bcc boolean type and hidden property 2025-05-31 14:14:19 +02:00
gwen
ad2c9cf2ce calculated default value 2025-05-27 15:57:30 +02:00
gwen
0293d4d455 contexte 2025-05-27 15:33:32 +02:00
gwen
dd0ae7d03b hidden property 2025-05-27 11:03:29 +02:00
gwen
e49f731aa2 disabled/hidden 2025-05-26 22:09:29 +02:00
gwen
284a176a0a boolean var 2025-05-14 13:17:08 +02:00
gwen
edde6e2a85 diabled property 2025-05-14 10:59:17 +02:00
gwen
3aed61cdb1 disabled 2025-05-06 16:49:03 +02:00
gwen
4af0e7cbe2 disabled 2025-05-05 21:39:54 +02:00
gwen
935b33d28e modifs 2025-05-05 21:39:32 +02:00
gwen
91ffd19336 typos 2025-02-21 20:26:08 +01:00
gwen
fce54f7c84 disable 2025-02-21 17:31:26 +01:00
gwen
cfb6017f32 proxymode 2025-02-21 17:14:30 +01:00
gwen
a932d7e1c3 proxymode 2025-02-21 07:23:52 +01:00
gwen
2da85eb0e8 preliminary and proxy mode ok 2025-02-20 14:32:11 +01:00
gwen
9ca27d7f51 proxy mode tutorial 2025-02-20 14:23:34 +01:00
gwen
2d39fe8bad getting started update 2025-02-20 11:35:55 +01:00
gwen
10a25b0cfe dictionary -> structure file 2025-02-09 11:20:36 +01:00
gwen
0f0d955e9f dictionary removed, replaced by structure file 2025-02-09 10:47:48 +01:00
gwen
038cd9429a add distant url for the default value 2025-02-09 10:36:19 +01:00
gwen
cc54cf675f preliminary file in the tutorial ok 2025-02-05 07:18:50 +01:00
gwen
b4efbf1d71 phrases 2025-02-04 22:01:19 +01:00
gwen
28fe83cfb2 css 2025-02-04 21:52:54 +01:00
gwen
6edda03d79 output box css 2025-02-04 21:35:42 +01:00
gwen
55bda5cd8c default value in the tutorial 2025-02-04 16:38:07 +01:00
gwen
543d54144b getting started -> hello world to tutorial 2025-02-04 15:48:49 +01:00
gwen
98f788ee9b modifs 2025-02-03 20:20:15 +01:00
gwen
bf6120f95e confvar 2024-10-28 21:21:56 +01:00
gwen
04f30963f4 family in turorial 2024-10-28 21:08:22 +01:00
gwen
eda0632809 missign rougail-tutorial tags 2024-10-28 15:29:11 +01:00
gwen
c2111fe581 typo 2024-10-21 19:58:35 +02:00
gwen
9870d949b9 typo 2024-10-21 19:56:41 +02:00
gwen
5dc7d2b630 structure files 2024-10-21 19:50:26 +02:00
gwen
fbc0744f61 keypoints 2024-10-21 18:28:34 +02:00
gwen
d7b2e9b521 roles 2024-10-21 15:57:03 +02:00
gwen
5cf4fb16a4 typo 2024-10-21 15:52:28 +02:00
gwen
a0546a137f remove rougail code (suite) 2024-10-21 15:47:41 +02:00
gwen
b1ed2d3aaf remove rougail code 2024-10-21 15:42:52 +02:00
gwen
39f01b36a1 library at the end 2024-10-21 15:25:00 +02:00
gwen
c361629b63 update slides and def 2024-10-21 15:03:34 +02:00
gwen
45b9a5495e delete httpx requirement 2024-10-16 13:25:30 +02:00
gwen
19ecc56316 replace httpx with the requests stdlib 2024-10-16 13:24:14 +02:00
gwen
0ce1550028 tutorial : mode_proxy variable 2024-10-15 18:17:21 +02:00
gwen
cd850f1089 questionary, user data, output 2024-10-15 17:49:26 +02:00
gwen
a310b6f063 typo 2024-10-15 16:55:01 +02:00
gwen
50299203af preliminaries 2024-10-15 15:50:01 +02:00
gwen
080bb9c489 links to the tutorial 2024-10-15 09:20:01 +02:00
gwen
d47011efe4 working dictionary link 2024-10-15 07:31:31 +02:00
gwen
9a84e28765 exticlude directive 2024-10-14 22:51:05 +02:00
gwen
c244a816f3 httpx 2024-10-14 19:28:12 +02:00
gwen
9199631ea5 extinclude attempt 2024-10-14 19:17:44 +02:00
2d02da9939 feat: better errors messages and improvement 2024-10-14 14:14:01 +02:00
06bb8f8fad feat: better debugging 2024-10-14 14:14:01 +02:00
e2eb58664a feat: update upgrade module 2024-10-14 14:14:01 +02:00
2c0763c516 feat: auto add multi for leader 2024-10-14 14:14:00 +02:00
ccb4eff30b Quick definition of an optional parameter variable (#24)
Co-authored-by: gwen <gwenaelremond@free.fr>
Co-authored-by: gwen <gwenael.remond@free.fr>
Co-authored-by: Emmanuel Garette <egarette@silique.fr>
Reviewed-on: #24
Co-authored-by: gremond <gwenael.remond@protonmail.com>
Co-committed-by: gremond <gwenael.remond@protonmail.com>
2024-10-14 14:14:00 +02:00
7bdc39e370 convert integer to string for port variable (#31 and #32)
Reviewed-on: #32
2024-10-14 14:14:00 +02:00
ea93bc55fc copy type/params and multi if default value is a variable calculation (#9, #31 and #34)
Reviewed-on: #34
Co-authored-by: Emmanuel Garette <egarette@silique.fr>
Co-committed-by: Emmanuel Garette <egarette@silique.fr>
2024-10-14 14:14:00 +02:00
ec86795768 fix: type is not always mandatory 2024-10-14 14:14:00 +02:00
810d08822b feat: use suffix in property calculation 2024-10-14 14:14:00 +02:00
83840e329c fix: auto_save in follower is now allowed in tiramisu 2024-10-14 14:14:00 +02:00
1389929371 feat: in structural commandline very is there is conflict alternative name 2024-10-14 14:14:00 +02:00
b21c13fea7 feat(#21): add examples attributes 2024-10-14 14:14:00 +02:00
a827ca2225 feat(#23): define easily a regexoption 2024-10-14 14:14:00 +02:00
75778cb39e corrections 2024-10-14 14:14:00 +02:00
9e614eb7a4 add 'whole' attribute to variable 2024-10-14 14:14:00 +02:00
90ef65dd40 toto 2024-10-14 14:14:00 +02:00
gwen
fd5b702686 add optional param in the schema
ref #22
2024-10-14 14:14:00 +02:00
d4167b1586 user_data is not mandatory if empty 2024-10-14 14:14:00 +02:00
161985ab50 add when and when_not attribute in properties calculation (#29) (#30)
Co-authored-by: Emmanuel Garette <egarette@silique.fr>
Co-authored-by: egarette@silique.fr <egarette@silique.fr>
Co-committed-by: egarette@silique.fr <egarette@silique.fr>
2024-10-14 14:14:00 +02:00
908356495b add information in tiramisu option for doc 2024-10-14 14:14:00 +02:00
eb561f5f52 allow 'variable' in dynamic family in 1.1 2024-10-14 14:14:00 +02:00
539ecc7412 new tiramisu's version 2024-10-14 14:14:00 +02:00
gwen
b39b728a90 pre-commit developer docs 2024-10-14 14:14:00 +02:00
gwen
80e3b73785 tests: tests about version 2024-10-14 14:14:00 +02:00
gwen
a7c862cccd default dictionary yaml format version 2024-10-14 14:14:00 +02:00
e2d62211ec shorthand declaration (#20)
Co-authored-by: Emmanuel Garette <egarette@silique.fr>
Co-authored-by: gwen <gwenaelremond@free.fr>
Reviewed-on: #20
Co-authored-by: gnunux@silique.fr <gnunux@silique.fr>
Co-committed-by: gnunux@silique.fr <gnunux@silique.fr>
2024-10-14 14:14:00 +02:00
9705830e88 Reactive error tests 2024-10-14 14:14:00 +02:00
0a9d1b3014 feat: add relative path support 2024-10-14 14:14:00 +02:00
gwen
4f33b7c7af feat: add default inference for basic types 2024-10-14 14:14:00 +02:00
bdd56d31c8 feat: suffixes in dynamic family should be a jinja function (#5)
Co-authored-by: Emmanuel Garette <egarette@silique.fr>
Co-authored-by: gwen <gwenaelremond@free.fr>
Reviewed-on: #5
Co-authored-by: egarette@silique.fr <egarette@silique.fr>
Co-committed-by: egarette@silique.fr <egarette@silique.fr>
2024-10-14 14:14:00 +02:00
gwen
6f9a981da7 update tutorial 2024-10-14 14:05:23 +02:00
gwen
4c6f451045 explicit link 2024-03-05 14:49:57 +01:00
gwen
fc8c1ecfda typo 2024-03-05 14:49:57 +01:00
gwen
7f7fe5f08f typos 2024-03-05 14:49:57 +01:00
2173 changed files with 13793 additions and 27519 deletions

View file

@ -1,226 +1,3 @@
## 1.2.1 (2026-08-19)
### Fix
- in each layers a dynamic family could be add, so aggregate all of those families
## 1.2.0 (2026-06-21)
### Feat
- add secret_manager information
- tags for family
- leadership => sequence
- add SUPPORTED_VERSION variable
- support leadership inside types
- identifier could be calculated
- check mandatories is now centralized
- cannot use tiramisu_cache directly with commandline
- structural data in a string
- type with dynamic family
- support transitive in properties variable
- load tiramisu objects from cache
- add types support
- better translation
- add "do" extension for jinja2
- add boolean return_type in validators
- can add limit length for a variable
- choice if invalid value or unknown variable in user data is a fatal error or not
- can add name for a tiramisu config
- active warnings for validators
- add tags support
- keep forced_descriptions information (mostly for rougail-output-doc)
- can desactivate isolated namespace feature
- add return_type to property
- remove return_values_not_error and only_default parameter
- user_data can load secret manager values
- add warning class
- for formatter
- **#28**: default value for a calculated variable with an unknown optional variable
- **#26**: cidr and network_cidr type is depreciate
- **#25**: add integer type which will replace number type
- **40**: better conflict error message with dynamic name
- add new get_root_option function
- separate rougail and rougail-base
- can launch UserDatas twice
- add ymlfile names in ConfigError message
- reoganise param conversion + better variable validation
- can link regexp variable
- can link choice variable
- add rougail secret_manager
- can change defaut params for an option
- upgrade is not in formatter
- remove prefix
- move test to a new project rougail-tests
- output could have annotator
- add "exists" attribut for a family
- add force_optional option to allow charging structure even if all variables are not available
### Fix
- black
- do not copy help and tags from types
- dependencies
- dependencies
- python 3.13 support
- we can redefine type of a types child
- for dynamic family, dynamic and variable paramater can be set together
- update tutorial tests
- use mkdtmp for jinja cache
- default params
- None for identifier without value
- add filename where type is used
- auto redefine in type is only for default
- better support for description and type variable inside types
- do not update name
- copy object before modify namespace
- types inside extra namespace
- better support for identifier calculation
- allow calculation with identifier
- rougail-pyproject.toml
- detect if password is set in a forbidden file even if it also in legitimate file
- structurals data in extra could be a simple file
- allow define an addition variable in a type
- better support for secret manager
- leadership and frozen
- secret with follower
- add transition
- types with subfamily
- better custom types support
- issymlinkoption is not available for an optiondescription
- better error messages
- new tiramisu version support
- better error message
- improvment
- better error message
- documentation
- description
- duplicate description
- user_datas => user_data
- disabled choices must not generate error when loaded from .rougailcli.yml
- better rougailconfig copy
- port is a string
- black
- load config leadership
- do not load secrets if not allowed
- update translation
- add test
- name is uncalculated
- translation for property is now in rougail
- error in InformationCalculation errors
- proprerty with unknown variable
- better doc for calculation with unknown variable
- dictionary => structure
- update test
- UserDatas, do now set modified option in second round
- conversion
- user_data better support for follower variable
- upgrade translation
- black
- add_quotes
- tiramisu_display_name could display only description
- use own undefined
- support of default_dictionary_format_version file in tests
- simplify version support
- user_datas support empty directory
- support {{ suffix }} name in 1.1 format version
- do not force use_data usage
- validators for an index
- remove symlink
- update translation
- remove negative_description support
- redefine family in flatten mode
- update tests
- better multi check
- version
- better detection of multi variable in default attribute
- better error message
- correction in namespace calculation
- update tests
- do not raise variable in property with force_optional
- update translation
- strutural step should not be available in commandline
- allow no user_datas installation (for example to generate doc)
- add get remove properties
- we can define structural plugin when generate documentation
- if a variable in user_data not existe, it's no a warnings
- if no description, generate negative_description too
- error messages
- better support of not_for_commandline feature
- add structural_directory
- add path.py
- remove link
- reorganise user_datas
- only change prefix if path is relative
- add user_datas file
- separate UserDatas
- options could be a list
- dynamic variable could be optional
- dynamic variable declare in verion 1.0 has {{ suffix }}
- user_data plugins could have annotator function
- do not modify a dynamic variable if has default value
### Refactor
- **src/rougail/convert/**: split the file
## 1.1.1 (2024-11-06)
### Fix
- upgrade tests
## 1.1.1rc0 (2024-11-06)
### Fix
- update tiramisu dependency
- better user information if a needed package is not installed
- **37**: import doesn't works for some python version
- **36**: format 1.0: suffix attribut must works
- update fr/rougail.mo
## 1.1.0 (2024-11-01)
### Fix
- black
- add changelog_merge_prerelease to commitizen
## 1.1.0rc0 (2024-11-01)
### Feat
- update dependencies
- translation
- in calculation better debugging
- can sort dictionaries in different directories
- suffix to identifier
- better errors messages and improvement
- better debugging
- update upgrade module
- auto add multi for leader
- use suffix in property calculation
- in structural commandline very is there is conflict alternative name
- **#21**: add examples attributes
- **#23**: define easily a regexoption
- add relative path support
- add default inference for basic types
- suffixes in dynamic family should be a jinja function (#5)
- we should be able to customize a new variable type
### Fix
- support for unknown language
- license
- README
- use black
- valid mode even if there is no mode configured
- valid mode if no mode defined
- update tests
- type is not always mandatory
- auto_save in follower is now allowed in tiramisu
## 1.0.2 (2024-01-28) ## 1.0.2 (2024-01-28)
### Fix ### Fix

326
LICENSE
View file

@ -1,165 +1,235 @@
GNU LESSER GENERAL PUBLIC LICENSE GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates Preamble
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions. The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
As used herein, "this License" refers to version 3 of the GNU Lesser The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License, When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL. The precise terms and conditions for copying, distribution and modification follow.
You may convey a covered work under sections 3 and 4 of this License TERMS AND CONDITIONS
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions. 0. Definitions.
If you modify a copy of the Library, and, in your modifications, a "This License" refers to version 3 of the GNU Affero General Public License.
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
The object code form of an Application may incorporate material from A "covered work" means either the unmodified Program or a work based on the Program.
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
document.
4. Combined Works. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
You may convey a Combined Work under terms of your choice that, 1. Source Code.
taken together, effectively do not restrict modification of the The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
document.
c) For a Combined Work that displays copyright notices during The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
execution, include the copyright notice for the Library among subprograms and other parts of the work.
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following: The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
0) Convey the Minimal Corresponding Source under the terms of this The Corresponding Source for a work in source code form is that same work.
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the 2. Basic Permissions.
Library. A suitable mechanism is one that (a) uses at run time All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
You may place library facilities that are a work based on the 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
Library side by side in a single library together with other library No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it 4. Conveying Verbatim Copies.
is a work based on the Library, and explaining where to find the You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
The Free Software Foundation may publish revised and/or new versions 5. Conveying Modified Source Versions.
of the GNU Lesser General Public License from time to time. Such new You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
permanent authorization for you to choose that version for the
Library. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see <http://www.gnu.org/licenses/>.

View file

@ -1,209 +0,0 @@
---
gitea: none
include_toc: true
---
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md)
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="default_structural_format_version" name="default_structural_format_version">default_structural_format_version</a>**<br/>**Ligne de commande** : <br/>-v, --default_structural_format_version<br/>**Variable d'environnement** : DEFAULT_STRUCTURAL_FORMAT_VERSION | Version par défaut du format des fichiers de structure.<br/>Cette valeur n&#x27;est utilisée que si la version n&#x27;est pas définie dans le fichier de structure. | | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choix** : <br/>•&nbsp;1.0<br/>•&nbsp;1.1<br/>•&nbsp;null |
| **<a id="types" name="types">types</a>**<br/>**Ligne de commande** : <br/>--types<br/>**Variable d'environnement** : TYPES | Fichier avec types personnalisés.<br/>Ce fichier contient des types personnalisés au format Rougail pour les fichiers de structure. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>•&nbsp;le nom de fichier peut être une chemin relatif<br/>•&nbsp;le fichier doit exister<br/>•&nbsp;type de fichier autorisé: "directory" et "file". |
| **<a id="functions_files" name="functions_files">functions_files</a>**<br/>**Ligne de commande** : <br/>--functions_files<br/>**Variable d'environnement** : FUNCTIONS_FILES | Fichier avec les fonctions.<br/>Ce fichier contient des filtres et des fonctions Jinja2 supplémentaires utilisables dans les fichiers de structure. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>•&nbsp;le nom de fichier peut être une chemin relatif<br/>•&nbsp;le fichier doit exister<br/>•&nbsp;type de fichier autorisé: "file". |
| **<a id="modes_level" name="modes_level">modes_level</a>**<br/>**Ligne de commande** : <br/>--modes_level<br/>**Variable d'environnement** : MODES_LEVEL | Tous les niveaux de modes valides. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="default_family_mode" name="default_family_mode">default_family_mode</a>**<br/>**Variable d'environnement** : DEFAULT_FAMILY_MODE | Mode par défaut pour une famille. | le premier défini dans "[Tous les niveaux de modes valides](#modes_level)". | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` *`désactivé`*<br/>**Désactivé** : si aucun mode n'est défini dans "[Tous les niveaux de modes valides](#modes_level)". | Ce mode doit être disponible dans "[Tous les niveaux de modes valides](#modes_level)". |
| **<a id="default_variable_mode" name="default_variable_mode">default_variable_mode</a>**<br/>**Variable d'environnement** : DEFAULT_VARIABLE_MODE | Mode par défaut pour une variable. | si la variable "[Tous les niveaux de modes valides](#modes_level)" est définit, la valeur par défaut est le second élément disponible, sinon, le premier. | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` *`désactivé`*<br/>**Désactivé** : si aucun mode n'est défini dans "[Tous les niveaux de modes valides](#modes_level)". | Ce mode doit être disponible dans "[Tous les niveaux de modes valides](#modes_level)". |
| **<a id="base_option_name" name="base_option_name">base_option_name</a>**<br/>**Variable d'environnement** : BASE_OPTION_NAME | Nom de l&#x27;option pour l&#x27;option de base. | baseoption | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` | |
| **<a id="export_with_import" name="export_with_import">export_with_import</a>**<br/>**Variable d'environnement** : EXPORT_WITH_IMPORT | Dans le fichier de cache, ne pas importer Tiramisu et autres dépendances. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` | |
| **<a id="tiramisu_cache" name="tiramisu_cache">tiramisu_cache</a>**<br/>**Variable d'environnement** : TIRAMISU_CACHE | Enregistrer le cache Tiramisu dans le fichier.<br/>Ce fichier contient les instructions Tiramisu utilisé en interne pour charger les variables.<br/>Ce fichier peut être utilisé pour le débogage. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | •&nbsp;le nom de fichier peut être une chemin relatif<br/>•&nbsp;type de fichier autorisé: "file". |
| **<a id="internal_functions" name="internal_functions">internal_functions</a>**<br/>**Variable d'environnement** : INTERNAL_FUNCTIONS | Nom des fonctions internes qu&#x27;il est possible d&#x27;utiliser comme fonction. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="extra_annotators" name="extra_annotators">extra_annotators</a>**<br/>**Variable d'environnement** : EXTRA_ANNOTATORS | Nom des annotators supplémentaires. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="suffix" name="suffix">suffix</a>**<br/>**Variable d'environnement** : SUFFIX | Suffix ajouté pour généré le nom des options. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="force_optional" name="force_optional">force_optional</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--force_optional<br/>•&nbsp;--no-force_optional<br/>**Variable d'environnement** : FORCE_OPTIONAL | Toutes les variables dans un calcul sont optionnelles. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` | |
| **<a id="load_unexist_redefine" name="load_unexist_redefine">load_unexist_redefine</a>**<br/>**Variable d'environnement** : LOAD_UNEXIST_REDEFINE | Charger les variables redéfinis même si elles n&#x27;existe pas. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` | |
## Le gestionnaire de secret
> [!NOTE]
>
> **Chemin** : secret_manager\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|--------------------------------------------------------------------------------------------------|----------------------|
| **<a id="secret_manager.pattern" name="secret_manager.pattern">secret_manager.pattern</a>**<br/>**Ligne de commande** : <br/>--secret_manager.pattern<br/>**Variable d'environnement** : SECRET_MANAGER.PATTERN | Le modèle de secret permettant de construire le nom de l&#x27;élément recherché dans le gestionnaire de secrets.<br/>Le modèle est au format Jinja2. | {{ project }} - {{ environment }} - {{ service }} - {{ user }} | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` |
## Load and exporter steps
> [!NOTE]
>
> **Chemin** : step\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|---------------------|-------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="step.structural" name="step.structural">step.structural</a>**<br/>**Variable d'environnement** : STEP.STRUCTURAL | Sélection pour structure. | •&nbsp;directory | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `obligatoire` | `standard` | `unique`<br/>**Choix** : <br/>•&nbsp;directory<br/>•&nbsp;string<br/>•&nbsp;commandline<br/>•&nbsp;risotto |
| **<a id="step.user_data" name="step.user_data">step.user_data</a>**<br/>**Ligne de commande** : <br/>-u, --step.user_data<br/>**Variable d'environnement** : STEP.USER_DATA | Sélection pour données utilisateur. | | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` *`désactivé`*<br/>**Désactivé** : les sorties "doc" n'autorisent pas des données utilisateur. | `unique`<br/>**Choix** : <br/>•&nbsp;yaml<br/>•&nbsp;environment<br/>•&nbsp;commandline<br/>•&nbsp;ansible<br/>•&nbsp;questionary<br/>•&nbsp;risotto<br/>•&nbsp;bitwarden |
| **<a id="step.output" name="step.output">step.output</a>**<br/>**Ligne de commande** : <br/>-o, --step.output<br/>**Variable d'environnement** : STEP.OUTPUT | Sélection pour sortie. | display | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` | **Choix** : <br/>•&nbsp;display<br/>•&nbsp;json<br/>•&nbsp;doc<br/>•&nbsp;table<br/>•&nbsp;ansible |
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|---------------------|---------------------------------------------------------------------------------------------------|----------------------|
| **<a id="define_default_params" name="define_default_params">define_default_params</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--define_default_params<br/>•&nbsp;--no-define_default_params<br/>**Variable d'environnement** : DEFINE_DEFAULT_PARAMS | Sur charger les paramètre par défaut pour le type d&#x27;option. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `obligatoire` | `standard` |
## Paramètre par défaut pour le type d&#x27;option
> [!NOTE]
>
> **Chemin** : default_params\
> `standard` *`désactivé`*\
> **Désactivé** : when the variable "[Sur charger les paramètre par défaut pour le type d'option](#define_default_params)" a la valeur "false".
### UNIX filename
> [!NOTE]
>
> **Chemin** : default_params.unix_filename\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|----------------------------------|-----------------------------------------------------------------------------------------------|----------------------|----------------------------------------------------------------|
| **<a id="default_params.unix_filename.allow_relative" name="default_params.unix_filename.allow_relative">default_params.unix_filename.allow_relative</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.unix_filename.allow_relative<br/>•&nbsp;--default_params.unix_filename.no-allow_relative<br/>**Variable d'environnement** : DEFAULT_PARAMS.UNIX_FILENAME.ALLOW_RELATIVE | Le nom de fichier peut être une chemin relatif. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.unix_filename.test_existence" name="default_params.unix_filename.test_existence">default_params.unix_filename.test_existence</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.unix_filename.test_existence<br/>•&nbsp;--default_params.unix_filename.no-test_existence<br/>**Variable d'environnement** : DEFAULT_PARAMS.UNIX_FILENAME.TEST_EXISTENCE | Le fichier doit exister. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.unix_filename.types" name="default_params.unix_filename.types">default_params.unix_filename.types</a>**<br/>**Ligne de commande** : <br/>--default_params.unix_filename.types<br/>**Variable d'environnement** : DEFAULT_PARAMS.UNIX_FILENAME.TYPES | Type de fichier autorisé. | •&nbsp;file<br/>•&nbsp;directory | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>**Choix** : <br/>•&nbsp;file<br/>•&nbsp;directory |
### IP
> [!NOTE]
>
> **Chemin** : default_params.ip\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|
| **<a id="default_params.ip.private_only" name="default_params.ip.private_only">default_params.ip.private_only</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.ip.private_only<br/>•&nbsp;--default_params.ip.no-private_only<br/>**Variable d'environnement** : DEFAULT_PARAMS.IP.PRIVATE_ONLY | Les IP privées sont autorisées. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.ip.allow_reserved" name="default_params.ip.allow_reserved">default_params.ip.allow_reserved</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.ip.allow_reserved<br/>•&nbsp;--default_params.ip.no-allow_reserved<br/>**Variable d'environnement** : DEFAULT_PARAMS.IP.ALLOW_RESERVED | Les IP réservées sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.ip.cidr" name="default_params.ip.cidr">default_params.ip.cidr</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.ip.cidr<br/>•&nbsp;--default_params.ip.no-cidr<br/>**Variable d'environnement** : DEFAULT_PARAMS.IP.CIDR | L&#x27;IP doit être au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### CIDR
> [!NOTE]
>
> **Chemin** : default_params.cidr\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|
| **<a id="default_params.cidr.private_only" name="default_params.cidr.private_only">default_params.cidr.private_only</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.cidr.private_only<br/>•&nbsp;--default_params.cidr.no-private_only<br/>**Variable d'environnement** : DEFAULT_PARAMS.CIDR.PRIVATE_ONLY | Les IP privées sont autorisées. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.cidr.allow_reserved" name="default_params.cidr.allow_reserved">default_params.cidr.allow_reserved</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.cidr.allow_reserved<br/>•&nbsp;--default_params.cidr.no-allow_reserved<br/>**Variable d'environnement** : DEFAULT_PARAMS.CIDR.ALLOW_RESERVED | Les IP réservées sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.cidr.cidr" name="default_params.cidr.cidr">default_params.cidr.cidr</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.cidr.cidr<br/>•&nbsp;--default_params.cidr.no-cidr<br/>**Variable d'environnement** : DEFAULT_PARAMS.CIDR.CIDR | L&#x27;IP doit être au format CIDR. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Network
> [!NOTE]
>
> **Chemin** : default_params.network\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|
| **<a id="default_params.network.private_only" name="default_params.network.private_only">default_params.network.private_only</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network.private_only<br/>•&nbsp;--default_params.network.no-private_only<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK.PRIVATE_ONLY | Les réseaux privés sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network.allow_reserved" name="default_params.network.allow_reserved">default_params.network.allow_reserved</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network.allow_reserved<br/>•&nbsp;--default_params.network.no-allow_reserved<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK.ALLOW_RESERVED | Les réseaux réservés sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network.cidr" name="default_params.network.cidr">default_params.network.cidr</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network.cidr<br/>•&nbsp;--default_params.network.no-cidr<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK.CIDR | Le réseau doit être au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Network CIDR
> [!NOTE]
>
> **Chemin** : default_params.network_cidr\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|
| **<a id="default_params.network_cidr.private_only" name="default_params.network_cidr.private_only">default_params.network_cidr.private_only</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network_cidr.private_only<br/>•&nbsp;--default_params.network_cidr.no-private_only<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK_CIDR.PRIVATE_ONLY | Les réseaux privés sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network_cidr.allow_reserved" name="default_params.network_cidr.allow_reserved">default_params.network_cidr.allow_reserved</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network_cidr.allow_reserved<br/>•&nbsp;--default_params.network_cidr.no-allow_reserved<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK_CIDR.ALLOW_RESERVED | Les réseaux réservés sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network_cidr.cidr" name="default_params.network_cidr.cidr">default_params.network_cidr.cidr</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.network_cidr.cidr<br/>•&nbsp;--default_params.network_cidr.no-cidr<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETWORK_CIDR.CIDR | Le réseau doit être au format CIDR. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Netbios
> [!NOTE]
>
> **Chemin** : default_params.netbios\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|-------------------------------------------------------------------------------------------|
| **<a id="default_params.netbios.type" name="default_params.netbios.type">default_params.netbios.type</a>**<br/>**Ligne de commande** : <br/>--default_params.netbios.type<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.TYPE | Type de nom de domaine. | netbios | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choix** : <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.netbios.allow_without_dot" name="default_params.netbios.allow_without_dot">default_params.netbios.allow_without_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.netbios.allow_without_dot<br/>•&nbsp;--default_params.netbios.no-allow_without_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.ALLOW_WITHOUT_DOT | Le nom de domaine peut être un nom d&#x27;hôte. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.test_existence" name="default_params.netbios.test_existence">default_params.netbios.test_existence</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.netbios.test_existence<br/>•&nbsp;--default_params.netbios.no-test_existence<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.TEST_EXISTENCE | Le nom de domaine doit exister. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_ip" name="default_params.netbios.allow_ip">default_params.netbios.allow_ip</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.netbios.allow_ip<br/>•&nbsp;--default_params.netbios.no-allow_ip<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.ALLOW_IP | Le nom de domaine peut être une IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_cidr_network" name="default_params.netbios.allow_cidr_network">default_params.netbios.allow_cidr_network</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.netbios.allow_cidr_network<br/>•&nbsp;--default_params.netbios.no-allow_cidr_network<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.ALLOW_CIDR_NETWORK | Le nom de domaine peut être un réseau au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_startswith_dot" name="default_params.netbios.allow_startswith_dot">default_params.netbios.allow_startswith_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.netbios.allow_startswith_dot<br/>•&nbsp;--default_params.netbios.no-allow_startswith_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.NETBIOS.ALLOW_STARTSWITH_DOT | Le nom de domaine peut démarré par un point. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Domainname
> [!NOTE]
>
> **Chemin** : default_params.domainname\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|-------------------------------------------------------------------------------------------|
| **<a id="default_params.domainname.type" name="default_params.domainname.type">default_params.domainname.type</a>**<br/>**Ligne de commande** : <br/>--default_params.domainname.type<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.TYPE | Type de nom de domaine. | domainname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choix** : <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.domainname.allow_without_dot" name="default_params.domainname.allow_without_dot">default_params.domainname.allow_without_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.domainname.allow_without_dot<br/>•&nbsp;--default_params.domainname.no-allow_without_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.ALLOW_WITHOUT_DOT | Le nom de domaine peut être un nom d&#x27;hôte. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.test_existence" name="default_params.domainname.test_existence">default_params.domainname.test_existence</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.domainname.test_existence<br/>•&nbsp;--default_params.domainname.no-test_existence<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.TEST_EXISTENCE | Le nom de domaine doit exister. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_ip" name="default_params.domainname.allow_ip">default_params.domainname.allow_ip</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.domainname.allow_ip<br/>•&nbsp;--default_params.domainname.no-allow_ip<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.ALLOW_IP | Le nom de domaine peut être une IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_cidr_network" name="default_params.domainname.allow_cidr_network">default_params.domainname.allow_cidr_network</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.domainname.allow_cidr_network<br/>•&nbsp;--default_params.domainname.no-allow_cidr_network<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.ALLOW_CIDR_NETWORK | Le nom de domaine peut être un réseau au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_startswith_dot" name="default_params.domainname.allow_startswith_dot">default_params.domainname.allow_startswith_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.domainname.allow_startswith_dot<br/>•&nbsp;--default_params.domainname.no-allow_startswith_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.DOMAINNAME.ALLOW_STARTSWITH_DOT | Le nom de domaine peut démarré par un point. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Hostname
> [!NOTE]
>
> **Chemin** : default_params.hostname\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|-------------------------------------------------------------------------------------------|
| **<a id="default_params.hostname.type" name="default_params.hostname.type">default_params.hostname.type</a>**<br/>**Ligne de commande** : <br/>--default_params.hostname.type<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.TYPE | Type de nom de domaine. | hostname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choix** : <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.hostname.allow_without_dot" name="default_params.hostname.allow_without_dot">default_params.hostname.allow_without_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.hostname.allow_without_dot<br/>•&nbsp;--default_params.hostname.no-allow_without_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.ALLOW_WITHOUT_DOT | Le nom de domaine peut être un nom d&#x27;hôte. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.test_existence" name="default_params.hostname.test_existence">default_params.hostname.test_existence</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.hostname.test_existence<br/>•&nbsp;--default_params.hostname.no-test_existence<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.TEST_EXISTENCE | Le nom de domaine doit exister. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_ip" name="default_params.hostname.allow_ip">default_params.hostname.allow_ip</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.hostname.allow_ip<br/>•&nbsp;--default_params.hostname.no-allow_ip<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.ALLOW_IP | Le nom de domaine peut être une IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_cidr_network" name="default_params.hostname.allow_cidr_network">default_params.hostname.allow_cidr_network</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.hostname.allow_cidr_network<br/>•&nbsp;--default_params.hostname.no-allow_cidr_network<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.ALLOW_CIDR_NETWORK | Le nom de domaine peut être un réseau au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_startswith_dot" name="default_params.hostname.allow_startswith_dot">default_params.hostname.allow_startswith_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.hostname.allow_startswith_dot<br/>•&nbsp;--default_params.hostname.no-allow_startswith_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.HOSTNAME.ALLOW_STARTSWITH_DOT | Le nom de domaine peut démarré par un point. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Web address
> [!NOTE]
>
> **Chemin** : default_params.web_address\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès | Validateur |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|-------------------------------------------------------------------------------------------|
| **<a id="default_params.web_address.type" name="default_params.web_address.type">default_params.web_address.type</a>**<br/>**Ligne de commande** : <br/>--default_params.web_address.type<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.TYPE | Type de nom de domaine. | domainname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choix** : <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.web_address.allow_without_dot" name="default_params.web_address.allow_without_dot">default_params.web_address.allow_without_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_without_dot<br/>•&nbsp;--default_params.web_address.no-allow_without_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_WITHOUT_DOT | Le nom de domaine peut être un nom d&#x27;hôte. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.test_existence" name="default_params.web_address.test_existence">default_params.web_address.test_existence</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.test_existence<br/>•&nbsp;--default_params.web_address.no-test_existence<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.TEST_EXISTENCE | Le nom de domaine doit exister. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_ip" name="default_params.web_address.allow_ip">default_params.web_address.allow_ip</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_ip<br/>•&nbsp;--default_params.web_address.no-allow_ip<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_IP | Le nom de domaine peut être une IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_cidr_network" name="default_params.web_address.allow_cidr_network">default_params.web_address.allow_cidr_network</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_cidr_network<br/>•&nbsp;--default_params.web_address.no-allow_cidr_network<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_CIDR_NETWORK | Le nom de domaine peut être un réseau au format CIDR. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_startswith_dot" name="default_params.web_address.allow_startswith_dot">default_params.web_address.allow_startswith_dot</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_startswith_dot<br/>•&nbsp;--default_params.web_address.no-allow_startswith_dot<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_STARTSWITH_DOT | Le nom de domaine peut démarré par un point. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_range" name="default_params.web_address.allow_range">default_params.web_address.allow_range</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_range<br/>•&nbsp;--default_params.web_address.no-allow_range<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_RANGE | Peut être une plage de port. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_protocol" name="default_params.web_address.allow_protocol">default_params.web_address.allow_protocol</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_protocol<br/>•&nbsp;--default_params.web_address.no-allow_protocol<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_PROTOCOL | Peut avoir le protocole. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_zero" name="default_params.web_address.allow_zero">default_params.web_address.allow_zero</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_zero<br/>•&nbsp;--default_params.web_address.no-allow_zero<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_ZERO | Port 0 est autorisé. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_wellknown" name="default_params.web_address.allow_wellknown">default_params.web_address.allow_wellknown</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_wellknown<br/>•&nbsp;--default_params.web_address.no-allow_wellknown<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_WELLKNOWN | Les ports connus (1 à 1023) sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_registred" name="default_params.web_address.allow_registred">default_params.web_address.allow_registred</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_registred<br/>•&nbsp;--default_params.web_address.no-allow_registred<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_REGISTRED | Les ports enregistrés (1024 à 49151) sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_private" name="default_params.web_address.allow_private">default_params.web_address.allow_private</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.web_address.allow_private<br/>•&nbsp;--default_params.web_address.no-allow_private<br/>**Variable d'environnement** : DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_PRIVATE | Les ports privés (supérieur à 49152) sont autorisés. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Port
> [!NOTE]
>
> **Chemin** : default_params.port\
> `standard`
| Variable | Description | Valeur par défaut | Type | Contrôle des accès |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|---------------------|-------------------------------------------------------------------------------------|----------------------|
| **<a id="default_params.port.allow_range" name="default_params.port.allow_range">default_params.port.allow_range</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_range<br/>•&nbsp;--default_params.port.no-allow_range<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_RANGE | Peut être une plage de port. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_protocol" name="default_params.port.allow_protocol">default_params.port.allow_protocol</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_protocol<br/>•&nbsp;--default_params.port.no-allow_protocol<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_PROTOCOL | Peut avoir le protocole. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_zero" name="default_params.port.allow_zero">default_params.port.allow_zero</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_zero<br/>•&nbsp;--default_params.port.no-allow_zero<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_ZERO | Port 0 est autorisé. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_wellknown" name="default_params.port.allow_wellknown">default_params.port.allow_wellknown</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_wellknown<br/>•&nbsp;--default_params.port.no-allow_wellknown<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_WELLKNOWN | Les ports connus (1 à 1023) sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_registred" name="default_params.port.allow_registred">default_params.port.allow_registred</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_registred<br/>•&nbsp;--default_params.port.no-allow_registred<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_REGISTRED | Les ports enregistrés (1024 à 49151) sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_private" name="default_params.port.allow_private">default_params.port.allow_private</a>**<br/>**Ligne de commande** : <br/>•&nbsp;--default_params.port.allow_private<br/>•&nbsp;--default_params.port.no-allow_private<br/>**Variable d'environnement** : DEFAULT_PARAMS.PORT.ALLOW_PRIVATE | Les ports privés (supérieur à 49152) sont autorisés. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |

275
README.md
View file

@ -1,209 +1,104 @@
![Logo Rougail](logo.png "logo rougail")
# Rougail
## Description
Rougail is a free full-featured configuration manager library written in python3.
The configuration is describe in YAML dictionary files.
Those dictionaries are converted into [Tiramisu](https://framagit.org/tiramisu/tiramisu) objects.
Rougail can be incorporated with other technologies and stacks regardless of whether they’re written in Python or not.
## Simple example
Create a directory:
```bash
# mkdir dict
```
## Dictionary
A dictionary is a variables description file.
Create the file `dict/dictionary.yml`:
```yml
--- ---
gitea: none version: '1.0'
include_toc: true # describe a variable my_first_variable
--- # and a family with a variable my_second_variable
[🇬🇧 (EN)](README.md) - [🇫🇷 (FR)](README.fr.md) my_first_variable:
default: my_value
my_family:
my_second_variable:
type: number
mandatory: true
value: 1
```
| Variable | Description | Default value | Type | Access control | Validator | ## Generate variable
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
| **<a id="default_structural_format_version" name="default_structural_format_version">default_structural_format_version</a>**<br/>**Command line**: <br/>-v, --default_structural_format_version<br/>**Environment variable**: DEFAULT_STRUCTURAL_FORMAT_VERSION | Default version of the structural file format.<br/>This value is only used if the version is not set in the structural file. | | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choices**: <br/>•&nbsp;1.0<br/>•&nbsp;1.1<br/>•&nbsp;null |
| **<a id="types" name="types">types</a>**<br/>**Command line**: <br/>--types<br/>**Environment variable**: TYPES | File with personalize types.<br/>This file contains personalize types in Rougail format for structure files. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>•&nbsp;this filename could be a relative path<br/>•&nbsp;this file must exist<br/>•&nbsp;file type allowed: "directory" and "file". |
| **<a id="functions_files" name="functions_files">functions_files</a>**<br/>**Command line**: <br/>--functions_files<br/>**Environment variable**: FUNCTIONS_FILES | File with functions.<br/>This file contains filters and additional Jinja2 functions usable in structure files. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>•&nbsp;this filename could be a relative path<br/>•&nbsp;this file must exist<br/>•&nbsp;file type allowed: "file". |
| **<a id="modes_level" name="modes_level">modes_level</a>**<br/>**Command line**: <br/>--modes_level<br/>**Environment variable**: MODES_LEVEL | All modes level available. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="default_family_mode" name="default_family_mode">default_family_mode</a>**<br/>**Environment variable**: DEFAULT_FAMILY_MODE | Default mode for a family. | the first one defined in "[All modes level available](#modes_level)". | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` *`disabled`*<br/>**Disabled**: when no mode is defined in "[All modes level available](#modes_level)". | This mode must be available in "[All modes level available](#modes_level)". |
| **<a id="default_variable_mode" name="default_variable_mode">default_variable_mode</a>**<br/>**Environment variable**: DEFAULT_VARIABLE_MODE | Default mode for a variable. | if the variable "[All modes level available](#modes_level)" is defined, the default value is the second available element, otherwise, the first. | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` *`disabled`*<br/>**Disabled**: when no mode is defined in "[All modes level available](#modes_level)". | This mode must be available in "[All modes level available](#modes_level)". |
| **<a id="base_option_name" name="base_option_name">base_option_name</a>**<br/>**Environment variable**: BASE_OPTION_NAME | Option name for the base option. | baseoption | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | |
| **<a id="export_with_import" name="export_with_import">export_with_import</a>**<br/>**Environment variable**: EXPORT_WITH_IMPORT | In cache file, do not importation of Tiramisu and other dependencies. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | |
| **<a id="tiramisu_cache" name="tiramisu_cache">tiramisu_cache</a>**<br/>**Environment variable**: TIRAMISU_CACHE | Store Tiramisu cache filename.<br/>This file contains the Tiramisu instructions used internally to load the variables.<br/>This file can be used for debugging. | | [`UNIX filename`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | •&nbsp;this filename could be a relative path<br/>•&nbsp;file type allowed: "file". |
| **<a id="internal_functions" name="internal_functions">internal_functions</a>**<br/>**Environment variable**: INTERNAL_FUNCTIONS | Name of internal functions that we can use as a function. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="extra_annotators" name="extra_annotators">extra_annotators</a>**<br/>**Environment variable**: EXTRA_ANNOTATORS | Name of extra annotators. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique` |
| **<a id="suffix" name="suffix">suffix</a>**<br/>**Environment variable**: SUFFIX | Suffix add to generated options name. | | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="force_optional" name="force_optional">force_optional</a>**<br/>**Command line**: <br/>•&nbsp;--force_optional<br/>•&nbsp;--no-force_optional<br/>**Environment variable**: FORCE_OPTIONAL | Every variables in calculation are optionals. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | |
| **<a id="load_unexist_redefine" name="load_unexist_redefine">load_unexist_redefine</a>**<br/>**Environment variable**: LOAD_UNEXIST_REDEFINE | Loads redefine variables even if there don&#x27;t already exists. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | |
## The secret manager ### With default value:
> [!NOTE] Here is a python3 example file:
>
> **Path**: secret_manager\
> `standard`
| Variable | Description | Default value | Type | Access control | ```python
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------|------------------| from rougail import Rougail, RougailConfig
| **<a id="secret_manager.pattern" name="secret_manager.pattern">secret_manager.pattern</a>**<br/>**Command line**: <br/>--secret_manager.pattern<br/>**Environment variable**: SECRET_MANAGER.PATTERN | The secret pattern to constructing the name of the item searched for in the secret manager.<br/>The pattern is in Jinja2 format. | {{ project }} - {{ environment }} - {{ service }} - {{ user }} | [`string`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | from pprint import pprint
## Load and exporter steps RougailConfig['dictionaries_dir'] = ['dict']
RougailConfig['templates_dir'] = ['tmpl']
RougailConfig['tmp_dir'] = 'tmp'
RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
pprint(config.value.get(), sort_dicts=False)
```
> [!NOTE] The result is:
>
> **Path**: step\
> `standard`
| Variable | Description | Default value | Type | Access control | Validator | ```json
|------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------|------------------|-----------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| {'rougail.my_first_variable': 'my_value',
| **<a id="step.structural" name="step.structural">step.structural</a>**<br/>**Environment variable**: STEP.STRUCTURAL | Select for structural. | •&nbsp;directory | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` `mandatory` | `standard` | `unique`<br/>**Choices**: <br/>•&nbsp;directory<br/>•&nbsp;string<br/>•&nbsp;commandline<br/>•&nbsp;risotto | 'rougail.my_family.my_second_variable': 1}
| **<a id="step.user_data" name="step.user_data">step.user_data</a>**<br/>**Command line**: <br/>-u, --step.user_data<br/>**Environment variable**: STEP.USER_DATA | Select for user datas. | | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` *`disabled`*<br/>**Disabled**: outputs "doc" did not allow user data. | `unique`<br/>**Choices**: <br/>•&nbsp;yaml<br/>•&nbsp;environment<br/>•&nbsp;commandline<br/>•&nbsp;ansible<br/>•&nbsp;questionary<br/>•&nbsp;risotto<br/>•&nbsp;bitwarden | ```
| **<a id="step.output" name="step.output">step.output</a>**<br/>**Command line**: <br/>-o, --step.output<br/>**Environment variable**: STEP.OUTPUT | Select for output. | display | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` | **Choices**: <br/>•&nbsp;display<br/>•&nbsp;json<br/>•&nbsp;doc<br/>•&nbsp;table<br/>•&nbsp;ansible |
| Variable | Description | Default value | Type | Access control | ### With modified value
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------|-------------------------------------------------------------------------------------------------|------------------|
| **<a id="define_default_params" name="define_default_params">define_default_params</a>**<br/>**Command line**: <br/>•&nbsp;--define_default_params<br/>•&nbsp;--no-define_default_params<br/>**Environment variable**: DEFINE_DEFAULT_PARAMS | Override default parameters for option type. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `mandatory` | `standard` |
## Default parameters for option type
> [!NOTE] Use [Tiramisu](https://framagit.org/tiramisu/tiramisu) API to change values:
>
> **Path**: default_params\
> `standard` *`disabled`*\
> **Disabled**: when the variable "[Override default parameters for option type](#define_default_params)" has the value "false".
### UNIX filename ```python
from rougail import Rougail, RougailConfig
from pprint import pprint
> [!NOTE] RougailConfig['dictionaries_dir'] = ['dict']
> RougailConfig['templates_dir'] = ['tmpl']
> **Path**: default_params.unix_filename\ RougailConfig['tmp_dir'] = 'tmp'
> `standard` RougailConfig['destinations_dir'] = 'dest'
rougail = Rougail()
config = rougail.get_config()
config.option('rougail.my_first_variable').value.set('modified_value')
config.option('rougail.my_family.my_second_variable').value.set(2)
pprint(config.value.get(), sort_dicts=False)
```
| Variable | Description | Default value | Type | Access control | Validator | The destination file is generated with new values:
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|----------------------------------|-----------------------------------------------------------------------------------------------|------------------|-----------------------------------------------------------------|
| **<a id="default_params.unix_filename.allow_relative" name="default_params.unix_filename.allow_relative">default_params.unix_filename.allow_relative</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.unix_filename.allow_relative<br/>•&nbsp;--default_params.unix_filename.no-allow_relative<br/>**Environment variable**: DEFAULT_PARAMS.UNIX_FILENAME.ALLOW_RELATIVE | This filename could be a relative path. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.unix_filename.test_existence" name="default_params.unix_filename.test_existence">default_params.unix_filename.test_existence</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.unix_filename.test_existence<br/>•&nbsp;--default_params.unix_filename.no-test_existence<br/>**Environment variable**: DEFAULT_PARAMS.UNIX_FILENAME.TEST_EXISTENCE | This file must exist. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.unix_filename.types" name="default_params.unix_filename.types">default_params.unix_filename.types</a>**<br/>**Command line**: <br/>--default_params.unix_filename.types<br/>**Environment variable**: DEFAULT_PARAMS.UNIX_FILENAME.TYPES | File type allowed. | •&nbsp;file<br/>•&nbsp;directory | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) `multiple` | `standard` | `unique`<br/>**Choices**: <br/>•&nbsp;file<br/>•&nbsp;directory |
### IP ```json
{'rougail.my_first_variable': 'modified_value',
'rougail.my_family.my_second_variable': 2}
```
> [!NOTE] # Link
>
> **Path**: default_params.ip\
> `standard`
| Variable | Description | Default value | Type | Access control | * [Documentation](https://rougail.readthedocs.io/en/latest/)
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|-----------------|-------------------------------------------------------------------------------------|------------------| * [Licence ](LICENSE)
| **<a id="default_params.ip.private_only" name="default_params.ip.private_only">default_params.ip.private_only</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.ip.private_only<br/>•&nbsp;--default_params.ip.no-private_only<br/>**Environment variable**: DEFAULT_PARAMS.IP.PRIVATE_ONLY | Private IP are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.ip.allow_reserved" name="default_params.ip.allow_reserved">default_params.ip.allow_reserved</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.ip.allow_reserved<br/>•&nbsp;--default_params.ip.no-allow_reserved<br/>**Environment variable**: DEFAULT_PARAMS.IP.ALLOW_RESERVED | Reserved IP are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.ip.cidr" name="default_params.ip.cidr">default_params.ip.cidr</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.ip.cidr<br/>•&nbsp;--default_params.ip.no-cidr<br/>**Environment variable**: DEFAULT_PARAMS.IP.CIDR | IP must be in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### CIDR # Related projects
> [!NOTE] * [Tiramisu](https://forge.cloud.silique.fr/gnunux/tiramisu)
> * [Risotto](https://cloud.silique.fr/gitea/risotto/risotto)
> **Path**: default_params.cidr\
> `standard`
| Variable | Description | Default value | Type | Access control |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|
| **<a id="default_params.cidr.private_only" name="default_params.cidr.private_only">default_params.cidr.private_only</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.cidr.private_only<br/>•&nbsp;--default_params.cidr.no-private_only<br/>**Environment variable**: DEFAULT_PARAMS.CIDR.PRIVATE_ONLY | Private IP are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.cidr.allow_reserved" name="default_params.cidr.allow_reserved">default_params.cidr.allow_reserved</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.cidr.allow_reserved<br/>•&nbsp;--default_params.cidr.no-allow_reserved<br/>**Environment variable**: DEFAULT_PARAMS.CIDR.ALLOW_RESERVED | Reserved IP are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.cidr.cidr" name="default_params.cidr.cidr">default_params.cidr.cidr</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.cidr.cidr<br/>•&nbsp;--default_params.cidr.no-cidr<br/>**Environment variable**: DEFAULT_PARAMS.CIDR.CIDR | IP must be in CIDR format. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Network
> [!NOTE]
>
> **Path**: default_params.network\
> `standard`
| Variable | Description | Default value | Type | Access control |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|
| **<a id="default_params.network.private_only" name="default_params.network.private_only">default_params.network.private_only</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network.private_only<br/>•&nbsp;--default_params.network.no-private_only<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK.PRIVATE_ONLY | Private network are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network.allow_reserved" name="default_params.network.allow_reserved">default_params.network.allow_reserved</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network.allow_reserved<br/>•&nbsp;--default_params.network.no-allow_reserved<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK.ALLOW_RESERVED | Reserved network are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network.cidr" name="default_params.network.cidr">default_params.network.cidr</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network.cidr<br/>•&nbsp;--default_params.network.no-cidr<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK.CIDR | Network must be in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Network CIDR
> [!NOTE]
>
> **Path**: default_params.network_cidr\
> `standard`
| Variable | Description | Default value | Type | Access control |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|
| **<a id="default_params.network_cidr.private_only" name="default_params.network_cidr.private_only">default_params.network_cidr.private_only</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network_cidr.private_only<br/>•&nbsp;--default_params.network_cidr.no-private_only<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK_CIDR.PRIVATE_ONLY | Private network are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network_cidr.allow_reserved" name="default_params.network_cidr.allow_reserved">default_params.network_cidr.allow_reserved</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network_cidr.allow_reserved<br/>•&nbsp;--default_params.network_cidr.no-allow_reserved<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK_CIDR.ALLOW_RESERVED | Reserved network are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.network_cidr.cidr" name="default_params.network_cidr.cidr">default_params.network_cidr.cidr</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.network_cidr.cidr<br/>•&nbsp;--default_params.network_cidr.no-cidr<br/>**Environment variable**: DEFAULT_PARAMS.NETWORK_CIDR.CIDR | Network must be in CIDR format. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
### Netbios
> [!NOTE]
>
> **Path**: default_params.netbios\
> `standard`
| Variable | Description | Default value | Type | Access control | Validator |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|--------------------------------------------------------------------------------------------|
| **<a id="default_params.netbios.type" name="default_params.netbios.type">default_params.netbios.type</a>**<br/>**Command line**: <br/>--default_params.netbios.type<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.TYPE | Type of domainname. | netbios | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choices**: <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.netbios.allow_without_dot" name="default_params.netbios.allow_without_dot">default_params.netbios.allow_without_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.netbios.allow_without_dot<br/>•&nbsp;--default_params.netbios.no-allow_without_dot<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.ALLOW_WITHOUT_DOT | The domain name can be a hostname. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.test_existence" name="default_params.netbios.test_existence">default_params.netbios.test_existence</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.netbios.test_existence<br/>•&nbsp;--default_params.netbios.no-test_existence<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.TEST_EXISTENCE | The domain name must exist. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_ip" name="default_params.netbios.allow_ip">default_params.netbios.allow_ip</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.netbios.allow_ip<br/>•&nbsp;--default_params.netbios.no-allow_ip<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.ALLOW_IP | The domain name can be an IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_cidr_network" name="default_params.netbios.allow_cidr_network">default_params.netbios.allow_cidr_network</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.netbios.allow_cidr_network<br/>•&nbsp;--default_params.netbios.no-allow_cidr_network<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.ALLOW_CIDR_NETWORK | The domain name can be network in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.netbios.allow_startswith_dot" name="default_params.netbios.allow_startswith_dot">default_params.netbios.allow_startswith_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.netbios.allow_startswith_dot<br/>•&nbsp;--default_params.netbios.no-allow_startswith_dot<br/>**Environment variable**: DEFAULT_PARAMS.NETBIOS.ALLOW_STARTSWITH_DOT | The domain name can starts by a dot. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Domainname
> [!NOTE]
>
> **Path**: default_params.domainname\
> `standard`
| Variable | Description | Default value | Type | Access control | Validator |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|--------------------------------------------------------------------------------------------|
| **<a id="default_params.domainname.type" name="default_params.domainname.type">default_params.domainname.type</a>**<br/>**Command line**: <br/>--default_params.domainname.type<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.TYPE | Type of domainname. | domainname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choices**: <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.domainname.allow_without_dot" name="default_params.domainname.allow_without_dot">default_params.domainname.allow_without_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.domainname.allow_without_dot<br/>•&nbsp;--default_params.domainname.no-allow_without_dot<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.ALLOW_WITHOUT_DOT | The domain name can be a hostname. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.test_existence" name="default_params.domainname.test_existence">default_params.domainname.test_existence</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.domainname.test_existence<br/>•&nbsp;--default_params.domainname.no-test_existence<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.TEST_EXISTENCE | The domain name must exist. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_ip" name="default_params.domainname.allow_ip">default_params.domainname.allow_ip</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.domainname.allow_ip<br/>•&nbsp;--default_params.domainname.no-allow_ip<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.ALLOW_IP | The domain name can be an IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_cidr_network" name="default_params.domainname.allow_cidr_network">default_params.domainname.allow_cidr_network</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.domainname.allow_cidr_network<br/>•&nbsp;--default_params.domainname.no-allow_cidr_network<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.ALLOW_CIDR_NETWORK | The domain name can be network in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.domainname.allow_startswith_dot" name="default_params.domainname.allow_startswith_dot">default_params.domainname.allow_startswith_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.domainname.allow_startswith_dot<br/>•&nbsp;--default_params.domainname.no-allow_startswith_dot<br/>**Environment variable**: DEFAULT_PARAMS.DOMAINNAME.ALLOW_STARTSWITH_DOT | The domain name can starts by a dot. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Hostname
> [!NOTE]
>
> **Path**: default_params.hostname\
> `standard`
| Variable | Description | Default value | Type | Access control | Validator |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|--------------------------------------------------------------------------------------------|
| **<a id="default_params.hostname.type" name="default_params.hostname.type">default_params.hostname.type</a>**<br/>**Command line**: <br/>--default_params.hostname.type<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.TYPE | Type of domainname. | hostname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choices**: <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.hostname.allow_without_dot" name="default_params.hostname.allow_without_dot">default_params.hostname.allow_without_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.hostname.allow_without_dot<br/>•&nbsp;--default_params.hostname.no-allow_without_dot<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.ALLOW_WITHOUT_DOT | The domain name can be a hostname. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.test_existence" name="default_params.hostname.test_existence">default_params.hostname.test_existence</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.hostname.test_existence<br/>•&nbsp;--default_params.hostname.no-test_existence<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.TEST_EXISTENCE | The domain name must exist. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_ip" name="default_params.hostname.allow_ip">default_params.hostname.allow_ip</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.hostname.allow_ip<br/>•&nbsp;--default_params.hostname.no-allow_ip<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.ALLOW_IP | The domain name can be an IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_cidr_network" name="default_params.hostname.allow_cidr_network">default_params.hostname.allow_cidr_network</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.hostname.allow_cidr_network<br/>•&nbsp;--default_params.hostname.no-allow_cidr_network<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.ALLOW_CIDR_NETWORK | The domain name can be network in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.hostname.allow_startswith_dot" name="default_params.hostname.allow_startswith_dot">default_params.hostname.allow_startswith_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.hostname.allow_startswith_dot<br/>•&nbsp;--default_params.hostname.no-allow_startswith_dot<br/>**Environment variable**: DEFAULT_PARAMS.HOSTNAME.ALLOW_STARTSWITH_DOT | The domain name can starts by a dot. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Web address
> [!NOTE]
>
> **Path**: default_params.web_address\
> `standard`
| Variable | Description | Default value | Type | Access control | Validator |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|--------------------------------------------------------------------------------------------|
| **<a id="default_params.web_address.type" name="default_params.web_address.type">default_params.web_address.type</a>**<br/>**Command line**: <br/>--default_params.web_address.type<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.TYPE | Type of domainname. | domainname | [`choice`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | **Choices**: <br/>•&nbsp;domainname<br/>•&nbsp;netbios<br/>•&nbsp;hostname<br/>•&nbsp;null |
| **<a id="default_params.web_address.allow_without_dot" name="default_params.web_address.allow_without_dot">default_params.web_address.allow_without_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_without_dot<br/>•&nbsp;--default_params.web_address.no-allow_without_dot<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_WITHOUT_DOT | The domain name can be a hostname. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.test_existence" name="default_params.web_address.test_existence">default_params.web_address.test_existence</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.test_existence<br/>•&nbsp;--default_params.web_address.no-test_existence<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.TEST_EXISTENCE | The domain name must exist. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_ip" name="default_params.web_address.allow_ip">default_params.web_address.allow_ip</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_ip<br/>•&nbsp;--default_params.web_address.no-allow_ip<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_IP | The domain name can be an IP. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_cidr_network" name="default_params.web_address.allow_cidr_network">default_params.web_address.allow_cidr_network</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_cidr_network<br/>•&nbsp;--default_params.web_address.no-allow_cidr_network<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_CIDR_NETWORK | The domain name can be network in CIDR format. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_startswith_dot" name="default_params.web_address.allow_startswith_dot">default_params.web_address.allow_startswith_dot</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_startswith_dot<br/>•&nbsp;--default_params.web_address.no-allow_startswith_dot<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_STARTSWITH_DOT | The domain name can starts by a dot. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_range" name="default_params.web_address.allow_range">default_params.web_address.allow_range</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_range<br/>•&nbsp;--default_params.web_address.no-allow_range<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_RANGE | Can be range of port. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_protocol" name="default_params.web_address.allow_protocol">default_params.web_address.allow_protocol</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_protocol<br/>•&nbsp;--default_params.web_address.no-allow_protocol<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_PROTOCOL | Can have the protocol. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_zero" name="default_params.web_address.allow_zero">default_params.web_address.allow_zero</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_zero<br/>•&nbsp;--default_params.web_address.no-allow_zero<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_ZERO | Port 0 is allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_wellknown" name="default_params.web_address.allow_wellknown">default_params.web_address.allow_wellknown</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_wellknown<br/>•&nbsp;--default_params.web_address.no-allow_wellknown<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_WELLKNOWN | Well-known ports (1 to 1023) are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_registred" name="default_params.web_address.allow_registred">default_params.web_address.allow_registred</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_registred<br/>•&nbsp;--default_params.web_address.no-allow_registred<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_REGISTRED | Registred ports (1024 to 49151) are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
| **<a id="default_params.web_address.allow_private" name="default_params.web_address.allow_private">default_params.web_address.allow_private</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.web_address.allow_private<br/>•&nbsp;--default_params.web_address.no-allow_private<br/>**Environment variable**: DEFAULT_PARAMS.WEB_ADDRESS.ALLOW_PRIVATE | Private ports (greater than 49152) are allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` | |
### Port
> [!NOTE]
>
> **Path**: default_params.port\
> `standard`
| Variable | Description | Default value | Type | Access control |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------|-----------------|-------------------------------------------------------------------------------------|------------------|
| **<a id="default_params.port.allow_range" name="default_params.port.allow_range">default_params.port.allow_range</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_range<br/>•&nbsp;--default_params.port.no-allow_range<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_RANGE | Can be range of port. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_protocol" name="default_params.port.allow_protocol">default_params.port.allow_protocol</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_protocol<br/>•&nbsp;--default_params.port.no-allow_protocol<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_PROTOCOL | Can have the protocol. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_zero" name="default_params.port.allow_zero">default_params.port.allow_zero</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_zero<br/>•&nbsp;--default_params.port.no-allow_zero<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_ZERO | Port 0 is allowed. | false | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_wellknown" name="default_params.port.allow_wellknown">default_params.port.allow_wellknown</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_wellknown<br/>•&nbsp;--default_params.port.no-allow_wellknown<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_WELLKNOWN | Well-known ports (1 to 1023) are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_registred" name="default_params.port.allow_registred">default_params.port.allow_registred</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_registred<br/>•&nbsp;--default_params.port.no-allow_registred<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_REGISTRED | Registred ports (1024 to 49151) are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |
| **<a id="default_params.port.allow_private" name="default_params.port.allow_private">default_params.port.allow_private</a>**<br/>**Command line**: <br/>•&nbsp;--default_params.port.allow_private<br/>•&nbsp;--default_params.port.no-allow_private<br/>**Environment variable**: DEFAULT_PARAMS.PORT.ALLOW_PRIVATE | Private ports (greater than 49152) are allowed. | true | [`boolean`](https://rougail.readthedocs.io/en/latest/variable.html#variables-types) | `standard` |

940
caracteristique.md Normal file
View file

@ -0,0 +1,940 @@
---
gitea: none
include_toc: true
---
# Rougail : caractéristiques
Rougail est un outil qui permet de gérer le cycle de vie des variables et de gestion des valeurs de ces variables.
Au moment de la conception de Rougail, il y a eu des choix structurant qui ont défini le fonctionnement de l'outil.
Voici la liste des principales caractéristiques :
## Logiciel libre
Rougail est un logiciel libre (et Open Source) de gestion externe de variables.
Le développement est réalisé de manière ouverte.
Rougail repose sur le logiciel libre Tiramisu comme moteur de contrainte.
Rougail est composé :
- d'un format de description
- d'un projet principal "Rougail" qui :
- charge les fichiers de structures,
- applique les valeurs des données utilisateur,
- représente les variables avec leurs valeurs.
- différents sous projet pour étendre les fonctionnalités de base
- un outil en ligne de commande pour facilité l'utilisation de la bibliothèque.
## Les acteurs
Rougail est destiné a séparer le cycle de vie de la variable entre 3 acteurs :
- l'acteur qui défini les variables
- l'acteur qui adapte les valeurs
- l'acteur qui utilise les variables avec leurs valeurs
Exemples concret d'acteur :
Dans le cadre du déploiement d'une configuration :
- l'intégrateur défini les variables
- l'exploitant adapte les valeurs
- l'installeur utilise les variables avec leurs valeurs
Dans le cadre du développement d'une application :
- le dévelopeur défini les variables
- l'utilisateur adapte les valeurs
- l'application utilise les variables avec leurs valeurs
|------------------------------------------|
| Acteur |
|------------------------------------------|
| défini les variables |
| adapte les valeurs |
| utilise les variables avec leurs valeurs |
|------------------------------------------|
## Cycle de vie des variables
Le but de Rougail est de gérer les variables et plus largement la configuration.
Rougail a pour but de définir les variables puis de gérer tout son cycle de vie.
Dans le cycle de vie d'une variable, on inclut les étapes générique d'une variable (par exemple pour le langage C) :
- déclaration (elles se voient attribuer un nom et un type) ;
- définition (elles se voient affecter leur première valeur) ;
- affectation (elles se voient modifier la valeur de la variable) ;
- lecture (elles se voient utilisent la valeur de la variable) ;
- fin de vie (elles se terminent à la destruction de l'objet).
Mais d'autres notions sont inclusent dans le cycle de vie :
- extension de la déclaration
- la "description" de la variable
- présentation, l'acteur qui adapte les valeurs doit avoir toutes les informations nécessaires pour renseigner les valeurs, c'est ainsi qu'il est possible de généré automatiquement la documentation, le journal des modifications, ...
- autorisations, des propriétés décrivent les contraintes d'accès
- spécialisation, qui décrit l'usage possible d'une variable
Rôle des différents composants Rougail :
Le format permet de décrire :
- la déclaration (nom, type, description, la présentation)
- les autorisations
- la spécialisation
Rougail et ces composants :
- la déclaration (via Tiramisu)
- la présentation
- l'affectation (via Tiramisu)
- la lecture
- la fin de vie
|------------------------------------------|----------------------------|
| Acteur | Cycle de vies |
|------------------------------------------|----------------------------|
| défini les variables | déclaration + présentation |
| adapte les valeurs | affectration |
| utilise les variables avec leurs valeurs | lecture |
| | destruction |
|------------------------------------------|----------------------------|
## Architecture Structurals-UserDatas-Outputs
### Structurals
Les fichiers de "Structures" sont des fichiers au format Rougail dans laquelle toutes les informations du cycle de vie sont définies.
Avoir des données structurées veut dire qu'on peut publier une fois et avoir plusieurs rendus.
Il est important de tout mettre ces informations au même endroit. Ainsi on connaitre toutes les aspects de la variable en lisant ces fichiers.
On y retrouve :
- un schéma
- la définition des contraintes
- des éléments de documentation
- ...
Les variables sont ici mutables, elles peuvent être redéfinit à tout moment.
Ces fichiers sont créées par l'acteur qui défini les variables.
### UserDatas
Une fois la structure définie, il est possible de charger les "Données Utilisateur" (UserDatas). On retrouve plusieurs type de données utilisateurs :
- des fichiers de configuration
- des variables d'environnement
- des sources externes
- des options de lignes de commande
- un formulaire
- ...
Les variables sont ici immuables, par contre les valeurs sont mutables.
Ces sources sont peuplées par l'acteur qui adapte les valeurs.
### Outputs
Ensuite on pourra définir sous quelle forme on veut recueillir l'information (Outputs) :
- un objet Tiramisu
- une extraction JSON
- un export pour l'inventaire Ansible
- de la documetation
- ...
Les variables et les valeurs sont ici immuables.
Voici un exemple concret :
Un intégrateur a besoin d'une variable et défini la défini ainsi (dans le fichier `structure_architecture.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
...
```
L'exploitant défini la valeur de cette variable ainsi (dans le fichier `userdata.yml`) :
```yaml
---
my_variable: a value
```
On désire afficher de manière lisible la configuration :
```bash
rougail -m structure_architecture.yml -u yaml -yf userdata.yml
╭──────── Caption ────────╮
│ Variable Modified value │
╰─────────────────────────╯
Variables:
┗━━ 📓 my_variable: a value ◀ loaded from the YAML file "userdata.yml"
```
|-------------|------------------------------------------|----------------------------|----------|----------|
| Étape | Acteur | Cycle de vies | Variable | Valeur |
|-------------|------------------------------------------|----------------------------|----------|----------|
| Structurals | défini les variables | déclaration + présentation | mutable | |
| UserDatas | adapte les valeurs | affectration | immuable | mutable |
| Outputs | utilise les variables avec leurs valeurs | lecture | immuable | immuable |
| | | destruction | | |
|-------------|------------------------------------------|----------------------------|----------|----------|
### Valeur par défaut
Les variables ont une valeur. Une valeur par défaut est définit à la variable (None ou []) mais il est possible d'en définir une autre.
Il ne faut pas confondre la valeur par défaut ou la/les valeur(s) défini par l'acteur adaptant la configuration.
Par exemple, si je veux définir la variable my_variable en y spécifiant une valeur par défaut (dans le fichier `structure_default.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
default: a default value
...
```
```bash
rougail -m structure_default.yml
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_variable: a default value
```
|-------------|------------------------------------------|----------------------------|----------|----------|
| Étape | Acteur | Cycle de vies | Variable | Valeur |
|-------------|------------------------------------------|----------------------------|----------|----------|
| Structurals | défini les variables | déclaration + présentation | mutable | défaut |
| UserDatas | adapte les valeurs | affectration | immuable | mutable |
| Outputs | utilise les variables avec leurs valeurs | lecture | immuable | immuable |
| | | destruction | | |
|-------------|------------------------------------------|----------------------------|----------|----------|
## Le format : un langage
### DSL (Domain Specific Language)
Contrairement à un langage générique, un langage dédié est conçu pour répondre à un domaine d'application précis.
La description des variables se faire dans des fichiers YAML version 1.2. Le langage de configuration de Rougail permet de décrire tout le cycle de vie de la variable.
### Abstraction déclarative
Les variables sont décrite suivant un modèle déclaratif. Cela signigie que l'utilisateur définit simplement l'état final souhaité de celle-ci. Tiramisu determinera les actions nécessaires pour atteindre cet état.
Dit autrement l'utilisateur défini le schéma des variables qui sera ensuite appliqué de manière déterministe.
### Redéfinition explicite
Les variables peuvent être redéfinis à tout moment (utile notamment lorsqu'on définit des modèles de configuration). Mais la redéfinition d'une variable doit être explicitement déclaré comme tel.
Par exemple, si je veux redéfinir la variable my_variable en y spécifiant une valeur par défaut (dans le fichier `structure_redefine.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
redefine: true
default: a new default value
...
```
```bash
rougail -m structure_default.yml structure_redefine.yml
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_variable: a new default value
```
## Typage
### Type standard
Rougail (et Tiramisu) accepte les types standards suivant :
- string (type par défaut d'une variable)
- integer
- float
- boolean
### Type métier
Mais on va retrouver également tout une série de type métier :
- IP
- domainname
- port
- MAC
- choice
- secret
- ...
Voici quelques exemples (dans le fichier `structure_type.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_integer: 1
my_mail:
type: mail
default: foo@bar.net
my_date:
type: date
default: "2025-11-19"
...
```
```bash
rougail -m structure_type.yml
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┣━━ 📓 my_integer: 1
┣━━ 📓 my_mail: foo@bar.net
┗━━ 📓 my_date: 2025-11-19
```
### Fortement typé
Rougail utilise en interne la bibliothèque Tiramisu. Les variables dans Tiramisu sont fortement typé.
C'est à dire que le chargement des données utilisateur implique une attention sur le type des variables. Pour les données utilisateurs non typées (comme les variables d'environnement), en pré traitement, il y aura une adaptation du type de la valeur.
Par exemple si l'exploitant adapte la valeur de cette variable ainsi (dans le fichier userdata_fort_type.yml :
```yaml
---
my_variable: 1
```
La valeur ne pourra pas être chargée (le type par défaut étant le type "string") :
```bash
rougail -m structure_architecture.yml -u yaml -yf userdata_fort_type.yml
🔔 WARNINGS
┗━━ the value "1" is an invalid string for "my_variable", which is not a string, it will be ignored when loading from the YAML file "userdata.yml"
🛑 ERRORS
┗━━ The following variables are mandatory but have no value:
┗━━ my_variable
```
### Typage dynamique
Au moment de la définition de la structure, le type est dynamique. C'est à dire que l'acteur qui défini la variable peut changé à tout moment le type de la variable.
Par exemple (dans le fichier `structure_redefine_type.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
redefine: true
type: integer
...
```
```bash
rougail -m structure_architecture.yml structure_redefine_type.yml -u yaml -yf userdata_fort_type.yml
╭──────── Caption ────────╮
│ Variable Modified value │
╰─────────────────────────╯
Variables:
┗━━ 📓 my_variable: 1 ◀ loaded from the YAML file "userdata.yml"
```
Par contre, comme l'exemple du typage fort le suggère, l'acteur qui adapte la valeur n'a pas la possiblité de redéfinir le type de la variable.
### Inférence de type
Le type peut être défini explicitement (comme dans le fichier structure_type.yml) ou déduit du typage des variables YAML.
Par exemple la variable avec une valeur par défaut à 1 est une variable de type "integer" (a mettre dans le fichier `structure_inference.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable: 1
...
```
```bash
rougail -m structure_inference.yml
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_variable: 1
```
### Variable "nullable"
Le type "null" (ou "None" en python) n'existe pas dans Rougail. "null" est une valeur. Tous les types peuvent accepter cette valeur, mais par défaut, ce n'est pas le cas.
Voici la déclaration d'une variable avec la valeur par défaut à "null" (dans le fichier `structure_nullable.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
...
```
```bash
rougail -m structure_nullable.yml
🛑 ERRORS
┗━━ The following variables are mandatory but have no value:
┗━━ my_variable
```
En réalité la variable n'est pas accessible lorsque Tiramisu est mode "lecture seule" (ce qui est le cas lors des étapes Outputs par défaut). Lorsqu'on force le mode "lecture écriture" on a bien accès :
```bash
rougail -m structure_nullable.yml --cli.read_write
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_variable: null
```
Pour que notre variable accepte dans tous les cas "null" il faut modifier le fichier de structure comme cela :
```yaml
%YAML 1.2
---
version: 1.1
my_variable:
mandatory: false
...
```
```bash
rougail -m structure_nullable.yml --cli.read_write
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_variable: null
```
### Variable "liste"
La liste n'est pas non plus un type. C'est une propriété d'une variable. Cela signifie qu'une liste ne peut pas contenir des valeurs de plusieurs types.
### Famille objet
Une famille est une variable d'un type particuiler. C'est un conteneur destiné à accueillir des variables.
#### Un objet
Ce qu'on appele "objet" généralement est appeler dans Rougail des "familles". Donc au lieu de déclarer mes variables à la racine, je vais la déclarer dans une famille.
Par exemple dans le fichier `structure_family.yml` je créé un famille my_object qui contient deux variables :
```yaml
%YAML 1.2
---
version: 1.1
my_object:
key1: value1
key2: value2
...
```
Si j'exporte au format JSON j'ai bien un objet :
```bash
rougail -m structure_family.yml -o json
{
"my_object": {
"key1": "value1",
"key2": "value2"
}
}
```
Les familles gèrent l'arborescence. Il est possible de faire des sous-familles.
#### Liste d'objet
Une famille particulière, appeler "leadership" permet d'avoir une liste d'objet identique.
Par exemple si je veux pouvoir créer un nombre non limité d'utilisateur associé à un mot de passe, je ne peux pas passer par des listes, je veux une liste d'objet.
Voici le contenu du fichier `structure_leadership.yml` :
```yaml
%YAML 1.2
---
version: 1.1
users:
type: leadership
username:
type: unix_user
password:
type: secret
...
```
Et le fichier `userdata_leadership.yml` :
```yaml
---
users:
- username: foo
password: SoSecr31
- username: bar
password: SoSecr31
- username: toot
password: SoSecr31
...
```
J'ai bien une liste d'objet :
```bash
rougail -m structure_leadership.yml -u yaml -yf userdata_leadership.yml -o json
{
"users": [
{
"username": "foo",
"password": "SoSecr31"
},
{
"username": "bar",
"password": "SoSecr31"
},
{
"username": "toot",
"password": "SoSecr31"
}
]
}
```
|-------------|------------------------------------------|----------------------------|----------|----------|------------|
| Étape | Acteur | Cycle de vies | Variable | Valeur | Propriétés |
|-------------|------------------------------------------|----------------------------|----------|----------|------------|
| Structurals | défini les variables | déclaration + présentation | mutable | défaut | |
| UserDatas | adapte les valeurs | affectration | immuable | mutable | |
| Outputs | utilise les variables avec leurs valeurs | lecture | immuable | immuable | mandatory |
| | | destruction | | | |
|-------------|------------------------------------------|----------------------------|----------|----------|------------|
## Intégrité des données
L'intégrité des données fait référence au fait que les données doivent être fiables et précises tout au long de leur cycle de vie.
Cela signifie que la valeur doit être :
- de qualité
- adapté au context globale
### Qualité de la donnée
Pour avoir des données de qualité, il faut que l'outil valide la saisie utilisateur.
La première façon de valider la donnée est bien évidement de définir le bon type.
Mais cela ne suffit pas.
#### Paramètres de type
Il existe, pour certains type, un certains nombres de paramètres qui vont pouvoir compléter le typage des variables (dans le fichier `structure_param_type.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_percent:
type: integer
params:
min_integer: 0
max_integer: 100
default:
10
...
```
```bash
rougail -m structure_param_type.yml
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_percent: 10
```
Mais avec une donnée utilisateur invalide, la valeur ne sera pas chargé (dans le fichier `userdata1.yml`) :
```yaml
---
my_percent: 120
```
```bash
rougail -m structure6.yml -u yaml -yf userdata1.yml
🔔 WARNINGS
┗━━ the value "120" is an invalid integer for "my_percent", value must be less than "100", it will be
ignored when loading from the YAML file "userdata1.yml"
╭─────── Caption ────────╮
│ Variable Default value │
╰────────────────────────╯
Variables:
┗━━ 📓 my_percent: 10
```
Ou pourra même généré une erreur :
```bash
rougail -m structure6.yml -u yaml -yf userdata1.yml --cli.invalid_user_datas_error
🛑 ERRORS
┗━━ the value "120" is an invalid integer for "my_percent", value must be less than "100", it will be
ignored when loading from the YAML file "userdata1.yml
```
#### Validation
Mais il est possible d'ajouter des validations complémentaires, par exemple ici vérifier que la variable est impaire (dans le fichier `structure_validators.yml`) :
```yaml
%YAML 1.2
---
version: 1.1
my_odd_variable:
type: integer
validators:
- jinja: "{% if not (_.my_odd_variable % 2) %}not an odd integer{% endif %}"
default:
10
...
```
```bash
rougail -m structure7.yml
🛑 ERRORS
┗━━ "10" is an invalid integer for "my_odd_variable", not an odd integer
```
Par contre cela passe avec une valeur impaire (dans le fichier `userdata_validators.yml`) :
```yaml
---
my_odd_variable: 11
```
```bash
rougail -m structure_validators.yml -u yaml -yf userdata_validators.yml
╭────────────── Caption ───────────────╮
│ Variable Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┗━━ 📓 my_odd_variable: 11 ◀ loaded from the YAML file "userdata_validators.yml" (⏳ 10)
```
### Cohérence globale
Une variable isolée peut être considéré comme étant de qualité mais devenir incohérence suivant le contexte.
Par exemple, si on demande une valeur minimum puis une valeur maximum, la minimal doit être inférieur à la maximal. Dans le fichier `structure_consistency.yml` on a :
```yaml
%YAML 1.2
---
version: 1.1
my_min_value: 11
my_max_value:
default:
variable: _.my_min_value
validators:
- jinja: |-
{% if _.my_min_value >= _.my_max_value %}
must but upper than {{ _.my_min_value }} (the value of "my_min_value")
{% endif %}
...
```
```bash
rougail -m structure_consistency.yml
🛑 ERRORS
┗━━ "11" is an invalid integer for "my_max_value", must but upper than 11 (the value of "my_min_value")
```
Si on défini la bonne valeur :
```yaml
---
my_max_value: 13
```
```bash
%YAML 1.2
---
version: 1.1
my_min_value: 11
my_max_value:
default:
variable: _.my_min_value
validators:
- jinja: |-
{% if _.my_min_value >= _.my_max_value %}
must but upper than {{ _.my_min_value }} (the value of "my_min_value")
{% endif %}
...
```
```bash
rougail -m structure_consistency.yml -u yaml -yf userdata_consistency.yml
╭────────────── Caption ───────────────╮
│ Variable Default value │
│ Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┣━━ 📓 my_min_value: 11
┗━━ 📓 my_max_value: 13 ◀ loaded from the YAML file "userdata_consistency.yml" (⏳ 11)
```
## Contrôle des accès
Le contrôle des accès est réalisé dès qu'on essaye d'accéder à une variable.
Dans Tiramisu il existe deux modes d'accès aux variables par défaut :
- le mode "lecture écriture" : ce mode est utilisé au moment du chargement des données utilisateurs
- le mode "lecture seule" : ce mode est utilisé au moment de le représentation des valeurs
Il existe deux grands type de contrôle des accès :
- les modes
- les propriétés
On pourrait rajouter les étiquettes à cette liste, même si l'objectif n'est pas spécialement de contrôler les accès via les étiquettes.
### Les modes
On va partir sur un cas classic de définition des modes. On part sur trois mode :
- basic : de façon automatique les variables obligatoires sans valeur par défaut (dans ce cas l'acteur qui adapte la configuration devra obligatoirement renseigné des valeurs) et manuellement les variables que l'acteur qui définit les variables juge utile
- standard : automatique les autres variables
- advanced : les variables que l'acteur qui définit les variables décide de mettre
Par exemple créons deux variables dans `structure_mode.yml` avec des modes différents :
```yaml
%YAML 1.2
---
version: 1.1
standard_variable: default value
advanced_variable:
mode: advanced
default: default value
...
```
Avec le fichier `userdata_mode.yml` :
```yaml
---
standard_variable: value
advanced_variable: value
```
```yaml
rougail -m structure_mode.yml -u yaml -ff userdata_mode.yml --modes_level basic standard advanced
╭────────────── Caption ───────────────╮
│ Variable Modified value │
│ (⏳ Original default value) │
╰──────────────────────────────────────╯
Variables:
┣━━ 📓 standard_variable: value ◀ loaded from the YAML file "userdata_mode.yml" (⏳ default value)
┗━━ 📓 advanced_variable: value ◀ loaded from the YAML file "userdata_mode.yml" (⏳ default value)
```
Et interdisont aux acteurs adaptant la configuration de modifier les variables "advanced" :
```bash
rougail -m structure_mode.yml -u yaml -yf userdata_mode.yml --modes_level basic standard advanced --cli.inaccessible_read_write_modes advanced
🔔 WARNINGS
┗━━ variable "advanced_variable" is advanced, it will be ignored when loading from the YAML file "userdata_mode.yml"
╭───────────────────── Caption ─────────────────────╮
│ Variable Default value │
│ Undocumented variable Modified value │
│ (⏳ Original default value) │
╰───────────────────────────────────────────────────╯
Variables:
┣━━ 📓 standard_variable: value ◀ loaded from the YAML file "userdata_mode.yml" (⏳ default value)
┗━━ 📓 advanced_variable: default value
```
La gestion des modes est plutôt limités via la ligne de commande. Pour des besoins plus spécifique il sera nécessaire de passer par la bibliothèque.
### Les propriétés
Les deux propriétés importantes sont :
- les variables cachée
- les variables désactivée
Ces propriétés peuvent être fixe ou calculer suivant le contexte
#### Variable cachée
Une variable cachée est une variable qui ne sera pas modifiable par l'utilisateur et que ne sera pas présente en mode "lecture écriture" mais présente en mode "lecture seule".
Généralement on utilise ce type de variable lorsqu'on ne veut pas que l'acteur qui adapte la configuration puisse modifier cette variable ou alors parce que la valeur de la variable est issu d'un calcul.
#### Variable désactivée
Une variable désactiver est une variable qui sera accessible a aucun des acteurs.
On utilise généralement cette propriété de façon dynamique pour supprimer l'accès à cette variable suivant le context.
Prenons un exemple de variable cachée (donc non modifiable) et ajoutons un variable "use_proxy" qui permet de définir une adresse proxy si on le souhait. Pour cela nous allons créer le fichier suivante : `structure_properties.yml` :
```yaml
%YAML 1.2
---
version: 1.1
hidden_variable:
hidden: true
default: accessible
use_proxy: false
proxy_address:
disabled:
variable: use_proxy
when: false
...
```
```bash
rougail -m structure_properties.yml
╭────────────── Caption ──────────────╮
│ Variable Default value │
│ Unmodifiable variable │
╰─────────────────────────────────────╯
Variables:
┣━━ 📓 hidden_variable: accessible
┗━━ 📓 use_proxy: false
```
Essayons de modifier la variable cachée et de configurer le proxy dans le fichier `userdata_properties.yml` :
```yaml
---
hidden_variable: inaccessible
use_proxy: true
proxy_address: https://proxy.foo.net:4128/
```
```yaml
rougail -m structure_properties.yml -u yaml -ff userdata_properties.yml
🔔 WARNINGS
┗━━ variable "hidden_variable" is hidden, it will be ignored when loading from the YAML file "userdata_properties.yml"
╭───────────────────── Caption ─────────────────────╮
│ Variable Default value │
│ Unmodifiable variable Modified value │
│ (⏳ Original default value) │
╰───────────────────────────────────────────────────╯
Variables:
┣━━ 📓 hidden_variable: accessible
┣━━ 📓 use_proxy: true ◀ loaded from the YAML file "userdata_properties.yml" (⏳ false)
┗━━ 📓 proxy_address: https://proxy.foo.net:4128/ ◀ loaded from the YAML file "userdata_properties.yml"
```
|-------------|------------------------------------------|----------------------------|----------|----------|--------------------|----------------------|
| Étape | Acteur | Cycle de vies | Variable | Valeur | Lecture | Écriture | Propriétés |
|-------------|------------------------------------------|----------------------------|----------|----------|--------------------|----------------------|
| Structurals | défini les variables | déclaration + présentation | mutable | défaut | | |
| UserDatas | adapte les valeurs | affectration | immuable | mutable | lecture + écriture | hidden + disabled |
| Outputs | utilise les variables avec leurs valeurs | lecture | immuable | immuable | lecture | disabled + mandatory |
| | | destruction | | | | |
|-------------|------------------------------------------|----------------------------|----------|----------|--------------------|----------------------|

View file

@ -1,12 +1,16 @@
rougail-output-ansible==1.0.0 rougail==1.2.0rc3
rougail-output-display==1.0.0 rougail-cli==1.0.0rc0
rougail-output-doc==1.0.1 rougail-output-ansible==1.0.0rc0
rougail-output-formatter==1.0.0 rougail-output-display==1.0.0rc0
rougail-output-json==1.0.0 rougail-output-doc==1.0.0rc0
rougail-output-table==0.1.0 rougail-output-formatter==1.0.0rc0
rougail-user-data-ansible==1.0.0 rougail-output-json==1.0.0rc0
rougail-user-data-bitwarden==1.0.0 rougail-output-table==0.1.0rc0
rougail-user-data-commandline==1.0.0 rougail-user-data-ansible==1.0.0rc0
rougail-user-data-environment==1.0.0 rougail-user-data-bitwarden==1.0.0rc1
rougail-user-data-questionary==1.0.0 rougail-user-data-commandline==1.0.0rc2
rougail-user-data-yaml==1.0.0 rougail-user-data-environment==1.0.0rc0
rougail-user-data-questionary==1.0.0rc0
rougail-user-data-yaml==1.0.0rc1
tiramisu==5.2.0rc0
tiramisu-cmdline-parser==1.0.0rc0

File diff suppressed because it is too large Load diff

View file

@ -1,844 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2026-04-29 21:11+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: src/rougail/annotator/family.py:152
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
#: src/rougail/annotator/family.py:158
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
msgstr ""
#: src/rougail/annotator/family.py:190
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
msgstr ""
#: src/rougail/annotator/family.py:194
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
msgstr ""
#: src/rougail/annotator/family.py:258
msgid "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:296
msgid "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:329
msgid "the family \"{0}\" is in \"{1}\" mode but variables and families inside have the higher modes \"{2}\""
msgstr ""
#: src/rougail/annotator/family.py:347
msgid "the variable \"{0}\" is in \"{1}\" mode but family has the higher family mode \"{2}\""
msgstr ""
#: src/rougail/annotator/property.py:182
msgid "invalid tag name \"{0}\" should only contains lowercase ascii character, number or _"
msgstr ""
#: src/rougail/annotator/property.py:187
msgid "invalid tag name \"{0}\" should not be a name of an existing mode"
msgstr ""
#: src/rougail/annotator/property.py:192
msgid "invalid tag name \"{0}\" should not be the name of an available properties"
msgstr ""
#: src/rougail/annotator/value.py:78
msgid "the follower \"{0}\" is not multi, so cannot have a list has default value"
msgstr ""
#: src/rougail/annotator/value.py:94
msgid "the variable \"{0}\" is multi but has a non list default value"
msgstr ""
#: src/rougail/annotator/value.py:118
msgid "the variable \"{0}\" is a \"choice\" variable but don't have any choice"
msgstr ""
#: src/rougail/annotator/value.py:137
msgid "the variable \"{0}\" is a \"regexp\" variable but don't have any regexp"
msgstr ""
#: src/rougail/annotator/variable.py:93
msgid "only \"unix_user\" or \"secret\" variable type can have \"secret_manager\" attribute, but \"{0}\" has type \"{1}\""
msgstr ""
#: src/rougail/annotator/variable.py:100
msgid "the variable \"{0}\" has attribute \"secret_manager\" but is a multi variable"
msgstr ""
#: src/rougail/annotator/variable.py:105
msgid "the variable \"{0}\" has attribute \"secret_manager\" so must not have default value"
msgstr ""
#: src/rougail/annotator/variable.py:159
msgid "{0} values needed, but there are {{{{ var | length }}}}"
msgstr ""
#: src/rougail/annotator/variable.py:160
msgid "needs exactly {0} values"
msgstr ""
#: src/rougail/annotator/variable.py:162
msgid "a maximum of {0} values are needed, but there are {{{{ var | length }}}}"
msgstr ""
#: src/rougail/annotator/variable.py:163
msgid "needs a maximum of {0} values"
msgstr ""
#: src/rougail/annotator/variable.py:167
msgid "a minimum of {0} values are needed, but there are {{{{ var | length }}}}"
msgstr ""
#: src/rougail/annotator/variable.py:168
msgid "needs a minimum of {0} values"
msgstr ""
#: src/rougail/annotator/variable.py:246
msgid "the \"{0}\" default value is a calculation with itself"
msgstr ""
#: src/rougail/annotator/variable.py:310
msgid "the variable \"{0}\" has regexp attribut but has not the \"regexp\" type"
msgstr ""
#: src/rougail/annotator/variable.py:353
msgid "the variable \"{0}\" has choices attribut but has not the \"choice\" type"
msgstr ""
#: src/rougail/annotator/variable.py:381
msgid "the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
msgstr ""
#: src/rougail/config/__init__.py:283
msgid "Default version of the structural file format"
msgstr ""
#: src/rougail/config/__init__.py:284
msgid "This value is only used if the version is not set in the structural file"
msgstr ""
#: src/rougail/config/__init__.py:292
msgid "File with personalize types"
msgstr ""
#: src/rougail/config/__init__.py:293
msgid "This file contains personalize types in Rougail format for structure files"
msgstr ""
#: src/rougail/config/__init__.py:302
msgid "File with functions"
msgstr ""
#: src/rougail/config/__init__.py:303
msgid "This file contains filters and additional Jinja2 functions usable in structure files"
msgstr ""
#: src/rougail/config/__init__.py:314
msgid "All modes level available"
msgstr ""
#: src/rougail/config/__init__.py:326
msgid "Default mode for a family"
msgstr ""
#: src/rougail/config/__init__.py:332
msgid "the first one defined in \"modes_level\""
msgstr ""
#: src/rougail/config/__init__.py:338 src/rougail/config/__init__.py:365
msgid "when no mode is defined in \"modes_level\""
msgstr ""
#: src/rougail/config/__init__.py:345 src/rougail/config/__init__.py:372
msgid "this mode must be available in \"modes_level\""
msgstr ""
#: src/rougail/config/__init__.py:349
msgid "Default mode for a variable"
msgstr ""
#: src/rougail/config/__init__.py:359
msgid "if the variable \"modes_level\" is defined, the default value is the second available element, otherwise, the first"
msgstr ""
#: src/rougail/config/__init__.py:376
msgid "Option name for the base option"
msgstr ""
#: src/rougail/config/__init__.py:381
msgid "In cache file, do not importation of Tiramisu and other dependencies"
msgstr ""
#: src/rougail/config/__init__.py:386
msgid "Store Tiramisu cache filename"
msgstr ""
#: src/rougail/config/__init__.py:387
msgid ""
"This file contains the Tiramisu instructions used internally to load the variables.\n"
"\n"
"This file can be used for debugging"
msgstr ""
#: src/rougail/config/__init__.py:398
msgid "Name of internal functions that we can use as a function"
msgstr ""
#: src/rougail/config/__init__.py:404
msgid "Name of extra annotators"
msgstr ""
#: src/rougail/config/__init__.py:410
msgid "Suffix add to generated options name"
msgstr ""
#: src/rougail/config/__init__.py:416
msgid "Every variables in calculation are optionals"
msgstr ""
#: src/rougail/config/__init__.py:420
msgid "Loads redefine variables even if there don't already exists"
msgstr ""
#: src/rougail/config/__init__.py:424
msgid "The secret manager"
msgstr ""
#: src/rougail/config/__init__.py:427
msgid "The secret pattern to constructing the name of the item searched for in the secret manager"
msgstr ""
#: src/rougail/config/__init__.py:428
msgid "The pattern is in Jinja2 format"
msgstr ""
#: src/rougail/config/__init__.py:437
msgid "structural"
msgstr ""
#: src/rougail/config/__init__.py:438
msgid "user datas"
msgstr ""
#: src/rougail/config/__init__.py:439
msgid "output"
msgstr ""
#: src/rougail/config/__init__.py:460
msgid "select for {0}"
msgstr ""
#: src/rougail/config/__init__.py:498
msgid "outputs {0} did not allow user data"
msgstr ""
#: src/rougail/config/__init__.py:524
msgid "Override default parameters for option type"
msgstr ""
#: src/rougail/config/__init__.py:527
msgid "Default parameters for option type"
msgstr ""
#: src/rougail/convert/convert.py:282
msgid "unknown type \"{0}\" for \"{1}\""
msgstr ""
#: src/rougail/convert/convert.py:441
msgid "family \"{0}\" define multiple time"
msgstr ""
#: src/rougail/convert/convert.py:739
msgid "variable \"{0}\" define multiple time"
msgstr ""
#: src/rougail/convert/convert.py:796
msgid "the {0} \"{1}\" has an invalid \"{2}\": {3}"
msgstr ""
#: src/rougail/convert/convert.py:836 src/rougail/convert/convert.py:843
msgid "params must be a dict for {0}"
msgstr ""
#: src/rougail/convert/convert.py:864
msgid "\"{0}\" has an invalid \"params\" for {1}: {2}"
msgstr ""
#: src/rougail/convert/convert.py:881
msgid "secret_manager must be a dict for {0}"
msgstr ""
#: src/rougail/convert/convert.py:1257
msgid "Cannot execute annotate multiple time"
msgstr ""
#: src/rougail/convert/convert.py:1264
msgid "invalid \"structural\" definition ({0}), we cannot load any structural file!"
msgstr ""
#: src/rougail/convert/object_model.py:132
msgid "cannot find variable \"{0}\" defined in attribute \"{1}\" for \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:138
msgid "the variable \"{0}\" is in fact a family in attribute \"{1}\" for \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:143
#: src/rougail/convert/object_model.py:530
msgid "unknown object \"{0}\" in attribute \"{1}\" for \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:162
msgid "identifier parameter for \"{0}\" in \"{1}\" cannot be set none dynamic family"
msgstr ""
#: src/rougail/convert/object_model.py:191
msgid "cannot find variable \"{0}\" defined in \"{1}\" for \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:196
msgid "variable \"{0}\" defined in \"{1}\" for \"{2}\" is a dynamic variable"
msgstr ""
#: src/rougail/convert/object_model.py:213
msgid "the variable \"{0}\" is not a follower, so cannot have index type for param in \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:264
msgid "\"warnings\" are only available with attribute \"{self.attribute_name}\" for variable \"{self.path}\""
msgstr ""
#: src/rougail/convert/object_model.py:326
msgid "the variable \"{0}\" has a depreciated return_type \"{1}\", please use \"{2}\" instead in {3}"
msgstr ""
#: src/rougail/convert/object_model.py:414
#: src/rougail/convert/object_model.py:448
msgid "variable \"{0}\" has a calculating \"{1}\" with an invalid return_type, should be boolean or string, not \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:425
msgid "the variable \"{0}\" has a return_type \"{1}\", for attribute \"{2}\" but has not description in {3}"
msgstr ""
#: src/rougail/convert/object_model.py:430
msgid "value is invalid"
msgstr ""
#: src/rougail/convert/object_model.py:525
msgid "a variable \"{0}\" is needs in attribute \"{1}\" for \"{2}\" but it's a family"
msgstr ""
#: src/rougail/convert/object_model.py:548
msgid "variable \"{0}\" has an attribute \"{1}\" with an identifier \"{2}\" but the path has also the identifier \"{3}\""
msgstr ""
#: src/rougail/convert/object_model.py:556
msgid "variable \"{0}\" has an attribute \"{1}\" calculated with the unknown variable \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:605
msgid "the variable \"{0}\" has an invalid \"{1}\" the variable \"{2}\" is in a sub dynamic option"
msgstr ""
#: src/rougail/convert/object_model.py:614
msgid "the leader \"{0}\" has an invalid \"{1}\" the follower \"{2}\" is a multi"
msgstr ""
#: src/rougail/convert/object_model.py:656
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" must not be multi"
msgstr ""
#: src/rougail/convert/object_model.py:670
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable must not be a multi or the variable \"{2}\" must be multi"
msgstr ""
#: src/rougail/convert/object_model.py:684
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable must be a multi or the variable \"{2}\" must not be multi"
msgstr ""
#: src/rougail/convert/object_model.py:698
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" is multi but is inside a list"
msgstr ""
#: src/rougail/convert/object_model.py:720
msgid "the variable \"{0}\" is waiting for a list as \"{1}\" but the attribute \"default\" is not a list (\"{2}\")"
msgstr ""
#: src/rougail/convert/object_model.py:724
msgid "the variable \"{0}\" is not waiting for a list as \"{1}\" but the attribute \"default\" is a list (\"{2}\")"
msgstr ""
#: src/rougail/convert/object_model.py:748
msgid "\"{0}\" attribut shall not have an \"optional\" attribute without the \"default\" attribute for variable \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:770
msgid "variable \"{0}\" has a default value calculated with \"{1}\" which has incompatible type"
msgstr ""
#: src/rougail/convert/object_model.py:816
msgid "the variable \"{0}\" is waiting for a boolean as \"{1}\" but the attribute \"default\" is not a boolean (\"{2}\")"
msgstr ""
#: src/rougail/convert/object_model.py:840
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:845
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", \"when\" and \"when_not\" cannot set together"
msgstr ""
#: src/rougail/convert/object_model.py:853
msgid "\"when_not\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:864
msgid "\"when\" or \"when_not\" is mandatory for the not boolean variable \"{0}\" in attribute \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:909
msgid "cannot find variable \"{0}\" for the information \"{1}\" when calculating \"{2}\""
msgstr ""
#: src/rougail/convert/object_model.py:914
msgid "identifier not allowed for the information \"{0}\" when calculating \"{1}\""
msgstr ""
#: src/rougail/convert/object_model.py:966
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\""
msgstr ""
#: src/rougail/convert/object_model.py:972
#: src/rougail/convert/object_model.py:982
msgid "the identifier has an invalid attribute \"{0}\", \"when\" and \"when_not\" cannot set together"
msgstr ""
#: src/rougail/convert/object_model.py:1008
msgid "the variable \"{0}\" is not a follower, so cannot have index type for \"{1}\""
msgstr ""
#: src/rougail/convert/path.py:213
msgid "The variable or the family \"{0}\" located in the \"{1}\" namespace shall not be used in the \"{2}\" namespace"
msgstr ""
#: src/rougail/convert/tiramisureflector.py:348
msgid "variable param \"{0}\" has whole attribute but it's not allowed for external variable"
msgstr ""
#: src/rougail/convert/tiramisureflector.py:351
msgid "variable param \"{0}\" has dynamic attribute but it's not allowed for external variable"
msgstr ""
#: src/rougail/convert/tiramisureflector.py:360
msgid "internal error, {0} is not a dynamic variable"
msgstr ""
#: src/rougail/error.py:61 src/rougail/tiramisu.py:237
msgid "{0} in {1}"
msgstr ""
#: src/rougail/structural_commandline/annotator.py:67
msgid "alternative_name \"{0}\" conflict with \"--help\""
msgstr ""
#: src/rougail/structural_commandline/annotator.py:72
msgid "conflict alternative_name \"{0}\": \"{1}\" and \"{2}\""
msgstr ""
#: src/rougail/structural_directory/__init__.py:130
msgid "duplicate structural file name {0}"
msgstr ""
#: src/rougail/structural_directory/config.py:32
msgid "Main namespace name"
msgstr ""
#: src/rougail/structural_directory/config.py:40
msgid "directory or string is not in \"_.step.structural\""
msgstr ""
#: src/rougail/structural_directory/config.py:43
msgid "Directories where structural files are placed"
msgstr ""
#: src/rougail/structural_directory/config.py:60
msgid "Sort structural from differents directories"
msgstr ""
#: src/rougail/structural_directory/config.py:69
msgid "Namespaces are isolated"
msgstr ""
#: src/rougail/structural_directory/config.py:75
msgid "directory or string is not in \"_.step.structural\" or \"_.main_namespace\" is not set"
msgstr ""
#: src/rougail/structural_directory/config.py:78
msgid "Extra namespaces"
msgstr ""
#: src/rougail/structural_directory/config.py:87
msgid "Extra namespace name"
msgstr ""
#: src/rougail/structural_directory/config.py:93
msgid "Directories where extra structural files are placed"
msgstr ""
#: src/rougail/structural_directory/config.py:104
msgid "directory is not in \"__.step.structural\""
msgstr ""
#: src/rougail/structural_string/config.py:32
msgid "Structural files contents"
msgstr ""
#: src/rougail/structural_string/config.py:33
#: src/rougail/structural_string/config.py:51
msgid "This variable is a list of string with YAML file format"
msgstr ""
#: src/rougail/structural_string/config.py:45
msgid "string is not in \"_.step.structural\""
msgstr ""
#: src/rougail/structural_string/config.py:50
msgid "Extra structural contents"
msgstr ""
#: src/rougail/structural_string/config.py:58
msgid "string is not in \"__.step.structural\""
msgstr ""
#: src/rougail/tiramisu.py:85
msgid "unknown boolean value \"{0}\""
msgstr ""
#: src/rougail/tiramisu.py:88
msgid "IP must be in CIDR format"
msgstr ""
#: src/rougail/tiramisu.py:89
msgid "private IP are allowed"
msgstr ""
#: src/rougail/tiramisu.py:90
msgid "reserved IP are allowed"
msgstr ""
#: src/rougail/tiramisu.py:93
msgid "network must be in CIDR format"
msgstr ""
#: src/rougail/tiramisu.py:94
msgid "private network are allowed"
msgstr ""
#: src/rougail/tiramisu.py:95
msgid "reserved network are allowed"
msgstr ""
#: src/rougail/tiramisu.py:98
msgid "can be range of port"
msgstr ""
#: src/rougail/tiramisu.py:99
msgid "can have the protocol"
msgstr ""
#: src/rougail/tiramisu.py:100
msgid "port 0 is allowed"
msgstr ""
#: src/rougail/tiramisu.py:101
msgid "well-known ports (1 to 1023) are allowed"
msgstr ""
#: src/rougail/tiramisu.py:102
msgid "registred ports (1024 to 49151) are allowed"
msgstr ""
#: src/rougail/tiramisu.py:103
msgid "private ports (greater than 49152) are allowed"
msgstr ""
#: src/rougail/tiramisu.py:106
msgid "type of domainname"
msgstr ""
#: src/rougail/tiramisu.py:106
msgid "type {0}"
msgstr ""
#: src/rougail/tiramisu.py:107
msgid "the domain name can starts by a dot"
msgstr ""
#: src/rougail/tiramisu.py:108
msgid "the domain name can be a hostname"
msgstr ""
#: src/rougail/tiramisu.py:109
msgid "the domain name can be an IP"
msgstr ""
#: src/rougail/tiramisu.py:110
msgid "the domain name can be network in CIDR format"
msgstr ""
#: src/rougail/tiramisu.py:111
msgid "the domain name must exist"
msgstr ""
#: src/rougail/tiramisu.py:121 src/rougail/tiramisu.py:127
msgid "the minimum value"
msgstr ""
#: src/rougail/tiramisu.py:121 src/rougail/tiramisu.py:127
msgid "the minimum value is {0}"
msgstr ""
#: src/rougail/tiramisu.py:122 src/rougail/tiramisu.py:128
msgid "the maximum value"
msgstr ""
#: src/rougail/tiramisu.py:122 src/rougail/tiramisu.py:128
msgid "the maximum value is {0}"
msgstr ""
#: src/rougail/tiramisu.py:137
msgid "minimum characters length for the secret"
msgstr ""
#: src/rougail/tiramisu.py:137
msgid "minimum length for the secret is {0} characters"
msgstr ""
#: src/rougail/tiramisu.py:138
msgid "maximum characters length for the secret"
msgstr ""
#: src/rougail/tiramisu.py:138
msgid "maximum length for the secret is {0} characters"
msgstr ""
#: src/rougail/tiramisu.py:139
msgid "forbidden characters"
msgstr ""
#: src/rougail/tiramisu.py:139
msgid "forbidden characters: {0}"
msgstr ""
#: src/rougail/tiramisu.py:146
msgid "this filename could be a relative path"
msgstr ""
#: src/rougail/tiramisu.py:147
msgid "this file must exist"
msgstr ""
#: src/rougail/tiramisu.py:148
msgid "file type allowed"
msgstr ""
#: src/rougail/tiramisu.py:148
msgid "file type allowed: {0}"
msgstr ""
#: src/rougail/tiramisu.py:438
msgid "cannot calculate the variable \"{0}\""
msgstr ""
#: src/rougail/tiramisu.py:439
msgid "the attribute \"{0}\" in {1} with the parameters \"{2}\" causes the error: {3}"
msgstr ""
#: src/rougail/tiramisu.py:457
msgid "cannot converting the variable \"{0}\""
msgstr ""
#: src/rougail/tiramisu.py:458
msgid "\"{0}\" is an invalid {1}"
msgstr ""
#: src/rougail/tiramisu.py:460
msgid "the attribute \"{0}\" in {1} causes the error: {2}"
msgstr ""
#: src/rougail/user_data.py:105
msgid "{0}, it will be ignored"
msgstr ""
#: src/rougail/user_data.py:156
msgid "cannot load variable path \"{0}\", the identifier \"{1}\" is not valid in {2}"
msgstr ""
#: src/rougail/user_data.py:240
msgid "the variable contains secrets and should not be defined in {0}"
msgstr ""
#: src/rougail/user_data.py:326
msgid "it's a family so we cannot set the value {0}, it has been loading from {1}"
msgstr ""
#: src/rougail/user_data.py:330
msgid "it's a family so we cannot set the value {0}, it will be ignored when loading from {1}"
msgstr ""
#: src/rougail/user_data.py:340
msgid "it's a symlink option so we cannot set the value {0}"
msgstr ""
#: src/rougail/user_data.py:342 src/rougail/user_data.py:372
#: src/rougail/user_data.py:504 src/rougail/user_data.py:516
#: src/rougail/user_data.py:529
msgid "{0}, it has been loading from {1}"
msgstr ""
#: src/rougail/user_data.py:344 src/rougail/user_data.py:376
#: src/rougail/user_data.py:508 src/rougail/user_data.py:520
#: src/rougail/user_data.py:531
msgid "{0}, it will be ignored when loading from {1}"
msgstr ""
#: src/rougail/user_data.py:349 src/rougail/user_data.py:354
msgid "{0}, it has been loaded from {1}"
msgstr ""
#: src/rougail/user_data.py:368
msgid "variable or family \"{0}\" does not exist so cannot load \"{1}\""
msgstr ""
#: src/rougail/user_data.py:385
msgid "\"{0}\" is the name of a dynamic family, it has been loading from {1}"
msgstr ""
#: src/rougail/user_data.py:389
msgid "\"{0}\" is the name of a dynamic family, it will be ignored when loading from {1}"
msgstr ""
#: src/rougail/user_data.py:395
msgid "{0} loaded from {1}"
msgstr ""
#: src/rougail/user_data.py:436
msgid "variable {0} at index \"{1}\" is {2}, it has been loading from {3}"
msgstr ""
#: src/rougail/user_data.py:440
msgid "variable {0} at index \"{1}\" is {2}, it will be ignored when loading from {3}"
msgstr ""
#: src/rougail/user_data.py:453
msgid "family {0} is {1}, {2} at index \"{3}\", it has been loading from {4}"
msgstr ""
#: src/rougail/user_data.py:457
msgid "family {0} is {1}, {2} at index \"{3}\", it will be ignored when loading from {4}"
msgstr ""
#: src/rougail/user_data.py:472
msgid "variable has propery {0}, it has been loading from {1}"
msgstr ""
#: src/rougail/user_data.py:476
msgid "variable has property {0}, it will be ignored when loading from {1}"
msgstr ""
#: src/rougail/user_data.py:487
msgid "family {0} has property {1}, so cannot access to {2}, it has been loading from {3}"
msgstr ""
#: src/rougail/user_data.py:491
msgid "family {0} has property {1}, so cannot access to {2}, it will be ignored when loading from {3}"
msgstr ""
#: src/rougail/user_data.py:536
msgid "the value {0} is an invalid {1}, {2}"
msgstr ""
#: src/rougail/user_data.py:542
msgid ", it has been loading from {0}"
msgstr ""
#: src/rougail/user_data.py:544
msgid ", it will be ignored when loading from {0}"
msgstr ""
#: src/rougail/user_data.py:585
msgid "loaded from {0}"
msgstr ""
#: src/rougail/user_data.py:593
msgid "{0} (the search key is \"{1}\")"
msgstr ""
#: src/rougail/user_data.py:652 src/rougail/user_data.py:666
msgid "null is not a valid value for a multi"
msgstr ""
#: src/rougail/user_data.py:655 src/rougail/user_data.py:668
msgid "mandatory variable but has no value"
msgstr ""
#: src/rougail/user_data.py:657
msgid "mandatory variable at index \"{0}\" but has no value"
msgstr ""
#: src/rougail/user_data.py:660
msgid "mandatory variable but is inaccessible and has no value or has null in value"
msgstr ""
#: src/rougail/user_data.py:662
msgid "mandatory variable at index \"{0}\" but is inaccessible and has no value or has null in value"
msgstr ""
#: src/rougail/utils.py:56
msgid "invalid variable or family name \"{0}\" must only contains lowercase ascii character, number or _"
msgstr ""
#: src/rougail/utils.py:104
msgid "error for the variable \"{1}\" in jinja \"{0}\": {2}"
msgstr ""
#: src/rougail/utils.py:216
msgid "mandatory"
msgstr ""
#: src/rougail/utils.py:217
msgid "hidden"
msgstr ""
#: src/rougail/utils.py:218
msgid "disabled"
msgstr ""
#: src/rougail/utils.py:219
msgid "unique"
msgstr ""
#: src/rougail/utils.py:220
msgid "auto modified"
msgstr ""

View file

@ -1,18 +1,44 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]
[project] [project]
name = "rougail" name = "rougail"
version = "1.2.1" version = "1.0.2"
authors = [
{name = "Emmanuel Garette", email = "gnunux@gnunux.info"},
]
description = "A consistency handling system that was initially designed in the configuration management"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"Natural Language :: English",
"Natural Language :: French",
]
dependencies = [
"ruamel.yaml ~= 0.17.40",
"pydantic ~= 2.5.2",
"jinja2 ~= 3.1.2",
"tiramisu ~= 4.1.0"
]
[project.optional-dependencies]
dev = [
"pylint ~= 3.0.3",
"pytest ~= 8.2.2",
"lxml ~= 5.2.2"
]
[tool.commitizen] [tool.commitizen]
name = "cz_conventional_commits" name = "cz_conventional_commits"
tag_format = "$version" tag_format = "$version"
version_scheme = "pep440" version_scheme = "semver"
version_provider = "pep621" version_provider = "pep621"
version_files = [
"src/rougail/__version__.py",
"rougail-pyproject.toml:version",
"rougail-pyproject.toml:rougail-base == ",
"rougail-base-pyproject.toml:version",
]
update_changelog_on_bump = true update_changelog_on_bump = true
changelog_merge_prerelease = true

View file

@ -1,52 +0,0 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail-base"
version = "1.2.1"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management"
requires-python = ">=3.10"
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"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",
"Natural Language :: French",
]
dependencies = [
"jinja2 ~= 3.1.6",
"tiramisu > 5.1.0"
]
[project.optional-dependencies]
dev = [
"pylint ~= 3.0.3",
"pytest ~= 8.2.2",
]
[tool.flit.module]
name = "rougail"
[tool.flit.sdist]
exclude = [
"src/rougail/annotator",
"src/rougail/config",
"src/rougail/convert",
"src/rougail/structural_commandline",
"src/rougail/structural_directory",
"src/rougail/update",
]
[project.urls]
Home = "https://forge.cloud.silique.fr/stove/rougail"

View file

@ -1,44 +0,0 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]
[project]
name = "rougail"
version = "1.2.1"
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
readme = "README.md"
description = "A consistency handling system that was initially designed in the configuration management"
requires-python = ">=3.10"
license = {file = "LICENSE"}
classifiers = [
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Programming Language :: Python",
"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",
"Natural Language :: French",
]
dependencies = [
"ruamel.yaml ~= 0.19.1", # same version as rougail-user-data-yaml
"pydantic ~= 2.13.4",
"rougail-base == 1.2.1",
]
[tool.flit.sdist]
exclude = [
"src/rougail/error.py",
"src/rougail/i18n.py",
"src/rougail/tiramisu.py",
"src/rougail/user_datas.py",
"src/rougail/utils.py",
"src/rougail/__version__.py",
]
[project.urls]
Home = "https://forge.cloud.silique.fr/stove/rougail"

View file

@ -9,28 +9,124 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from tiramisu import Config
from tiramisu.error import PropertiesOptionError
from warnings import warn
from typing import List
from .__version__ import __version__ from .convert import RougailConvert
from .config import RougailConfig
from .update import RougailUpgrade
from .object_model import CONVERT_OPTION
from .utils import normalize_family
try:
from .convert import Rougail, SUPPORTED_VERSION
from .config import RougailConfig
__all__ = ("Rougail", "RougailConfig", "__version__") def tiramisu_display_name(kls, subconfig) -> str:
except ModuleNotFoundError as err: """Replace the Tiramisu display_name function to display path + description"""
__all__ = ("__version__",) doc = kls._get_information(subconfig, "doc", None)
comment = f" ({doc})" if doc and doc != kls.impl_getname() else ""
if "{{ suffix }}" in comment:
comment = comment.replace('{{ suffix }}', str(subconfig.suffixes[-1]))
path = kls.impl_getpath()
if "{{ suffix }}" in path:
path = path.replace('{{ suffix }}', normalize_family(str(subconfig.suffixes[-1])))
return f"{path}{comment}"
class Rougail:
"""Main Rougail object"""
def __init__(
self,
rougailconfig=None,
) -> None:
if rougailconfig is None:
rougailconfig = RougailConfig
self.rougailconfig = rougailconfig
self.converted = RougailConvert(self.rougailconfig)
self.config = None
def add_path_prefix(
self,
path_prefix: str,
) -> None:
"""Add a prefix"""
self.converted.load_config()
self.converted.parse_directories(path_prefix)
def run(self):
"""Get Tiramisu Config"""
if not self.config:
tiram_obj = self.converted.save(self.rougailconfig["tiramisu_cache"])
optiondescription = {}
custom_types = {custom.__name__: custom for custom in self.rougailconfig["custom_types"].values()}
exec(tiram_obj, custom_types, optiondescription) # pylint: disable=W0122
self.config = Config(
optiondescription["option_0"],
display_name=tiramisu_display_name,
)
self.config.property.read_write()
return self.config
def get_config(self):
warn("get_config is deprecated, use run instead", DeprecationWarning, stacklevel=2)
return self.run()
def user_datas(self,
user_datas: List[dict]):
values = {}
errors = []
warnings = []
for datas in user_datas:
for name, data in datas.get('values', {}).items():
values.setdefault(name, {}).update(data)
errors.extend(datas.get('errors', []))
warnings.extend(datas.get('warnings', []))
while values:
value_is_set = False
for option in self.config:
if option.path() in values and option.index() in values[option.path()]:
try:
option.value.set(values[option.path()])
value_is_set = True
values.pop(option.path())
except:
pass
if not value_is_set:
break
for path, data in values.items():
for index, value in data.items():
try:
print('attention', path, value)
self.config.option(path).value.set(value)
print('pfff')
except AttributeError as err:
errors.append(str(err))
except ValueError as err:
errors.append(str(err).replace('"', "'"))
except PropertiesOptionError as err:
# warnings.append(f'"{err}" but is defined in "{self.filename}"')
warnings.append(str(err))
return {'errors': errors,
'warnings': warnings,
}
__all__ = ("Rougail", "RougailConfig", "RougailUpgrade")

View file

@ -1 +0,0 @@
__version__ = "1.2.1"

View file

@ -1,4 +1,4 @@
"""Annotate structural file """Annotate dictionaries
Created by: Created by:
EOLE (http://eole.orion.education.fr) EOLE (http://eole.orion.education.fr)
@ -9,22 +9,24 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import importlib.resources import importlib.resources
from os.path import isfile from os.path import isfile
from ..utils import load_modules from ..utils import load_modules
@ -37,23 +39,16 @@ def get_level(module):
return module.level return module.level
def get_annotators(annotators, module_name, file_name=None): def get_annotators(annotators, module_name):
if file_name is None: annotators[module_name] = []
_module_name = module_name
else:
_module_name = module_name + "." + file_name
full_file_name = f"/{file_name}.py"
annotators[_module_name] = []
for pathobj in importlib.resources.files(module_name).iterdir(): for pathobj in importlib.resources.files(module_name).iterdir():
path = str(pathobj) path = str(pathobj)
if not path.endswith(".py") or path.endswith("__.py"): if not path.endswith(".py") or path.endswith("__.py"):
continue continue
if file_name is not None and not path.endswith(full_file_name):
continue
module = load_modules(module_name, path) module = load_modules(module_name, path)
if "Annotator" not in dir(module): if "Annotator" not in dir(module):
continue continue
annotators[_module_name].append(module.Annotator) annotators[module_name].append(module.Annotator)
class SpaceAnnotator: # pylint: disable=R0903 class SpaceAnnotator: # pylint: disable=R0903
@ -71,44 +66,22 @@ class SpaceAnnotator: # pylint: disable=R0903
if extra_annotator in ANNOTATORS: if extra_annotator in ANNOTATORS:
continue continue
get_annotators(ANNOTATORS, extra_annotator) get_annotators(ANNOTATORS, extra_annotator)
for structural in objectspace.structurals: for plugin in objectspace.plugins:
try: try:
get_annotators( get_annotators(ANNOTATORS, f'rougail.{plugin}.annotator')
ANNOTATORS, f"rougail.structural_{structural}", "annotator"
)
except ModuleNotFoundError:
pass
for user_data in objectspace.user_data:
try:
get_annotators(
ANNOTATORS, f"rougail.user_data_{user_data}", "annotator"
)
except ModuleNotFoundError:
pass
if objectspace.output:
try:
get_annotators(
ANNOTATORS, f"rougail.output_{objectspace.output}", "annotator"
)
except ModuleNotFoundError: except ModuleNotFoundError:
pass pass
annotators = ANNOTATORS["rougail.annotator"].copy() annotators = ANNOTATORS["rougail.annotator"].copy()
for extra_annotator in objectspace.extra_annotators: for extra_annotator in objectspace.extra_annotators:
annotators.extend(ANNOTATORS[extra_annotator]) annotators.extend(ANNOTATORS[extra_annotator])
for structural in objectspace.structurals: for plugin in objectspace.plugins:
annotators.extend(ANNOTATORS[f"rougail.structural_{structural}.annotator"]) annotators.extend(ANNOTATORS[f'rougail.{plugin}.annotator'])
for user_data in objectspace.user_data:
annotators.extend(ANNOTATORS[f"rougail.user_data_{user_data}.annotator"])
if objectspace.output:
annotators.extend(
ANNOTATORS[f"rougail.output_{objectspace.output}.annotator"]
)
annotators = sorted(annotators, key=get_level) annotators = sorted(annotators, key=get_level)
functions = {} functions = {}
functions_files = objectspace.functions_files functions_files = objectspace.functions_files
for functions_file in functions_files: for functions_file in functions_files:
if isfile(functions_file): if isfile(functions_file):
loaded_modules = load_modules("function_file", functions_file) loaded_modules = load_modules('function_file', functions_file)
for function in dir(loaded_modules): for function in dir(loaded_modules):
if function.startswith("_"): if function.startswith("_"):
continue continue

View file

@ -9,28 +9,29 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import Optional from typing import Optional
from tiramisu.error import display_list
from rougail.i18n import _ from rougail.i18n import _
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.annotator.variable import Walk from rougail.annotator.variable import Walk
from rougail.convert.object_model import VariableCalculation from rougail.object_model import VariableCalculation
class Mode: # pylint: disable=R0903 class Mode: # pylint: disable=R0903
@ -59,118 +60,95 @@ class Annotator(Walk):
objectspace, objectspace,
*args, *args,
): ):
if not objectspace.paths:
return
self.objectspace = objectspace
self.mode_auto = [] self.mode_auto = []
self.objectspace = objectspace
if not self.objectspace.paths:
return
self.check_leadership()
self.remove_empty_families() self.remove_empty_families()
self.check_sequence() self.family_names()
self.families_description() if self.objectspace.modes_level:
self.set_modes() self.modes = {
name: Mode(idx)
for idx, name in enumerate(self.objectspace.modes_level)
}
self.default_variable_mode = self.objectspace.default_variable_mode
self.default_family_mode = self.objectspace.default_family_mode
self.change_modes()
self.convert_help() self.convert_help()
def check_leadership(self) -> None:
"""No subfamily in a leadership"""
for family in self.get_families():
if family.type != "leadership":
continue
for variable_path in self.objectspace.parents[family.path]:
variable = self.objectspace.paths[variable_path]
if variable.type in self.objectspace.family_types:
msg = f'the leadership "{family.path}" cannot have the { variable.type } "{ variable.path}"'
raise DictConsistencyError(msg, 24, variable.xmlfiles)
def remove_empty_families(self) -> None: def remove_empty_families(self) -> None:
"""Remove all families without any variable""" """Remove all families without any variable"""
for family in reversed(list(self.get_families())): removed_families = []
path = family.path
if not self.objectspace.parents[path]:
self.objectspace.del_family(path)
def check_sequence(self) -> None:
"""No subfamily in a sequence"""
for family in self.get_families(): for family in self.get_families():
if family.type == "leadership": if isinstance(family, self.objectspace.family) and not self._has_variable(
family.type = "sequence" family.path
if family.type != "sequence": ):
continue if self.objectspace.paths.default_namespace is None or "." in family.path:
for variable_path in self.objectspace.parents[family.path]: removed_families.append(family.path)
if variable_path in self.objectspace.families: removed_families.reverse()
variable = self.objectspace.paths[variable_path] for family in removed_families:
msg = f'the sequence "{family.path}" cannot have the "{variable.type}" "{variable.path}"' self.objectspace.del_family(family)
raise DictConsistencyError(msg, 24, variable.xmlfiles)
def families_description(self) -> None: def _has_variable(
self,
family: str,
) -> bool:
for variable in self.objectspace.parents[family]:
if variable in self.objectspace.families:
if self._has_variable(variable):
return True
else:
return True
return False
def family_names(self) -> None:
"""Set doc, path, ... to family"""
for family in self.get_families(): for family in self.get_families():
if not family.description: if not family.description:
family.description = family.name family.description = family.name
self.objectspace.forced_descriptions.append(family.path)
if family.type == "dynamic" and isinstance(
family.dynamic, VariableCalculation
):
path = family.dynamic.variable
if (
family.version != "1.0"
and self.objectspace.paths.regexp_relative.search(path)
):
path = self.objectspace.paths.get_full_path(
family.dynamic.variable,
family.path,
)
if family.version == "1.0" and "{{ suffix }}" in path:
path = path.replace("{{ suffix }}", "{{ identifier }}")
self.objectspace.dynamics_variable.setdefault(path, []).append(
family.path
)
self.objectspace.informations.add(family.path, "dynamic_variable", path)
if family.xmlfiles:
self.objectspace.informations.add(
family.path, "ymlfiles", family.xmlfiles
)
def set_modes(self):
if self.objectspace.modes_level:
self.configure_modes()
self.change_modes()
else:
self.modes = {}
for family in self.get_families():
self.valid_mode(family)
for variable in self.get_variables():
self.valid_mode(variable)
def configure_modes(self):
modes = self.modes = {
name: Mode(idx) for idx, name in enumerate(self.objectspace.modes_level)
}
default_variable_mode = self.default_variable_mode = (
self.objectspace.default_variable_mode
)
default_family_mode = self.default_family_mode = (
self.objectspace.default_family_mode
)
list_modes = list(modes)
if default_variable_mode not in list_modes:
msg = _(
'default variable mode "{0}" is not a valid mode, valid modes are {1}'
).format(default_variable_mode, display_list(list_modes, add_quote=True))
raise DictConsistencyError(msg, 72, None)
if default_family_mode not in list_modes:
msg = _(
'default family mode "{0}" is not a valid mode, valid modes are {1}'
).format(default_family_mode, display_list(list_modes, add_quote=True))
raise DictConsistencyError(msg, 73, None)
self.lower_mode = list_modes[0]
self.higher_mode = list_modes[-1]
def change_modes(self): def change_modes(self):
"""change the mode of variables and families""" """change the mode of variables"""
modes_level = self.objectspace.modes_level
default_variable_mode = self.default_variable_mode
if default_variable_mode not in modes_level:
msg = _(
f'default variable mode "{default_variable_mode}" is not a valid mode, '
f"valid modes are {modes_level}"
)
raise DictConsistencyError(msg, 72, None)
default_family_mode = self.default_family_mode
if default_family_mode not in modes_level:
msg = _(
f'default family mode "{default_family_mode}" is not a valid mode, '
f"valid modes are {modes_level}"
)
raise DictConsistencyError(msg, 73, None)
families = list(self.get_families()) families = list(self.get_families())
for family in families: for family in families:
self.valid_mode(family) self.valid_mode(family)
self.set_default_mode(family) self._set_default_mode(family)
for family in reversed(families): families.reverse()
self.change_family_mode(family) for family in families:
self._change_family_mode(family)
if self.objectspace.paths.default_namespace is None: if self.objectspace.paths.default_namespace is None:
for variable_path in self.objectspace.parents["."]: for variable_path in self.objectspace.parents['.']:
variable = self.objectspace.paths[variable_path] variable = self.objectspace.paths[variable_path]
if ( if variable.type == "symlink" or variable_path in self.objectspace.families:
variable.type == "symlink"
or variable_path in self.objectspace.families
):
continue continue
self.valid_mode(variable) self._set_default_mode_variable(variable,
self.set_default_mode_variable(
variable,
self.default_variable_mode, self.default_variable_mode,
check_level=False, check_level=False,
) )
@ -179,98 +157,88 @@ class Annotator(Walk):
self, self,
obj, obj,
) -> None: ) -> None:
if not self.modes: modes_level = self.objectspace.modes_level
if self.has_mode(obj): if self._has_mode(obj) and obj.mode not in modes_level:
msg = _( msg = _(
'mode "{0}" for "{1}" is not a valid mode, valid modes are {2}' f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, '
).format( f"valid modes are {modes_level}"
obj.mode, obj.name, display_list(list(self.modes), add_quote=True)
) )
raise DictConsistencyError(msg, 71, obj.xmlfiles) raise DictConsistencyError(msg, 71, obj.xmlfiles)
elif self.has_mode(obj) and obj.mode not in self.modes:
msg = _(
'mode "{0}" for "{1}" is not a valid mode, no modes are available'
).format(obj.mode, obj.name)
raise DictConsistencyError(msg, 71, obj.xmlfiles)
def set_default_mode( def _set_default_mode(
self, self,
family: "self.objectspace.family", family: "self.objectspace.family",
) -> None: ) -> None:
if self.has_mode(family): children = self.objectspace.parents[family.path]
if not children:
return
if self._has_mode(family):
family_mode = family.mode family_mode = family.mode
else: else:
family_mode = None family_mode = None
is_sequence = family.type == "sequence"
if is_sequence:
leader = None leader = None
for child_path in self.objectspace.parents[family.path]: for variable_path in children:
child = self.objectspace.paths[child_path] variable = self.objectspace.paths[variable_path]
if child.type == "symlink": if variable.type == "symlink":
continue continue
if is_sequence and leader is None: if leader is None and family.type == "leadership":
leader = child leader = variable
leader_mode = leader.mode leader_mode = leader.mode
if child_path in self.objectspace.families: if variable_path in self.objectspace.families:
# set default mode a subfamily # set default mode a subfamily
if family_mode and not self.has_mode(child): if family_mode and not self._has_mode(variable):
self.set_auto_mode(child, family_mode) self._set_auto_mode(variable, family_mode)
else: else:
# set default mode to a variable # set default mode to a variable
self.valid_mode(child) self.valid_mode(variable)
if is_sequence and leader: if leader:
self.set_default_mode_leader(leader, child) self._set_default_mode_leader(leader, variable)
self.set_default_mode_variable(child, family_mode) self._set_default_mode_variable(variable, family_mode)
if is_sequence and leader_mode is not None: if leader and leader_mode is not None:
# here because follower can change sequence mode # here because follower can change leader mode
self.set_auto_mode(family, leader_mode) self._set_auto_mode(family, leader_mode)
def has_mode(self, obj) -> bool: def _has_mode(self, obj) -> bool:
# the mode is set in the structural file
return obj.mode and not obj.path in self.mode_auto return obj.mode and not obj.path in self.mode_auto
def set_default_mode_variable( def _set_default_mode_variable(
self, self,
variable: "self.objectspace.variable", variable: "self.objectspace.variable",
family_mode: Optional[str], family_mode: Optional[str],
check_level: bool = True, check_level: bool=True,
) -> None: ) -> None:
# auto_save variable is set to 'basic' mode # auto_save variable is set to 'basic' mode
# if its mode is not defined by the user # if its mode is not defined by the user
if not self.has_mode(variable) and variable.auto_save is True: if not self._has_mode(variable) and variable.auto_save is True:
variable.mode = self.lower_mode variable.mode = self.objectspace.modes_level[0]
# mandatory variable without value is a basic variable # mandatory variable without value is a basic variable
elif ( elif (
not self.has_mode(variable) not self._has_mode(variable)
and variable.mandatory is True and variable.mandatory is True
and variable.default is None and variable.default is None
and variable.path not in self.objectspace.default_multi and variable.path not in self.objectspace.default_multi
): ):
variable_mode = self.lower_mode variable_mode = self.objectspace.modes_level[0]
if ( if check_level and family_mode and self.modes[variable_mode] < self.modes[family_mode]:
check_level
and family_mode
and self.modes[variable_mode] < self.modes[family_mode]
):
msg = _( msg = _(
'the variable "{0}" is mandatory so in "{1}" mode but family has the higher family mode "{2}"' f'the variable "{variable.name}" is mandatory so in "{variable_mode}" mode '
).format(variable.name, variable_mode, family_mode) f'but family has the higher family mode "{family_mode}"'
)
raise DictConsistencyError(msg, 36, variable.xmlfiles) raise DictConsistencyError(msg, 36, variable.xmlfiles)
variable.mode = variable_mode variable.mode = variable_mode
elif family_mode and not self.has_mode(variable): elif family_mode and not self._has_mode(variable):
self.set_auto_mode(variable, family_mode) self._set_auto_mode(variable, family_mode)
def set_auto_mode( def _set_auto_mode(
self, self,
obj, obj,
mode: str, mode: str,
) -> None: ) -> None:
# This mode is set automaticly
obj.mode = mode obj.mode = mode
self.mode_auto.append(obj.path) self.mode_auto.append(obj.path)
def set_default_mode_leader( def _set_default_mode_leader(
self, self,
leader: "self.objectspace.variable", leader: "self.objectspace.variable",
follower: "self.objectspace.variable", follower: "self.objectspace.variable",
@ -278,26 +246,29 @@ class Annotator(Walk):
if leader == follower: if leader == follower:
# it's a leader # it's a leader
if not leader.mode: if not leader.mode:
self.set_auto_mode(leader, self.default_variable_mode) self._set_auto_mode(
leader, self.default_variable_mode
)
return return
if self.has_mode(follower): if self._has_mode(follower):
follower_mode = follower.mode follower_mode = follower.mode
else: else:
follower_mode = self.default_variable_mode follower_mode = self.default_variable_mode
if self.modes[leader.mode] > self.modes[follower_mode]: if self.modes[leader.mode] > self.modes[follower_mode]:
if self.has_mode(follower) and not self.has_mode(leader): if self._has_mode(follower) and not self._has_mode(leader):
# if follower has mode but not the leader # if follower has mode but not the leader
self.set_auto_mode(leader, follower_mode) self._set_auto_mode(leader, follower_mode)
else: else:
# leader's mode is minimum level # leader's mode is minimum level
if self.has_mode(follower): if self._has_mode(follower):
msg = _( msg = _(
'the follower "{0}" is in "{1}" mode but leader have the higher mode "{2}"' f'the follower "{follower.name}" is in "{follower_mode}" mode '
).format(follower.name, follower_mode, leader.mode) f'but leader have the higher mode "{leader.mode}"'
)
raise DictConsistencyError(msg, 63, follower.xmlfiles) raise DictConsistencyError(msg, 63, follower.xmlfiles)
self.set_auto_mode(follower, leader.mode) self._set_auto_mode(follower, leader.mode)
def change_family_mode( def _change_family_mode(
self, self,
family: "self.objectspace.family", family: "self.objectspace.family",
) -> None: ) -> None:
@ -305,29 +276,30 @@ class Annotator(Walk):
family_mode = family.mode family_mode = family.mode
else: else:
family_mode = self.default_family_mode family_mode = self.default_family_mode
min_variable_mode = self.higher_mode min_variable_mode = self.objectspace.modes_level[-1]
is_sequence = family.type == "sequence" # change variable mode, but not if variables are not in a family
for child_path in self.objectspace.parents[family.path]: is_leadership = family.type == "leadership"
child = self.objectspace.paths[child_path] if family.path in self.objectspace.parents:
if child.type == "symlink": for variable_path in self.objectspace.parents[family.path]:
variable = self.objectspace.paths[variable_path]
if variable.type == "symlink":
continue continue
if child_path in self.objectspace.families: if variable_path in self.objectspace.families:
if not child.mode: if not variable.mode:
child.mode = self.default_family_mode variable.mode = self.default_family_mode
else: else:
self.change_variable_mode(child, family_mode, is_sequence) self._change_variable_mode(variable, family_mode, is_leadership)
if self.modes[min_variable_mode] > self.modes[child.mode]: if self.modes[min_variable_mode] > self.modes[variable.mode]:
min_variable_mode = child.mode min_variable_mode = variable.mode
if not family.mode: if not family.mode:
# set the lower variable mode to family # set the lower variable mode to family
self.set_auto_mode(family, min_variable_mode) self._set_auto_mode(family, min_variable_mode)
if self.modes[family.mode] < self.modes[min_variable_mode]: if self.modes[family.mode] < self.modes[min_variable_mode]:
msg = _( msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and '
'the family "{0}" is in "{1}" mode but variables and families inside have the higher modes "{2}"' f'families inside have the higher modes "{min_variable_mode}"')
).format(family.name, family.mode, min_variable_mode)
raise DictConsistencyError(msg, 62, family.xmlfiles) raise DictConsistencyError(msg, 62, family.xmlfiles)
def change_variable_mode( def _change_variable_mode(
self, self,
variable, variable,
family_mode: str, family_mode: str,
@ -339,12 +311,13 @@ class Annotator(Walk):
variable_mode = self.default_variable_mode variable_mode = self.default_variable_mode
# none basic variable in high level family has to be in high level # none basic variable in high level family has to be in high level
if not is_follower and self.modes[variable_mode] < self.modes[family_mode]: if not is_follower and self.modes[variable_mode] < self.modes[family_mode]:
if self.has_mode(variable): if self._has_mode(variable):
msg = _( msg = _(
'the variable "{0}" is in "{1}" mode but family has the higher family mode "{2}"' f'the variable "{variable.name}" is in "{variable_mode}" mode '
).format(variable.path, variable_mode, family_mode) f'but family has the higher family mode "{family_mode}"'
)
raise DictConsistencyError(msg, 61, variable.xmlfiles) raise DictConsistencyError(msg, 61, variable.xmlfiles)
self.set_auto_mode(variable, family_mode) self._set_auto_mode(variable, family_mode)
if not variable.mode: if not variable.mode:
variable.mode = variable_mode variable.mode = variable_mode

View file

@ -9,30 +9,29 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import Union
from typing import Union, List
from tiramisu.setting import PROPERTIES_MAKE_SENSE
from rougail.i18n import _ from rougail.i18n import _
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.annotator.variable import Walk from rougail.annotator.variable import Walk
from rougail.convert.object_model import Calculation from rougail.object_model import Calculation
from rougail.utils import NAME_REGEXP
from rougail.convert.object_model import VariableCalculation
PROPERTIES = ( PROPERTIES = (
@ -52,57 +51,33 @@ class Annotator(Walk):
def __init__(self, objectspace, *args) -> None: def __init__(self, objectspace, *args) -> None:
self.objectspace = objectspace self.objectspace = objectspace
if not self.objectspace.paths:
return
self.frozen = {} self.frozen = {}
self.variables_default_transitive = [] if self.objectspace.paths:
self.convert_sequence()
self.convert_family() self.convert_family()
self.convert_variable() self.convert_variable()
def convert_sequence(self) -> None:
for variable_path in self.objectspace.leaders:
variable = self.objectspace.paths[variable_path]
if variable.hidden:
family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
hidden = variable.hidden
if hidden is not True:
hidden = hidden.model_copy()
if hidden.ori_path is None:
hidden.ori_path = variable_path
family.hidden = hidden
variable.hidden = None
def convert_family(self) -> None: def convert_family(self) -> None:
"""convert families""" """convert families"""
for family in self.get_families(): for family in self.get_families():
self.family_variable_property(family) self._convert_property(family)
self.convert_tag(family)
# collect for force_default_on_freeze # collect for force_default_on_freeze
if family.hidden: if family.hidden:
if family.hidden is True: self.set_variable_frozen(
frozen = True
else:
frozen = family.hidden.model_copy()
frozen.attribute_name = "frozen"
if frozen.ori_path is None:
frozen.ori_path = family.path
self.set_variable_frozen_inside_family(
family.path, family.path,
frozen, family.hidden,
) )
def set_variable_frozen_inside_family( def set_variable_frozen(
self, self,
family_path: str, family_path: str,
frozen: Union[bool, Calculation], hidden: Union[bool, Calculation],
) -> None: ) -> None:
for variable_path in self.objectspace.parents[family_path]: for variable_path in self.objectspace.parents[family_path]:
if variable_path in self.objectspace.families: if variable_path in self.objectspace.families:
# it's a family # it's a family
self.set_variable_frozen_inside_family( self.set_variable_frozen(
variable_path, variable_path,
frozen, hidden,
) )
else: else:
# it's a variable # it's a variable
@ -111,48 +86,51 @@ class Annotator(Walk):
if ( if (
self.frozen.get(variable.path) is True self.frozen.get(variable.path) is True
or variable.hidden is True or variable.hidden is True
or frozen is True or hidden is True
): ):
self.frozen[variable.path] = True self.frozen[variable.path] = True
elif variable.path in self.frozen:
self.frozen[variable.path].append(hidden)
else: else:
if variable.path in self.frozen: self.frozen[variable.path] = [hidden]
if not isinstance(self.frozen[variable.path], list):
self.frozen[variable.path] = [frozen]
self.frozen[variable.path].append(frozen)
else:
self.frozen[variable.path] = frozen
def convert_variable(self) -> None: def convert_variable(self) -> None:
"""convert variables""" """convert variables"""
for variable in self.get_variables(): for variable in self.get_variables():
if variable.path.startswith("services."):
continue
if variable.type == "symlink": if variable.type == "symlink":
continue continue
self.convert_variable_property(variable) self._convert_variable_property(variable)
def convert_variable_property( def _convert_variable_property(
self, self,
variable: dict, variable: dict,
) -> None: ) -> None:
"""convert properties""" """convert properties"""
path = variable.path path = variable.path
self.family_variable_property(variable) self._convert_property(variable)
if variable.hidden: if variable.hidden:
if variable.hidden is True: if variable.hidden is True:
self.frozen[path] = True self.frozen[path] = True
elif self.frozen.get(path) is not True: elif self.frozen.get(path) is not True:
frozen = variable.hidden.model_copy() self.frozen.setdefault(path, []).append(variable.hidden)
frozen.attribute_name = "frozen"
if frozen.ori_path is None:
frozen.ori_path = path
if path in self.frozen: if path in self.frozen:
if not isinstance(self.frozen, list): frozen = self.frozen[path]
self.frozen[path] = [self.frozen[path]] if frozen is True:
self.frozen[path].append(frozen) value = True
else: else:
self.frozen[path] = frozen value = []
if path in self.frozen: for calculation in frozen:
self.objectspace.properties.add(path, "frozen", self.frozen[path]) calculation_copy = calculation.copy()
if not variable.auto_save and not variable.secret_manager: calculation_copy.attribute_name = 'frozen'
calculation_copy.ori_path = calculation_copy.path
calculation_copy.path = path
value.append(calculation_copy)
if len(value) == 1:
value = value[0]
self.objectspace.properties.add(path, "frozen", value)
if not variable.auto_save:
# if auto_save, save calculated value # if auto_save, save calculated value
self.objectspace.properties.add(path, "force_default_on_freeze", True) self.objectspace.properties.add(path, "force_default_on_freeze", True)
if not variable.empty and self.objectspace.multis.get(variable.path, False): if not variable.empty and self.objectspace.multis.get(variable.path, False):
@ -165,39 +143,8 @@ class Annotator(Walk):
self.objectspace.properties.add(path, "notunique", True) self.objectspace.properties.add(path, "notunique", True)
if variable.auto_save: if variable.auto_save:
self.objectspace.properties.add(path, "force_store_value", True) self.objectspace.properties.add(path, "force_store_value", True)
self.convert_tag(variable)
def convert_tag(self, variable): def _convert_property(
if not variable.tags:
return
for tag in variable.tags:
self.check_tag(tag, variable.xmlfiles)
self.objectspace.properties.add(variable.path, tag, True)
self.objectspace.informations.add(variable.path, "tags", tuple(variable.tags))
def check_tag(
self,
tag: str,
xmlfiles: List[str],
):
match = NAME_REGEXP.search(tag)
if not match:
msg = _(
'invalid tag name "{0}" should only contains lowercase ascii character, number or _'
).format(tag)
raise DictConsistencyError(msg, 82, xmlfiles)
if tag in self.objectspace.modes_level:
msg = _(
'invalid tag name "{0}" should not be a name of an existing mode'
).format(tag)
raise DictConsistencyError(msg, 82, xmlfiles)
if tag in PROPERTIES_MAKE_SENSE:
msg = _(
'invalid tag name "{0}" should not be the name of an available properties'
).format(tag)
raise DictConsistencyError(msg, 82, xmlfiles)
def family_variable_property(
self, self,
obj: dict, obj: dict,
) -> None: ) -> None:

View file

@ -9,27 +9,29 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from rougail.annotator.variable import Walk from rougail.annotator.variable import Walk
from rougail.i18n import _ from rougail.i18n import _
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.convert.object_model import Calculation from rougail.object_model import Calculation
class Annotator(Walk): # pylint: disable=R0903 class Annotator(Walk): # pylint: disable=R0903
@ -47,14 +49,13 @@ class Annotator(Walk): # pylint: disable=R0903
self.objectspace = objectspace self.objectspace = objectspace
self.convert_value() self.convert_value()
self.valid_choices() self.valid_choices()
self.valid_regexp()
def convert_value(self) -> None: def convert_value(self) -> None:
"""convert value""" """convert value"""
for variable in self.get_variables(): for variable in self.get_variables():
if variable.type == "symlink": if variable.type == "symlink":
continue continue
if variable.version != "1.0" and variable.type == "port": if variable.version != '1.0' and variable.type == 'port':
self._convert_port(variable) self._convert_port(variable)
self._convert_value(variable) self._convert_value(variable)
@ -76,24 +77,24 @@ class Annotator(Walk): # pylint: disable=R0903
raise DictConsistencyError(msg, 68, variable.xmlfiles) raise DictConsistencyError(msg, 68, variable.xmlfiles)
if variable.path in self.objectspace.followers and multi != "submulti": if variable.path in self.objectspace.followers and multi != "submulti":
msg = _( msg = _(
'the follower "{0}" is not multi, so cannot have a list has default value' f'the follower "{variable.name}" without multi attribute can only have one value'
).format(variable.path) )
raise DictConsistencyError(msg, 87, variable.xmlfiles) raise DictConsistencyError(msg, 87, variable.xmlfiles)
if not variable.default: if not variable.default:
variable.default = None variable.default = None
else: else:
if variable.path not in self.objectspace.leaders: if variable.path not in self.objectspace.leaders:
if multi == "submulti": if multi == "submulti":
self.objectspace.default_multi[variable.path] = variable.default self.objectspace.default_multi[
variable.path
] = variable.default
variable.default = None variable.default = None
else: else:
self.objectspace.default_multi[variable.path] = ( self.objectspace.default_multi[variable.path] = variable.default[
variable.default[0] 0
) ]
elif variable.multi: elif variable.multi:
msg = _( msg = _(f'the variable "{variable.name}" is multi but has a non list default value')
'the variable "{0}" is multi but has a non list default value'
).format(variable.path)
raise DictConsistencyError(msg, 12, variable.xmlfiles) raise DictConsistencyError(msg, 12, variable.xmlfiles)
elif variable.path in self.objectspace.followers: elif variable.path in self.objectspace.followers:
self.objectspace.default_multi[variable.path] = variable.default self.objectspace.default_multi[variable.path] = variable.default
@ -115,9 +116,7 @@ class Annotator(Walk): # pylint: disable=R0903
if isinstance(variable.choices, Calculation): if isinstance(variable.choices, Calculation):
continue continue
if variable.choices is None: if variable.choices is None:
msg = _( msg = f'the variable "{variable.path}" is a "choice" variable but don\'t have any choice'
'the variable "{0}" is a "choice" variable but don\'t have any choice'
).format(variable.path)
raise DictConsistencyError(msg, 19, variable.xmlfiles) raise DictConsistencyError(msg, 19, variable.xmlfiles)
if not variable.mandatory and not variable.multi: if not variable.mandatory and not variable.multi:
self.add_choice_nil(variable) self.add_choice_nil(variable)
@ -128,13 +127,3 @@ class Annotator(Walk): # pylint: disable=R0903
if choice is None: if choice is None:
return return
variable.choices.append(None) variable.choices.append(None)
def valid_regexp(self) -> None:
for variable in self.get_variables():
if variable.type != "regexp":
continue
if variable.regexp is None:
msg = _(
'the variable "{0}" is a "regexp" variable but don\'t have any regexp'
).format(variable.path)
raise DictConsistencyError(msg, 66, variable.xmlfiles)

View file

@ -9,36 +9,29 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from tiramisu.error import display_list
from rougail.i18n import _ from rougail.i18n import _
from rougail.utils import calc_multi_for_type_variable
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.convert.object_model import ( from rougail.object_model import Calculation, VariableCalculation
Calculation, from tiramisu.error import display_list
VariableCalculation,
VariableParam,
IndexCalculation,
JinjaCalculation,
)
from rougail.tiramisu import display_xmlfiles, RENAME_TYPE
from warnings import warn
class Walk: class Walk:
@ -51,6 +44,8 @@ class Walk:
for path in self.objectspace.variables: for path in self.objectspace.variables:
yield self.objectspace.paths[path] yield self.objectspace.paths[path]
# yield from get_variables(self.objectspace)
def get_families(self): def get_families(self):
"""Iter all families from the objectspace""" """Iter all families from the objectspace"""
for path in self.objectspace.families: for path in self.objectspace.families:
@ -70,234 +65,91 @@ class Annotator(Walk): # pylint: disable=R0903
if not objectspace.paths: if not objectspace.paths:
return return
self.objectspace = objectspace self.objectspace = objectspace
if self.objectspace.main_namespace:
self.forbidden_name = [
self.objectspace.main_namespace
]
for extra in self.objectspace.extra_dictionaries:
self.forbidden_name.append(extra)
else:
self.forbidden_name = []
# default type inference from a default value with :term:`basic types` # default type inference from a default value with :term:`basic types`
self.basic_types = { self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
str: "string",
int: "integer",
bool: "boolean",
float: "float",
}
self.verify_secret_managers()
self.verify_choices()
self.convert_variable() self.convert_variable()
self.convert_test() self.convert_test()
self.convert_examples() self.convert_examples()
self.convert_help() self.convert_help()
self.verify_choices()
def verify_secret_managers(self):
for variable in self.get_variables():
if not variable.secret_manager:
continue
path = variable.path
if variable.type not in ["unix_user", "secret"]:
msg = _(
'only "unix_user" or "secret" variable type can have "secret_manager" attribute, but "{0}" has type "{1}"'
)
raise DictConsistencyError(
msg.format(path, variable.type), 56, variable.xmlfiles
)
if variable.multi and path not in self.objectspace.leaders:
msg = _(
'the variable "{0}" has attribute "secret_manager" but is a multi variable'
)
raise DictConsistencyError(msg.format(path), 57, variable.xmlfiles)
if variable.default is not None:
msg = _(
'the variable "{0}" has attribute "secret_manager" so must not have default value'
)
raise DictConsistencyError(msg.format(path), 59, variable.xmlfiles)
self.objectspace.informations.add(path, "secret_manager", True)
def convert_variable(self): def convert_variable(self):
"""convert variable""" """convert variable"""
for variable in self.get_variables(): for variable in self.get_variables():
if variable.version != "1.0":
if variable.type == "symlink": if variable.type == "symlink":
continue continue
if variable.version != "1.0":
self._convert_variable_inference(variable) self._convert_variable_inference(variable)
self._convert_variable_multi(variable)
for variable in self.get_variables(): for variable in self.get_variables():
if variable.type == "symlink": if variable.type == "symlink":
continue continue
if variable.type in RENAME_TYPE: if variable.version != "1.0":
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use "{RENAME_TYPE[variable.type]}" instead in {display_xmlfiles(variable.xmlfiles)}' self._default_variable_copy_informations(variable)
warn( if variable.multi is None:
warning, variable.multi = False
DeprecationWarning, if variable.type is None:
) variable.type = "string"
variable.type = RENAME_TYPE[variable.type]
if variable.type == "cidr":
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use type "ip" with attribute cidr=True instead in {display_xmlfiles(variable.xmlfiles)}'
warn(
warning,
DeprecationWarning,
)
if variable.type == "network_cidr":
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use type "network" with attribute cidr=True instead in {display_xmlfiles(variable.xmlfiles)}'
warn(
warning,
DeprecationWarning,
)
self.objectspace.informations.add( self.objectspace.informations.add(
variable.path, "ymlfiles", variable.xmlfiles variable.path, "type", variable.type
)
if variable.version != "1.0" and variable.type is None:
if isinstance(variable.default, IndexCalculation):
variable.type = "integer"
elif isinstance(variable.default, VariableCalculation):
calculated_variable_path, calculated_variable, identifier = (
variable.default.get_variable(self.objectspace, variable.path)
)
if calculated_variable is not None:
variable = self._default_variable_copy_informations(
variable, calculated_variable
) )
self._convert_variable(variable) self._convert_variable(variable)
if variable.multi and variable.params:
indexes_to_remove = []
for idx, param in enumerate(variable.params):
if param.key == "multi_length":
jinja = f'{{% if var | length != {param.value} %}}{_("{0} values needed, but there are {{{{ var | length }}}}").format(param.value)}{{% endif %}}'
description = _("needs exactly {0} values").format(param.value)
elif param.key == "multi_max_length":
jinja = f'{{% if var | length > {param.value} %}}{_("a maximum of {0} values are needed, but there are {{{{ var | length }}}}").format(param.value)}{{% endif %}}'
description = _("needs a maximum of {0} values").format(
param.value
)
elif param.key == "multi_min_length":
jinja = f'{{% if var | length < {param.value} %}}{_("a minimum of {0} values are needed, but there are {{{{ var | length }}}}").format(param.value)}{{% endif %}}'
description = _("needs a minimum of {0} values").format(
param.value
)
else:
continue
indexes_to_remove.append(idx)
if variable.validators is None:
variable.validators = []
variable.validators.append(
JinjaCalculation(
inside_list=True,
version=variable.version,
xmlfiles=variable.xmlfiles,
attribute_name="validators",
namespace=variable.namespace,
jinja=jinja,
description=description,
params=[
VariableParam(
variable.path,
"validators",
False,
variable.xmlfiles,
key="var",
namespace=variable.namespace,
type="variable",
variable=variable.path,
whole=True,
)
],
)
)
for idx in reversed(indexes_to_remove):
variable.params.pop(idx)
if variable.secret_manager:
self.objectspace.properties.add(variable.path, "novalidator", True)
def _convert_variable_inference( def _convert_variable_inference(
self, self,
variable, variable,
) -> None: ) -> None:
# variable has no type # variable has no type
if variable.type is not None: if variable.type is None:
return # choice type inference from the `choices` attribute
## choice type inference from the `choices` attribute if variable.choices is not None:
# if variable.choices is not None: variable.type = "choice"
# variable.type = "choice" elif variable.regexp is not None:
# elif variable.regexp is not None: variable.type = "regexp"
# variable.type = "regexp" elif variable.default not in [None, []]:
if variable.default not in [None, []]:
if isinstance(variable.default, list): if isinstance(variable.default, list):
tested_value = variable.default[0] tested_value = variable.default[0]
else: else:
tested_value = variable.default tested_value = variable.default
variable.type = self.basic_types.get(type(tested_value), None) variable.type = self.basic_types.get(type(tested_value), None)
def _convert_variable_multi(
self,
variable,
) -> None:
# variable has no multi attribute # variable has no multi attribute
if variable.multi is not None: if variable.multi is None and not (variable.type is None and isinstance(variable.default, VariableCalculation)):
return
if variable.path in self.objectspace.leaders: if variable.path in self.objectspace.leaders:
variable.multi = self.objectspace.multis[variable.path] = True variable.multi = True
elif variable.version != "1.0" and isinstance(
variable.default, VariableCalculation
):
calculated_variable_path, calculated_variable, identifier = (
variable.default.get_variable(self.objectspace, variable.path)
)
if calculated_variable is not None:
if calculated_variable.multi is None:
if (
isinstance(calculated_variable.default, VariableCalculation)
and variable.path == calculated_variable.path
):
msg = _(
'the "{0}" default value is a calculation with itself'
).format(variable.path)
raise DictConsistencyError(msg, 75, variable.xmlfiles)
self._convert_variable_multi(calculated_variable)
identifier_is_a_calculation = False
if isinstance(variable.default, Calculation):
identifier_is_a_calculation = isinstance(
variable.default.identifier, Calculation
)
variable.multi = calc_multi_for_type_variable(
variable,
calculated_variable_path,
calculated_variable,
identifier_is_a_calculation,
self.objectspace,
)[1]
if (
calculated_variable.path in self.objectspace.followers
and variable.mandatory is calculated_variable.mandatory is False
and calculated_variable.path.rsplit(".", 1)[0]
!= variable.path.rsplit(".", 1)[0]
):
variable.empty = False
else: else:
variable.multi = isinstance(variable.default, list) variable.multi = isinstance(variable.default, list)
def _default_variable_copy_informations( def _default_variable_copy_informations(
self, self,
variable, variable,
calculated_variable,
) -> None: ) -> None:
# if a variable has a variable as default value, that means the type/params or multi should has same value
if variable.type is not None or not isinstance(variable.default, VariableCalculation):
return
# copy type and params # copy type and params
calculated_type = calculated_variable.__class__ calculated_variable_path = variable.default.variable
if variable.__class__ == calculated_type: calculated_variable, suffix = self.objectspace.paths.get_with_dynamic(
calculated_variable_path, variable.default.path_prefix, variable.path, variable.version, variable.namespace, variable.xmlfiles
)
if calculated_variable is None:
return
variable.type = calculated_variable.type variable.type = calculated_variable.type
else:
data = dict(variable)
data["type"] = calculated_variable.type
variable = calculated_type(**data)
self.objectspace.paths.replace(data["path"], variable)
if variable.params is None and calculated_variable.params is not None: if variable.params is None and calculated_variable.params is not None:
variable.params = calculated_variable.params variable.params = calculated_variable.params
if variable.type == "choice" and variable.choices is None: # copy multi attribut
variable.choices = calculated_variable.choices if variable.multi is None:
if isinstance(variable.choices, VariableCalculation): calculated_path = calculated_variable.path
variable.choices = variable.choices.model_copy() if calculated_path in self.objectspace.leaders and variable.path in self.objectspace.followers and calculated_path.rsplit('.')[0] == variable.path.rsplit('.')[0]:
variable.choices.variable = self.objectspace.paths.get_full_path( variable.multi = False
variable.choices.variable, else:
calculated_variable.path, variable.multi = calculated_variable.multi
)
if variable.type == "regexp" and variable.regexp is None:
variable.regexp = calculated_variable.regexp
return variable
def _convert_variable( def _convert_variable(
self, self,
@ -306,10 +158,6 @@ class Annotator(Walk): # pylint: disable=R0903
# variable without description: description is the name # variable without description: description is the name
if not variable.description: if not variable.description:
variable.description = variable.name variable.description = variable.name
self.objectspace.forced_descriptions.append(variable.path)
if variable.type is None:
variable.type = "string"
self.objectspace.informations.add(variable.path, "type", variable.type)
if variable.path in self.objectspace.followers: if variable.path in self.objectspace.followers:
if not variable.multi: if not variable.multi:
self.objectspace.multis[variable.path] = True self.objectspace.multis[variable.path] = True
@ -317,13 +165,21 @@ class Annotator(Walk): # pylint: disable=R0903
self.objectspace.multis[variable.path] = "submulti" self.objectspace.multis[variable.path] = "submulti"
elif variable.multi: elif variable.multi:
self.objectspace.multis[variable.path] = True self.objectspace.multis[variable.path] = True
# if variable.regexp is not None and variable.type != "regexp": if variable.path in self.objectspace.leaders:
# msg = _( if not self.objectspace.multis.get(variable.path, False):
# 'the variable "{0}" has regexp attribut but has not the "regexp" type' variable.multi = self.objectspace.multis[variable.path] = True
# ).format(variable.path) family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
# raise DictConsistencyError(msg, 37, variable.xmlfiles) if variable.hidden:
if variable.mandatory is None: family.hidden = variable.hidden
variable.mandatory = True elif family.hidden:
variable.hidden = family.hidden
variable.hidden = None
if variable.choices is not None and variable.type != 'choice':
msg = _(f'the variable "{variable.path}" has choices attribut but has not the "choice" type')
raise DictConsistencyError(msg, 11, variable.xmlfiles)
if variable.regexp is not None and variable.type != 'regexp':
msg = _(f'the variable "{variable.path}" has regexp attribut but has not the "regexp" type')
raise DictConsistencyError(msg, 37, variable.xmlfiles)
def convert_test(self): def convert_test(self):
"""Convert variable tests value""" """Convert variable tests value"""
@ -357,16 +213,8 @@ class Annotator(Walk): # pylint: disable=R0903
def verify_choices(self): def verify_choices(self):
for variable in self.get_variables(): for variable in self.get_variables():
# FIXME if variable.type != 'choice' or variable.default is None:
# if variable.type is None and variable.choices:
# # choice type inference from the `choices` attribute
# variable.type = "choice"
if variable.type != "choice":
continue continue
if variable.default is None:
continue
if None in variable.choices and variable.mandatory is None:
variable.mandatory = False
if not isinstance(variable.choices, list): if not isinstance(variable.choices, list):
continue continue
choices = variable.choices choices = variable.choices
@ -385,11 +233,5 @@ class Annotator(Walk): # pylint: disable=R0903
if isinstance(value, Calculation): if isinstance(value, Calculation):
continue continue
if value not in choices: if value not in choices:
msg = _( msg = _(f'the variable "{variable.path}" has an unvalid default value "{value}" should be in {display_list(choices, separator="or", add_quote=True)}')
'the variable "{0}" has an unvalid default value "{1}" should be in {2}'
).format(
variable.path,
value,
display_list(choices, separator="or", add_quote=True),
)
raise DictConsistencyError(msg, 26, variable.xmlfiles) raise DictConsistencyError(msg, 26, variable.xmlfiles)

454
src/rougail/config.py Normal file
View file

@ -0,0 +1,454 @@
"""
Config file for Rougail
Created by:
EOLE (http://eole.orion.education.fr)
Copyright (C) 2005-2018
Forked by:
Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021
Silique (https://www.silique.fr)
Copyright (C) 2022-2024
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from pathlib import Path
from tiramisu import Config
from ruamel.yaml import YAML
from .utils import _, load_modules, normalize_family
from .convert import RougailConvert
RENAMED = {'dictionaries_dir': 'main_dictionaries',
'variable_namespace': 'main_namespace',
'functions_file': 'functions_files',
}
NOT_IN_TIRAMISU = {'custom_types': {},
}
SUBMODULES = None
def get_sub_modules():
global SUBMODULES
if SUBMODULES is None:
SUBMODULES = {}
for submodule in Path(__file__).parent.iterdir():
if submodule.name.startswith('_') or not submodule.is_dir():
continue
config_file = submodule / 'config.py'
if config_file.is_file():
SUBMODULES[submodule.name] = load_modules('rougail.' + submodule.name + '.config', str(config_file))
return SUBMODULES
def get_level(module):
return module['level']
class _RougailConfig:
def __init__(self,
backward_compatibility: bool,
root,
extra_vars: dict
):
self.backward_compatibility = backward_compatibility
self.root = root
self.config = Config(
self.root,
)
self.config.property.read_only()
self.extra_vars = extra_vars
self.not_in_tiramisu = NOT_IN_TIRAMISU | extra_vars
for variable, default_value in self.not_in_tiramisu.items():
if not isinstance(default_value, str):
default_value = default_value.copy()
setattr(self, variable, default_value)
def copy(self):
rougailconfig = _RougailConfig(self.backward_compatibility, self.root, self.extra_vars)
rougailconfig.config.value.importation(self.config.value.exportation())
rougailconfig.config.property.importation(self.config.property.exportation())
rougailconfig.config.property.read_only()
for variable in self.not_in_tiramisu:
value = getattr(self, variable)
if not isinstance(value, str):
value = value.copy()
setattr(rougailconfig, variable, value)
return rougailconfig
def __setitem__(self,
key,
value,
) -> None:
if key in self.not_in_tiramisu:
setattr(self, key, value)
else:
self.config.property.read_write()
if key == 'export_with_import':
key = 'not_export_with_import'
key = RENAMED.get(key, key)
option = self.config.option(key)
if option.isoptiondescription() and option.isleadership():
leader = list(value)
option.leader().value.reset()
option.leader().value.set(leader)
follower = option.followers()[0]
for idx, val in enumerate(value.values()):
self.config.option(follower.path(), idx).value.set(val)
elif key == 'not_export_with_import':
option.value.set(not value)
else:
option.value.set(value)
self.config.property.read_only()
def __getitem__(self,
key,
) -> None:
if key in self.not_in_tiramisu:
return getattr(self, key)
if key == 'export_with_import':
key = 'not_export_with_import'
option = self.config.option(key)
if option.isoptiondescription() and option.isleadership():
return self.get_leadership(option)
ret = self.config.option(key).value.get()
if key == 'not_export_with_import':
return not ret
return ret
def get_leadership(self,
option
) -> dict:
leader = None
followers = []
for opt, value in option.value.get().items():
if opt.issymlinkoption():
continue
if leader is None:
leader = value
else:
followers.append(value)
return dict(zip(leader, followers))
def parse(self, config) -> str:
for option in config:
if option.isoptiondescription():
yield from self.parse(option)
elif not option.issymlinkoption():
yield f'{option.path()}: {option.value.get()}'
def __repr__(self):
self.config.property.read_write()
try:
values = "\n".join(self.parse(self.config))
except Exception as err:
values = str(err)
self.config.property.read_only()
return values
class FakeRougailConvert(RougailConvert):
def __init__(self,
add_extra_options: bool,
) -> None:
self.add_extra_options = add_extra_options
super().__init__({})
def load_config(self) -> None:
self.sort_dictionaries_all = False
self.main_namespace = None
self.suffix = ''
self.custom_types = {}
self.functions_files = []
self.modes_level = []
self.extra_annotators = []
self.base_option_name = "baseoption"
self.export_with_import = True
self.internal_functions = []
self.plugins = ['structural_commandline']
self.add_extra_options = self.add_extra_options
def get_rougail_config(*,
backward_compatibility: bool=True,
add_extra_options: bool=True,
) -> _RougailConfig:
if backward_compatibility:
main_namespace_default = 'rougail'
else:
main_namespace_default = 'null'
rougail_options = """default_dictionary_format_version:
description: Dictionary format version by default, if not specified in dictionary file
alternative_name: v
choices:
- '1.0'
- '1.1'
mandatory: false
main_dictionaries:
description: 'Directories where dictionary files are placed'
type: unix_filename
alternative_name: m
params:
allow_relative: True
test_existence: True
types:
- directory
multi: true
sort_dictionaries_all:
description: Sort dictionaries from differents directories
negative_description: Sort dictionaries directory by directory
default: false
main_namespace:
description: Main namespace name
default: MAIN_MAMESPACE_DEFAULT
alternative_name: s
mandatory: false
extra_dictionaries:
description: Extra namespaces
type: leadership
disabled:
variable: main_namespace
when: null
names:
description: 'Extra namespace name'
alternative_name: xn
multi: true
mandatory: false
directories:
description: Directories where extra dictionary files are placed
alternative_name: xd
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- directory
multi: true
upgrade:
description: Update dictionaries to newest Rougail format version
negative_description: Do not update dictionaries to newest Rougail format version
default: false
upgrade_options:
description: Update informations
disabled:
variable: upgrade
when: false
main_dictionaries:
description: 'Directories where dictionary files will be placed'
default:
variable: __.main_dictionaries
extra_dictionary:
description: 'Directories where extra files will be placed'
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- directory
disabled:
variable: __.main_namespace
when: null
functions_files:
description: File with functions
alternative_name: c
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- file
multi: true
mandatory: false
modes_level:
description: All modes level available
default:
- basic
- standard
- advanced
commandline: false
default_family_mode:
description: Default mode for a family
default:
type: jinja
jinja: |
{{ modes_level[0] }}
validators:
- type: jinja
jinja: |
{% if default_family_mode not in modes_level %}
not in modes_level ({modes_level})
{% endif %}
commandline: false
default_variable_mode:
description: Default mode for a variable
default:
type: jinja
jinja: |
{{ modes_level[1] }}
validators:
- type: jinja
jinja: |
{% if default_variable_mode not in modes_level %}
not in modes_level ({modes_level})
{% endif %}
commandline: false
base_option_name:
description: Option name for the base option
default: baseoption
commandline: false
not_export_with_import:
description: In cache file, do not importation of Tiramisu and other dependencies
default: false
commandline: false
tiramisu_cache:
description: Tiramisu cache filename
alternative_name: t
type: unix_filename
mandatory: false
params:
allow_relative: true
internal_functions:
description: Name of internal functions that we can use as a function
multi: true
mandatory: false
commandline: false
extra_annotators:
description: Name of extra annotators
multi: true
mandatory: false
commandline: false
plugins:
description: Name of Rougail plugins
multi: true
mandatory: false
commandline: false
suffix:
description: Suffix add to generated option name
default: ''
mandatory: false
commandline: false
""".replace('MAIN_MAMESPACE_DEFAULT', main_namespace_default)
processes = {'structural': [],
'output': [],
'user data': [],
}
for module in get_sub_modules().values():
data = module.get_rougail_config()
processes[data['process']].append(data)
# reorder
for process in processes:
processes[process] = list(sorted(processes[process], key=get_level))
rougail_process = """step: # Load and exporter steps
disabled:
variable: upgrade"""
for process in processes:
if processes[process]:
objects = processes[process]
rougail_process += """
{NAME}:
description: Select for {NAME}
alternative_name: {NAME[0]}
choices:
""".format(NAME=normalize_family(process),
)
for obj in objects:
rougail_process += f" - {obj['name']}\n"
if process == 'structural':
rougail_process += " commandline: false"
elif process == 'user data':
rougail_process += """ multi: true
mandatory: false
"""
hidden_outputs = [process['name'] for process in processes['output'] if not process.get('allow_user_data', True)]
if hidden_outputs:
rougail_process += """ hidden:
type: jinja
jinja: |
"""
for hidden_output in hidden_outputs:
rougail_process += """ {% if _.output == 'NAME' %}
Cannot load user data for NAME output
{% endif %}
""".replace('NAME', hidden_output)
else:
rougail_process += ' default: {DEFAULT}'.format(DEFAULT=objects[0]['name'])
else:
rougail_process += """
{NAME}:
description: Select for {NAME}
hidden: true
mandatory: false
multi: true
""".format(NAME=normalize_family(process),
)
rougail_options += rougail_process
convert = FakeRougailConvert(add_extra_options)
convert._init()
convert.namespace = None
convert.parse_root_file(
'rougail.config',
'',
'1.1',
YAML().load(rougail_options),
)
extra_vars = {}
for process in processes:
for obj in processes[process]:
if 'extra_vars' in obj:
extra_vars |= obj['extra_vars']
if not 'options' in obj:
continue
convert.parse_root_file(
f'rougail.config.{obj["name"]}',
'',
'1.1',
YAML().load(obj['options']),
)
tiram_obj = convert.save(None)
optiondescription = {}
exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122
return _RougailConfig(backward_compatibility,
optiondescription["option_0"],
extra_vars=extra_vars,
)
RougailConfig = get_rougail_config()

View file

@ -1,618 +0,0 @@
"""
Config file for Rougail
Created by:
EOLE (http://eole.orion.education.fr)
Copyright (C) 2005-2018
Forked by:
Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021
Silique (https://www.silique.fr)
Copyright (C) 2022-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from pathlib import Path
from tiramisu import Config
from tiramisu.error import display_list
from ruamel.yaml import YAML
from ..utils import _, load_modules
from ..tiramisu import normalize_family, tiramisu_display_name
from ..convert import RougailConvert
from ..convert.object_model import get_convert_option_types
RENAMED = {
"dictionaries_dir": "main_structural_directories",
"main_dictionaries": "main_structural_directories",
"variable_namespace": "main_namespace",
"functions_file": "functions_files",
}
NOT_IN_TIRAMISU = {
"custom_types": {},
}
SUBMODULES = None
def get_sub_modules():
global SUBMODULES
if SUBMODULES is None:
SUBMODULES = {}
for submodule in Path(__file__).parent.parent.iterdir():
if submodule.name.startswith("_") or not submodule.is_dir():
continue
config_file = submodule / "config.py"
if config_file.is_file():
SUBMODULES[submodule.name] = load_modules(
"rougail." + submodule.name + ".config", str(config_file)
)
return SUBMODULES
def get_level(module):
return float(module["level"]) + {
"structural": 0.1,
"user data": 0.2,
"output": 0.3,
}.get(module["process"])
class _RougailConfig:
def __init__(self, backward_compatibility: bool, add_extra_options: bool):
self.backward_compatibility = backward_compatibility
self.add_extra_options = add_extra_options
self.root = None
def copy(self, backward_compatibility=None):
if not self.root:
self.generate_config()
config = self.config.config.copy()
config.value.importation(self.config.value.exportation())
config.property.importation(self.config.property.exportation())
config.property.read_only()
if backward_compatibility is None:
backward_compatibility = self.backward_compatibility
rougailconfig = _RougailConfig(backward_compatibility, self.add_extra_options)
rougailconfig.root = self.root
rougailconfig.config = config
rougailconfig.extra_vars = self.extra_vars.copy()
rougailconfig.not_in_tiramisu = NOT_IN_TIRAMISU | rougailconfig.extra_vars
for variable in self.not_in_tiramisu:
value = getattr(self, variable)
if not isinstance(value, str):
value = value.copy()
setattr(rougailconfig, variable, value)
return rougailconfig
def generate_config(self):
self.root, extra_vars = _rougail_config(
self.backward_compatibility, self.add_extra_options
)
self.config = Config(
self.root,
display_name=tiramisu_display_name,
)
self.extra_vars = extra_vars
self.not_in_tiramisu = NOT_IN_TIRAMISU | extra_vars
for variable, default_value in self.not_in_tiramisu.items():
if not isinstance(default_value, str):
default_value = default_value.copy()
setattr(self, variable, default_value)
self.config.property.read_only()
def __setitem__(
self,
key,
value,
) -> None:
if self.root is None:
self.generate_config()
if key in self.not_in_tiramisu:
setattr(self, key, value)
else:
self.config.property.read_write()
key = RENAMED.get(key, key)
option = self.config.option(key)
if option.isoptiondescription() and option.isleadership():
if isinstance(value, RConfigLeadership):
leader = value.leader
followers = value.followers
else:
leader = list(value)
followers = value.values()
option.leader().value.reset()
option.leader().value.set(leader)
follower = option.followers()[0]
for idx, val in enumerate(followers):
self.config.option(follower.path(), idx).value.set(val)
else:
option.value.set(value)
self.config.property.read_only()
def __getitem__(
self,
key,
) -> None:
if self.root is None:
self.generate_config()
if key in self.not_in_tiramisu:
return getattr(self, key)
option = self.config.option(key)
if option.isoptiondescription() and option.isleadership():
return self.get_sequence(option)
ret = self.config.option(key).value.get()
return ret
def __contains__(
self,
key,
) -> None:
try:
self.__getitem__(key)
except AttributeError:
return False
return True
def get_sequence(self, option) -> dict:
leader = None
followers = []
for opt, value in option.value.get().items():
if opt.issymlinkoption():
continue
if leader is None:
leader = value
else:
followers.append(value)
return RConfigLeadership(self.config, option, leader, followers)
def parse(self, config) -> str:
for option in config:
if option.isoptiondescription():
yield from self.parse(option)
elif not option.issymlinkoption():
yield f"{option.path()}: {option.value.get()}"
def __repr__(self):
if self.root is None:
self.generate_config()
self.config.property.read_write()
try:
values = "\n".join(self.parse(self.config))
except Exception as err:
values = str(err)
self.config.property.read_only()
return values
class RConfigLeadership:
def __init__(self, config, option, leader, followers):
self.config = config
self.option = option
self.leader = leader
self.followers = followers
def items(self):
return dict(zip(self.leader, self.followers)).items()
def __setitem__(
self,
key,
value,
) -> None:
self.config.property.read_write()
names = self.option.option("names")
leader = names.value.get()
leader.append(key)
names.value.set(leader)
directories = self.option.option("directories", len(leader) - 1)
directories.value.set(value)
self.leader.append(key)
self.followers.append(value)
self.config.property.read_only()
def __getitem__(self, key):
option = self.option.option(key)
if option.isleader():
return option.value.get()
return [option.index(idx).value.get() for idx in range(option.value.len())]
def __repr__(self):
return dict(zip(self.leader, self.followers))
def set_follower(self, key, idx, value):
self.config.property.read_write()
self.option.option(key, idx).value.set(value)
self.config.property.read_only()
def reset(self):
self.config.property.read_write()
names = self.option.option("names").value.reset()
self.config.property.read_only()
class StaticRougailConvert(RougailConvert):
def __init__(
self,
add_extra_options: bool,
rougailconfig: dict = {},
) -> None:
self.add_extra_options = add_extra_options
super().__init__(rougailconfig)
def load_config(self) -> None:
self.sort_structural_files_all = False
self.main_namespace = None
self.suffix = ""
self.custom_types = {}
self.functions_files = []
self.modes_level = []
self.extra_annotators = []
self.base_option_name = "baseoption"
self.export_with_import = True
self.internal_functions = []
self.force_optional = False
self.structurals = ["commandline"]
self.user_data = []
self.output = None
self.tiramisu_cache = False
# self.tiramisu_cache = "a.py"
self.load_unexist_redefine = False
def get_common_rougail_config(
*,
backward_compatibility=True,
) -> str:
rougail_options = f"""default_structural_format_version:
description: {_('Default version of the structural file format')}
help: {_('This value is only used if the version is not set in the structural file')}
alternative_name: v
choices:
- '1.0'
- '1.1'
mandatory: false
types:
description: {_("File with personalize types")}
help: {_("This file contains personalize types in Rougail format for structure files")}
type: unix_filename
params:
allow_relative: true
test_existence: true
multi: true
mandatory: false
functions_files:
description: {_("File with functions")}
help: {_("This file contains filters and additional Jinja2 functions usable in structure files")}
type: unix_filename
params:
allow_relative: true
test_existence: true
types:
- file
multi: true
mandatory: false
modes_level:
description: {_("All modes level available")}
multi: true
mandatory: false
"""
if backward_compatibility:
rougail_options += """ default:
- basic
- standard
- advanced
"""
rougail_options += f"""
default_family_mode:
description: {_("Default mode for a family")}
default:
jinja: |
{{% if modes_level %}}
{{{{ modes_level[0] }}}}
{{% endif %}}
description: {_('the first one defined in "modes_level"')}
disabled:
jinja: |
{{% if not modes_level %}}
No mode
{{% endif %}}
description: {_('when no mode is defined in "modes_level"')}
validators:
- type: jinja
jinja: |
{{% if default_family_mode not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
description: {_('this mode must be available in "modes_level"')}
commandline: false
default_variable_mode:
description: {_("Default mode for a variable")}
default:
jinja: |
{{% if modes_level %}}
{{% if modes_level | length == 1 %}}
{{{{ modes_level[0] }}}}
{{% else %}}
{{{{ modes_level[1] }}}}
{{% endif %}}
{{% endif %}}
description: {_('if the variable "modes_level" is defined, the default value is the second available element, otherwise, the first')}
disabled:
jinja: |
{{% if not modes_level %}}
No mode
{{% endif %}}
description: {_('when no mode is defined in "modes_level"')}
validators:
- type: jinja
jinja: |
{{% if default_variable_mode not in modes_level %}}
not in modes_level ({{modes_level}})
{{% endif %}}
description: {_('this mode must be available in "modes_level"')}
commandline: false
base_option_name:
description: {_("Option name for the base option")}
default: baseoption
commandline: false
export_with_import:
description: {_("In cache file, do not importation of Tiramisu and other dependencies")}
default: true
commandline: false
tiramisu_cache:
description: {_("Store Tiramisu cache filename")}
help: "{_("This file contains the Tiramisu instructions used internally to load the variables.\n\nThis file can be used for debugging")}"
alternative_name: t
type: unix_filename
mandatory: false
commandline: false
params:
allow_relative: true
types:
- file
internal_functions:
description: {_("Name of internal functions that we can use as a function")}
multi: true
mandatory: false
commandline: false
extra_annotators:
description: {_("Name of extra annotators")}
multi: true
mandatory: false
commandline: false
suffix:
description: {_("Suffix add to generated options name")}
default: ''
mandatory: false
commandline: false
force_optional:
description: {_("Every variables in calculation are optionals")}
default: False
load_unexist_redefine:
description: {_("Loads redefine variables even if there don't already exists")}
commandline: false
default: False
secret_manager: # {_("The secret manager")}
pattern:
description: {_("The secret pattern to constructing the name of the item searched for in the secret manager")}
help: {_("The pattern is in Jinja2 format")}
default: "{{{{ project }}}} - {{{{ environment }}}} - {{{{ service }}}} - {{{{ user }}}}"
"""
processes = {
"structural": [],
"user data": [],
"output": [],
}
processes_tr = {
"structural": _("structural"),
"user data": _("user data"),
"output": _("output"),
}
processes_empty = []
for module in get_sub_modules().values():
data = module.get_rougail_config(backward_compatibility=backward_compatibility)
if data["process"]:
processes[data["process"]].append(data)
else:
processes_empty.append(data["options"])
# reorder
for process in processes:
processes[process] = list(sorted(processes[process], key=get_level))
rougail_process = "step: # Load and exporter steps"
for process in processes:
if processes[process]:
objects = processes[process]
process_name = normalize_family(process)
tr_process_name = processes_tr[process]
rougail_process += f"""
{process_name}:
description: {_('select for {0}').format(tr_process_name)}
"""
if process != "structural":
rougail_process += """ alternative_name: {NAME[0]}
""".format(
NAME=normalize_family(process),
)
rougail_process += """ choices:
"""
for obj in objects:
rougail_process += f" - {obj['name']}\n"
if process == "structural":
rougail_process += """ multi: true
default:
- directory
"""
elif process == "user data":
rougail_process += """ multi: true
mandatory: false"""
hidden_outputs = [
process["name"]
for process in processes["output"]
if not process.get("allow_user_data", True)
]
if hidden_outputs:
rougail_process += """
disabled:
type: jinja
jinja: |
"""
for hidden_output in hidden_outputs:
rougail_process += """ {% if _.output is not propertyerror and _.output == 'NAME' %}
Cannot load user data for NAME output
{% endif %}
""".replace(
"NAME", hidden_output
)
rougail_process += f""" description: {_('outputs {0} did not allow user data')}
""".format(
display_list(hidden_outputs, add_quote=True, separator="or")
)
elif objects:
rougail_process += " default: {DEFAULT}".format(
DEFAULT=objects[0]["name"]
)
else:
if process == "output":
prop = "hidden"
else:
prop = "disabled"
rougail_process += """
{NAME}:
description: Select for {NAME}
mandatory: false
{PROP}: true
multi: true
default: ["You haven't installed \\\"{NAME}\\\" package for rougail"]
validators:
- jinja: Please install a rougail-{NAME}-* package.
""".format(
NAME=normalize_family(process),
PROP=prop,
)
rougail_process += f"""
define_default_params: false # {_('Override default parameters for option type')}
default_params:
description: {_("Default parameters for option type")}
disabled:
variable: _.define_default_params
when: false
"""
for typ, typ_description, params in get_convert_option_types():
rougail_process += f"""
{typ}: # {typ_description}
"""
for key, key_type, description, multi, value, choices in params:
rougail_process += f"""
{key}:
"""
if description:
rougail_process += f""" description: "{description}"
"""
rougail_process += f""" type: {key_type}
multi: {multi}
mandatory: false
default: {value}
"""
if choices:
rougail_process += " choices:\n"
for choice in choices:
rougail_process += f" - {choice}\n"
rougail_options += rougail_process
return processes, processes_empty, rougail_options
def _rougail_config(
backward_compatibility: bool = True,
add_extra_options: bool = True,
) -> "OptionDescription":
processes, processes_empty, rougail_options = get_common_rougail_config(
backward_compatibility=backward_compatibility
)
convert = StaticRougailConvert(add_extra_options)
convert.init()
convert.namespace = None
convert.parse_root_file(
["rougail.config"],
"",
"1.1",
YAML().load(rougail_options),
)
for process_empty in processes_empty:
convert.parse_root_file(
["rougail.config"],
"",
"1.1",
YAML().load(process_empty),
)
extra_vars = {}
objects = []
for obj in sorted(
[obj for objects in processes.values() for obj in objects], key=get_level
):
if "extra_vars" in obj:
extra_vars |= obj["extra_vars"]
if not "options" in obj:
continue
if not isinstance(obj["options"], list):
options = [obj["options"]]
else:
options = obj["options"]
for option in options:
convert.parse_root_file(
[f'rougail.{obj["process"].replace(" ", "_")}_{obj["name"]}.config'],
"",
"1.1",
YAML().load(option),
)
tiram_obj = convert.save()
optiondescription = {}
exec(tiram_obj, {}, optiondescription) # pylint: disable=W0122
return optiondescription["option_0"], extra_vars
def get_rougail_config(
*,
backward_compatibility: bool = True,
add_extra_options: bool = True,
) -> _RougailConfig:
return _RougailConfig(
backward_compatibility,
add_extra_options,
)
RougailConfig = get_rougail_config()

1351
src/rougail/convert.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,82 +0,0 @@
"""Silique (https://www.silique.fr)
Copyright (C) 2022-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from pathlib import Path
from typing import Optional
from tiramisu import Config
from warnings import warn
from .convert import RougailConvert, SUPPORTED_VERSION
from ..types import rougail_type
from ..config import RougailConfig
from ..user_data import UserData
from ..tiramisu import tiramisu_display_name
class Rougail(UserData):
"""Main Rougail object"""
def __init__(
self,
rougailconfig: Optional[RougailConfig] = None,
load_from_tiramisu_cache: bool = False,
) -> None:
if rougailconfig is None:
rougailconfig = RougailConfig
self.rougailconfig = rougailconfig
self.load_from_tiramisu_cache = (
load_from_tiramisu_cache
and Path(self.rougailconfig["tiramisu_cache"]).is_file()
)
types = rougail_type(self.rougailconfig)
if not self.load_from_tiramisu_cache:
self.converted = RougailConvert(self.rougailconfig, **types)
self.config = None
def get_root_option(self):
if not self.load_from_tiramisu_cache:
tiram_obj = self.converted.save()
else:
tiramisu_cache = self.rougailconfig["tiramisu_cache"]
with open(tiramisu_cache, "r", encoding="utf-8") as tiramisu:
tiram_obj = tiramisu.read()
optiondescription = {}
custom_types = {
custom.__name__: custom
for custom in self.rougailconfig["custom_types"].values()
}
exec(tiram_obj, custom_types, optiondescription) # pylint: disable=W0122
return optiondescription["option_0"]
def run(self, *, name: Optional[str] = None):
"""Get Tiramisu Config"""
if not self.config:
self.config = Config(
self.get_root_option(),
name=name,
display_name=tiramisu_display_name,
)
self.config.property.read_write()
return self.config
def get_config(self):
warn(
"get_config is deprecated, use run instead",
DeprecationWarning,
stacklevel=2,
)
return self.run()

View file

@ -1,789 +0,0 @@
"""Takes a bunch of Rougail YAML dispatched in differents folders
as an input and outputs a Tiramisu's file.
Silique (https://www.silique.fr)
Copyright (C) 2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import logging
from warnings import warn
from pydantic import ValidationError
from typing import (
Any,
Iterator,
Literal,
Optional,
)
from tiramisu.error import display_list
from .object_model import (
CALCULATION_TYPES,
CALCULATION_PROPERTY_TYPES,
PROPERTY_ATTRIBUTE,
PARAM_TYPES,
AnyParam,
)
from ..i18n import _
from ..error import DictConsistencyError
class CollectFamily:
def family_collect(self) -> None:
if self.parameters is None:
self.parameters = {}
if self.user_type == "dynamic":
# FIXME code here only for support 1.0 dynamic flavor
# DictConsistencyError should be place in annotation
if "{{ identifier }}" not in self.name:
if "{{ suffix }}" in self.name:
self.name = self.name.replace("{{ suffix }}", "{{ identifier }}")
self.path = self.path.replace("{{ suffix }}", "{{ identifier }}")
elif "variable" in self.parameters:
self.name += "{{ identifier }}"
self.path += "{{ identifier }}"
elif self.raises:
msg = f'dynamic family name must have "{{{{ identifier }}}}" in his name for "{self.path}"'
raise DictConsistencyError(msg, 13, self.sources)
if self.version == "1.0":
if self.raises and "variable" not in self.parameters:
raise DictConsistencyError(
f'dynamic family must have "variable" attribute for "{self.path}"',
101,
self.sources,
)
if self.raises and "dynamic" in self.parameters:
raise DictConsistencyError(
'variable and dynamic cannot be set together in the dynamic family "{self.path}"',
100,
self.sources,
)
self.parameters["dynamic"] = {
"type": "variable",
"variable": self.parameters["variable"],
"propertyerror": False,
"allow_none": True,
}
del self.parameters["variable"]
if "dynamic" not in self.parameters and "variable" in self.parameters:
self.parameters["dynamic"] = {
"type": "variable",
"variable": self.parameters["variable"],
"propertyerror": False,
"allow_none": True,
}
del self.parameters["variable"]
if self.version != "1.0":
warning = f'"variable" attribute in dynamic family "{self.path}" is depreciated in {display_list(self.sources)}'
warn(
warning,
DeprecationWarning,
stacklevel=2,
)
self.object = self.objectspace.family_objects[0]
else:
self.object = self.objectspace.family_objects[-1]
self.split_param_family_children()
def split_param_family_children(
self,
) -> None:
"""Family declaration mix variable object and family attributes
Here we separate attribute (which is the correct self.parameters content and variable declaration
"""
new_parameters = {}
children = self.parameters
# when an attribute starts with "_", the variable name without this "_" is a variable
sub_variables = [
key[1:]
for key in self.parameters
if key.startswith("_") and key[1:] in self.parameters
]
# and known variables
if self.test_exists and self.path in self.objectspace.paths:
sub_variables.extend(
[p.rsplit(".", 1)[-1] for p in self.objectspace.parents[self.path]]
)
attributes = self.object["attrs"]
attributes_types = self.object["attributes_types"]
if self.types:
types_children = list(self.types.children)
else:
types_children = []
for key, value in list(children.items()):
if self.raises and not isinstance(key, str):
raise DictConsistencyError(
f'the key "{key}" is not in string format for family {self.path}',
103,
self.sources,
)
if key.startswith("_"):
# if key starts with _, it's an attribute
if key == "_type" and self.types:
children.pop(key)
else:
new_parameters[key[1:]] = children.pop(key)
elif (
key in types_children
or key not in attributes
or key in sub_variables
or not self.parameter_is_an_attributes(key, value, attributes_types)
):
if key == "type" and self.types and key not in types_children:
children.pop(key)
else:
new_parameters[key] = children.pop(key)
if self.version != "1.0" and not new_parameters and self.comment:
new_parameters["description"] = self.comment
self.children = children
self.parameters = new_parameters
class CollectVariable:
def variable_collect(self) -> None:
obj = self.parameters
if self.version == "1.0" or isinstance(obj, dict):
if obj is None:
# only with self.version to 1.0
obj = {}
self.parameters = obj
self.parse_type_params()
self.parse_secret_manager()
if self.raises and not self.check_no_extra_keys:
extra_attrs = set(obj) - self.object["attrs"]
if extra_attrs:
raise DictConsistencyError(
f'"{self.path}" is not a valid variable, there are additional '
f'attributes: "{", ".join(extra_attrs)}"',
65,
self.sources,
)
else:
self.parameters = {"default": obj}
if self.comment:
self.parameters["description"] = self.comment
def parse_type_params(self):
"""Parse variable params"""
if "params" not in self.parameters:
return
params = self.parameters["params"]
if isinstance(params, list):
# the conversion has already be done (in types purpose)
for param in params:
if self.raises and not isinstance(param, AnyParam):
raise DictConsistencyError(
_("params must be a dict for {0}").format(self.path),
55,
self.sources,
)
return
elif self.raises and not isinstance(params, dict):
raise DictConsistencyError(
_("params must be a dict for {0}").format(self.path),
55,
self.sources,
)
new_params = []
namespace = self.objectspace.namespace
for key, val in params.items():
try:
new_params.append(
AnyParam(
key=key,
value=val,
type="any",
path=None,
attribute=None,
family_is_dynamic=None,
namespace=namespace,
xmlfiles=self.sources,
)
)
except ValidationError as err:
if self.raises:
raise DictConsistencyError(
_('"{0}" has an invalid "params" for {1}: {2}').format(
key, self.path, err
),
54,
self.sources,
) from err
self.parameters["params"] = new_params
def parse_secret_manager(self):
"""Parse variable secret_manager"""
if "secret_manager" not in self.parameters:
return
secret_manager = {
"type": "jinja",
"jinja": self.objectspace.secret_pattern,
"params": self.parameters["secret_manager"],
}
self.set_calculation(
"secret_manager",
secret_manager,
)
class CollectType:
"""Determine the option type
1/ self.option_type must be "variable" or "family" option type
needs to determinate if the option is a variable or a family
an option is a family if:
- user specified a know family type: family, sequence (user must set it explicitly) or dynamic)
- has a family custom type
- has "dynamic" attribute (a variable could not has dynamic attribut)
- it's already a family (so we are certainly in redefine purpose
otherwise it's a variable
2/ self.user_type must be a more specilized variable or family type defined by the user
"""
def set_option_types(self):
if isinstance(self.parameters, dict):
self.set_user_type()
self.set_dynamic_user_type()
else:
self.short_hand_variable()
self.set_user_redefined()
self.variable_in_sequence()
self.family_or_variable()
if self.user_type:
logging.info(
"family_or_variable: %s is a %s (%s)",
self.path,
self.option_type,
self.user_type,
)
else:
logging.info("family_or_variable: %s is a %s", self.path, self.option_type)
def set_user_type(
self,
) -> None:
"""Check 'type' attributes and determine the option type"""
for type_name in ["_type", "type"]:
if type_name not in self.parameters or not isinstance(
self.parameters[type_name], str
):
continue
self.user_type = self.parameters[type_name]
if self.user_type in self.objectspace.custom_family_types:
self.set_custom_type(
self.objectspace.custom_family_types[self.user_type]
)
if self.user_type is None:
self.object = self.objectspace.family_objects[-1]
else:
self.set_object_user_type_family()
break
elif self.user_type in self.objectspace.custom_variable_types:
self.set_custom_type(
self.objectspace.custom_variable_types[self.user_type]
)
if self.user_type is None:
self.object = self.objectspace.variable_objects[0]
else:
self.set_object_user_type_variable()
break
self.object = None
self.set_object_user_type_family()
if not self.object:
self.set_object_user_type_variable()
if self.raises and not self.object:
msg = _('cannot determine the type of the {0} "{1}"').format(
self.user_type, self.path
)
raise DictConsistencyError(msg, 43, self.sources)
break
def set_custom_type(self, custom: dict, from_parent: bool = False) -> None:
if self.raises and self.test_exists and self.path in self.objectspace.paths:
msg = f'cannot redefine "{self.path}" object to a custom type'
raise DictConsistencyError(msg, 64, self.sources)
self.types = custom
self.types.name = self.name
self.types.path = self.path
self.types.namespace = self.namespace
self.types.help = None
self.types.tags = []
if not from_parent:
self.types.parameters["help"] = None
self.types.parameters["tags"] = []
self.option_type = self.types.option_type
self.user_type = self.types.user_type
self.sources = self.types.sources + self.sources
self.object = self.types.object
if (
not from_parent
and self.option_type == "variable"
and "type" in self.parameters
):
self.parameters.pop("type")
def set_object_user_type_family(self):
for obj in self.objectspace.family_objects:
if self.user_type in obj["types"]:
self.option_type = "family"
self.object = obj
return
def set_object_user_type_variable(self):
for obj in self.objectspace.variable_objects:
if self.user_type in obj["types"]:
self.option_type = "variable"
self.object = obj
return
def set_dynamic_user_type(self) -> None:
if self.user_type:
return
for type_name in ["_dynamic", "dynamic"]:
if type_name in self.parameters and isinstance(
self.parameters[type_name], (list, dict)
):
self.user_type = "dynamic"
self.option_type = "family"
break
def set_user_redefined(self) -> None:
if not self.test_exists or self.path not in self.objectspace.paths:
return
# it's already a variable or a family
old_option_type = self.option_type if self.user_type else None
self.option_type = (
"family" if self.path in self.objectspace.families else "variable"
)
if self.raises and old_option_type and self.option_type != old_option_type:
msg = f'the {old_option_type} "{self.path}" is redefine as a {self.option_type}, which is not allowed'
raise DictConsistencyError(msg, 11, self.sources)
if self.user_type:
return
self.user_type = self.objectspace.paths[self.path].type
if self.option_type == "family":
for obj in self.objectspace.family_objects:
if self.user_type in obj["types"]:
self.object = obj
break
else:
self.object = self.objectspace.variable_objects[0]
else:
for obj in self.objectspace.variable_objects:
if self.user_type in obj["types"]:
self.object = obj
break
else:
self.object = self.objectspace.variable_objects[-1]
def short_hand_variable(self):
if self.option_type:
return
# it's something like: "my_variable:" or "my_variable: True"
self.option_type = "variable"
self.object = self.objectspace.variable_objects[0]
def variable_in_sequence(self):
# in a sequence there have only variables
if not self.option_type and self.family_is_sequence:
self.option_type = "variable"
if self.raises and not self.find_variable_object():
msg = f'"{self.path}" seems to be a family, which is not allowed in a family'
raise DictConsistencyError(msg, 17, self.sources)
def family_or_variable(
self,
) -> Literal["variable", "family"]:
"""check if all attributes are attributes of a variable"""
if self.option_type:
return
if not self.find_variable_object():
self.option_type = "family"
def find_variable_object(self) -> bool:
attrs = set(self.parameters)
for variable in self.objectspace.variable_objects:
if not attrs - variable["attrs"] and self.check_variable_parameters(
variable
):
self.option_type = "variable"
self.check_no_extra_keys = True
self.object = variable
return True
return False
def check_variable_parameters(self, variable):
attributes_types = variable["attributes_types"]
attrs = variable["attrs"]
for key, value in list(self.parameters.items()):
if key not in attrs:
return False
if not self.parameter_is_an_attributes(key, value, attributes_types):
return False
return True
def parameter_is_an_attributes(
self, key: str, value: Any, attributes_types: dict
) -> bool:
if value is None:
return True
if (
key in attributes_types["literals"]
and value in attributes_types["literals"][key]
):
return True
for k, typ in [
("strings", str),
("booleans", bool),
("integers", int),
("floats", float),
]:
if key in attributes_types[k] and isinstance(value, typ):
return True
if isinstance(value, dict):
if key in attributes_types["calculation"]:
return self.is_calculation(
key, value, attributes_types=attributes_types
)
if key in attributes_types["params"]:
return True
if isinstance(value, list):
current_value = value.copy()
for k, typ in [
("strings", str),
("booleans", bool),
("integers", int),
("floats", float),
]:
if key in attributes_types["lists"][k]:
for idx, val in reversed(list(enumerate(current_value))):
if val is not None and not isinstance(val, typ):
continue
del current_value[idx]
if not current_value:
return True
if key in attributes_types["lists"]["calculation"]:
for val in current_value:
if isinstance(val, dict) and not self.is_calculation(
key, val, inside_list=True, attributes_types=attributes_types
):
return False
return True
return False
class Collect(CollectType, CollectFamily, CollectVariable):
def __init__(
self,
objectspace: "ParserVariable",
name: str,
subpath: Optional[str],
parameters: dict,
comment: Optional[str],
parent_option: Optional["Collect"],
*,
raises: bool = True,
test_exists: bool = True,
) -> None:
self.sources_types = None
self.types = None
self.name = name
if not subpath:
path = name
else:
path = f"{subpath}.{name}"
self.raises = raises
self.test_exists = test_exists
if self.raises and name.startswith("_"):
msg = f'the variable or family "{self.path}" is incorrect, it must not starts with "_" character'
raise DictConsistencyError(msg, 16, obj["sources"])
self.path = path
self.subpath = subpath
self.parameters = parameters
self.comment = comment
self.objectspace = objectspace
self.namespace = objectspace.namespace
self.sources = objectspace.sources.copy()
self.user_type = None
self.option_type = None
if (
parent_option is not None
and parent_option.types is not None
and self.name in parent_option.types.children
):
self.set_custom_type(
parent_option.types.children[self.name], from_parent=True
)
self.check_no_extra_keys = False
if self.test_exists and path in objectspace.paths:
for source in reversed(self.objectspace.paths[path].xmlfiles):
self.sources.insert(0, source)
if parent_option:
self.family_is_sequence = parent_option.user_type in [
"leadership",
"sequence",
]
self.family_is_dynamic = parent_option.family_is_dynamic
self.parent_dynamic = parent_option.parent_dynamic
else:
self.family_is_sequence = False
self.family_is_dynamic = False
self.parent_dynamic = None
self.version = self.objectspace.version
self.set_option_types()
if self.user_type == "dynamic":
self.family_is_dynamic = True
self.parent_dynamic = subpath
if self.option_type == "family":
self.family_collect()
else:
self.variable_collect()
self.convert_calculated_parameters()
self.exists = self.is_exists()
self.redefine = self.is_redefine()
def convert_calculated_parameters(
self,
):
"""Parse option attributes and convert calculation"""
obj = self.parameters
for key, value in obj.items():
if self.is_calculation(
key,
value,
):
try:
self.set_calculation(
key,
value,
)
except ValidationError as err:
if self.raises:
raise DictConsistencyError(
_('the {0} "{1}" has an invalid "{2}": {3}').format(
self.option_type, self.path, key, err
),
84,
self.sources,
) from err
continue
if not isinstance(value, list):
continue
for idx, val in enumerate(value):
if not self.is_calculation(
key,
val,
inside_list=True,
):
continue
try:
self.set_calculation(
key,
val,
inside_list=True,
index=idx,
)
except ValidationError as err:
raise Exception(
f'the {option.type} "{option.path}" in "{display_list(option.sources)}" has an invalid "{key}" '
f"at index {idx}: {err}"
) from err
def is_dict(
self, key: str, value: Any, *, attributes_types: Optional[dict] = None
) -> bool:
"""it's a dict, so it's a new variables!"""
return isinstance(value, dict) and not self.is_calculation(
key, value, attributes_types=attributes_types
)
def is_calculation(
self,
attribute: str,
value: dict,
*,
attributes_types: Optional[dict] = None,
inside_list: bool = False,
):
"""Check if it's a calculation"""
if not isinstance(value, dict):
return False
if attributes_types is None:
attributes_types = self.object["attributes_types"]
if inside_list:
attributes_types = attributes_types["lists"]["calculation"]
else:
attributes_types = attributes_types["calculation"]
if attribute not in attributes_types:
return False
return self.manage_calculation_type(value)
def manage_calculation_type(self, value) -> bool:
"""Return true if the dict type is a calculation
If user set the type, it's easy, we just have to check if it's a known calculation type
Otherwise if we have an attribute with a known calculation type, we assume that is de calculation type
"""
if "type" in value:
return value["type"] in CALCULATION_TYPES
# auto set type
typ = set(CALCULATION_TYPES) & set(value)
# XXX variable could have identifier
if typ == {"variable", "identifier"}:
typ = {"variable"}
# XXX variable is also set to information
if typ == {"variable", "information"}:
typ = {"information"}
if len(typ) == 1:
value["type"] = typ.pop()
return True
return False
def set_calculation(
self,
attribute: str,
value: dict,
*,
obj: Optional[dict] = None,
inside_list: bool = False,
index: int = None,
):
"""This variable is a calculation"""
if obj is None:
obj = self.parameters
calculation_object = value.copy()
typ = calculation_object.pop("type")
namespace = self.objectspace.namespace
calculation_object["attribute_name"] = attribute
calculation_object["inside_list"] = inside_list
calculation_object["version"] = self.version
calculation_object["namespace"] = namespace
calculation_object["xmlfiles"] = self.sources
#
self.set_identifier_calculation_in_default_attribut(
attribute, calculation_object, inside_list, index
)
self.set_params_calculation(calculation_object, attribute)
#
return_type = calculation_object.get("return_type")
if (
return_type
and return_type not in self.objectspace.variable_objects[0]["types"]
):
raise Exception(
f'unknown "return_type" in {attribute} of variable "{self.path}"'
)
#
if self.raises and typ == "identifier" and not self.family_is_dynamic:
msg = f'identifier calculation for "{attribute}" in "{self.path}" cannot be set variable is not in dynamic family'
raise DictConsistencyError(msg, 53, self.sources)
if attribute in PROPERTY_ATTRIBUTE:
calc = CALCULATION_PROPERTY_TYPES[typ](**calculation_object)
else:
calc = CALCULATION_TYPES[typ](**calculation_object)
if index is None:
obj[attribute] = calc
else:
obj[attribute][index] = calc
def set_identifier_calculation_in_default_attribut(
self,
attribute: str,
calculation_object: dict,
inside_list: bool,
index: Optional[int],
) -> None:
if attribute != "default" or "identifier" not in calculation_object:
return
identifier = calculation_object["identifier"]
if self.is_calculation(
"identifier",
identifier,
attributes_types=self.objectspace.variable_objects[0]["attributes_types"],
inside_list=inside_list,
):
self.set_calculation(
"identifier",
identifier,
obj=calculation_object,
inside_list=inside_list,
index=index,
)
def set_params_calculation(self, calculation_object: dict, attribute: str) -> None:
if "params" not in calculation_object:
return
params = []
for key, value in calculation_object["params"].items():
if isinstance(value, dict) and "type" not in value:
self.set_param_type(value)
if not isinstance(value, dict) or "type" not in value:
param_typ = "any"
value = {
"value": value,
"type": "any",
}
else:
if self.version == "1.0" and value["type"] == "suffix":
value["type"] = "identifier"
param_typ = value["type"]
value["key"] = key
value["path"] = self.path
value["family_is_dynamic"] = self.family_is_dynamic
value["attribute"] = attribute
value["namespace"] = self.objectspace.namespace
value["xmlfiles"] = self.sources
if self.raises and param_typ not in PARAM_TYPES:
raise DictConsistencyError(
f'unknown type "{param_typ}" for "{self.path}"',
52,
self.sources,
)
try:
params.append(PARAM_TYPES[param_typ](**value))
except ValidationError as err:
if self.raises:
raise DictConsistencyError(
f'"{attribute}" has an invalid "{key}" for "{self.path}": {err}',
29,
self.sources,
) from err
calculation_object["params"] = params
def set_param_type(self, val):
# auto set type
param_typ = set(CALCULATION_TYPES) & set(val)
# XXX variable is also set to information
if param_typ == {"variable", "information"}:
param_typ = {"information"}
if len(param_typ) == 1:
val["type"] = list(param_typ)[0]
def is_redefine(self):
if (
self.path in self.objectspace.paths
and self.option_type == "family"
and not self.parameters
):
# allow loading family with no attribute loaded
return True
if self.types:
return True
return self.parameters.pop("redefine", False) or (
self.types and list(self.parameters) in [[], ["default"]]
)
def is_exists(self):
if self.version == "1.0" and self.option_type == "family":
return None
return self.parameters.pop("exists", None)

View file

@ -1,824 +0,0 @@
"""Takes a bunch of Rougail YAML dispatched in differents folders
as an input and outputs a Tiramisu's file.
Created by:
EOLE (http://eole.orion.education.fr)
Copyright (C) 2005-2018
Forked by:
Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021
Silique (https://www.silique.fr)
Copyright (C) 2022-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from pathlib import Path
from typing import (
Any,
Dict,
Iterator,
List,
Literal,
Optional,
Tuple,
Union,
get_type_hints,
)
from ruamel.yaml.comments import CommentedMap
from pydantic import ValidationError
from tiramisu.error import display_list
from ..annotator import SpaceAnnotator
from ..i18n import _
from ..tiramisu import CONVERT_OPTION, normalize_family
from .object_model import (
Calculation,
Dynamic,
Family,
Variable,
Choices,
Param,
Regexp,
SymLink,
VariableCalculation,
)
from .tiramisureflector import TiramisuReflector
from ..utils import load_modules
from .path import Paths
from .collect import Collect
from ..error import DictConsistencyError
property_types = Union[Literal[True], Calculation]
properties_types = Dict[str, property_types]
SUPPORTED_VERSION = ["1.0", "1.1"]
class Property:
def __init__(self) -> None:
self._properties: Dict[str, properties_types] = {}
def add(
self,
path: str,
property_: str,
value: property_types,
) -> None:
self._properties.setdefault(path, {})[property_] = value
def get(self, path: str) -> None:
return self._properties.setdefault(path, {})
def remove(self, path: str, property_: str) -> None:
del self._properties[path][property_]
def __getitem__(
self,
path: str,
) -> properties_types:
return self._properties.get(path, {})
def __contains__(
self,
path: str,
) -> bool:
return path in self._properties
information_types = Dict[str, Union[str, int, float, bool]]
class Informations:
def __init__(self) -> None:
self._data: Dict[str, information_types] = {}
def add(
self,
path: str,
key: str,
data: Any,
) -> None:
if path not in self._data:
self._data[path] = {}
if key in self._data[path]:
raise Exception(f'an information "{key}" is already present in "{path}"')
self._data[path][key] = data
def get(
self,
path: str,
) -> information_types:
return self._data.get(path, {})
class ParserVariable:
def __init__(self, rougailconfig):
self.rougailconfig = rougailconfig
self.load_config()
self.paths = Paths(None, True)
self.families = []
self.variables = []
self.parents = {".": []}
self.index = 0
self.reflector_names = {}
self.leaders = []
self.followers = []
self.dynamics_variable = {}
self.multis = {}
self.default_multi = {}
self.forced_descriptions = []
self.jinja = {}
#
self.convert_options = list(CONVERT_OPTION)
self.convert_options.extend(self.custom_types)
#
self.exclude_imports = []
self.informations = Informations()
self.properties = Property()
# self.choices = Appendable()
self.has_dyn_option = False
self.is_init = False
super().__init__()
def load_config(self) -> None:
rougailconfig = self.rougailconfig
self.suffix = rougailconfig["suffix"]
self.default_structural_format_version = rougailconfig[
"default_structural_format_version"
]
self.custom_types = rougailconfig["custom_types"]
self.functions_files = rougailconfig["functions_files"]
self.modes_level = rougailconfig["modes_level"]
if self.modes_level:
self.default_variable_mode = rougailconfig["default_variable_mode"]
self.default_family_mode = rougailconfig["default_family_mode"]
self.extra_annotators = rougailconfig["extra_annotators"]
self.base_option_name = rougailconfig["base_option_name"]
self.export_with_import = rougailconfig["export_with_import"]
self.internal_functions = rougailconfig["internal_functions"]
self.force_optional = rougailconfig["force_optional"]
self.add_extra_options = rougailconfig[
"structural_commandline.add_extra_options"
]
self.structurals = rougailconfig["step.structural"]
try:
self.user_data = rougailconfig["step.user_data"]
except:
self.user_data = []
try:
self.output = rougailconfig["step.output"]
except:
self.output = None
self.tiramisu_cache = rougailconfig["tiramisu_cache"]
self.load_unexist_redefine = rougailconfig["load_unexist_redefine"]
self.secret_pattern = rougailconfig["secret_manager.pattern"]
# change default initkwargs in CONVERT_OPTION
if (
hasattr(rougailconfig, "config")
and rougailconfig.config.option("define_default_params").value.get()
):
for sub_od in rougailconfig.config.option("default_params"):
for option in sub_od:
if option.owner.isdefault():
continue
convert_option = CONVERT_OPTION[sub_od.name()]
if "initkwargs" not in convert_option:
convert_option["initkwargs"] = {}
convert_option["initkwargs"][option.name()] = option.value.get()
def init(self):
if self.is_init:
return
root = Path(__file__).parent.parent
self.walker = None
self.variable = Variable
self.family = Family
for structural_name in self.structurals:
structural = f"structural_{structural_name}"
module_path = root / structural / "__init__.py"
if not module_path.is_file():
continue
module = load_modules(f"rougail.{structural}", str(module_path))
if "Variable" in module.__all__:
self.variable = type(
self.variable.__name__ + "_" + structural,
(self.variable, module.Variable),
{},
)
if "Family" in module.__all__:
self.family = type(
self.family.__name__ + "_" + structural,
(self.family, module.Family),
{},
)
if not self.walker and "Walker" in module.__all__:
self.walker = module.Walker
self.dynamic = type(Dynamic.__name__, (Dynamic, self.family), {})
self.choices = type(Choices.__name__, (Choices, self.variable), {})
self.regexp = type(Regexp.__name__, (Regexp, self.variable), {})
variable_types = self.convert_options.copy()
variable_types.remove("choice")
variable_types.remove("regexp")
variable_types.remove("symlink")
self.variable_objects = [
self.get_variable_object(obj, is_variable=True)
for obj in [
(self.variable, variable_types),
SymLink,
self.choices,
self.regexp,
]
]
self.family_objects = [
self.get_variable_object(obj, is_variable=False)
for obj in [self.dynamic, self.family]
]
self.is_init = True
def get_variable_object(self, obj, *, is_variable: bool) -> dict:
if isinstance(obj, tuple):
obj, types = obj
hint = get_type_hints(obj)
else:
hint = get_type_hints(obj)
types = self.get_types(hint)
return {
"object": obj,
"types": types,
"attrs": self.get_option_attrs(hint),
"attributes_types": self.get_attributes_types(hint, variable=is_variable),
}
def get_types(self, hint):
return hint["type"].__args__
def get_option_attrs(self, hint):
return frozenset( # pylint: disable=W0201
set(hint) - {"name", "path", "xmlfiles"} | {"redefine", "exists"}
)
###############################################################################################
# create, update or delete family or variable object
###############################################################################################
def family_or_variable(
self,
name: str,
subpath: str,
obj: dict,
comment: Optional[str],
*,
first_variable: bool = False,
custom_type: bool = False,
parent_option: "Collect" = None,
) -> None:
option = Collect(
self,
name,
subpath,
obj,
comment,
parent_option,
)
if option.option_type == "family":
parser = self.parse_family
else:
parser = self.parse_variable
parser(
option,
first_variable=first_variable,
custom_type=custom_type,
)
def parse_family(
self,
option: Collect,
*,
first_variable: bool = False,
custom_type: bool = False,
) -> None:
"""Parse a family"""
path = option.path
redefine = option.redefine
exists = option.exists
# if not redefine and not exists and option.user_type in self.custom_family_types:
types = option.types
if types:
self.add_family(
types,
custom_type=True,
)
if path not in self.paths:
if not self.load_unexist_redefine and exists is None and redefine:
raise Exception(
f'cannot redefine the inexisting family "{path}" in {display_list(option.sources)}'
)
if not self.load_unexist_redefine and exists is True:
return
self.add_family(
option,
custom_type=custom_type,
)
force_not_first = False
else:
if exists in [None, True] and not redefine:
msg = _('family "{0}" define multiple time').format(path)
raise DictConsistencyError(msg, 32, option.sources)
if self.load_unexist_redefine or exists in [None, True]:
objects = option.parameters.copy()
objects["xmlfiles"] = option.sources
self.paths.add(
option,
self.paths[path].model_copy(update=objects),
force=True,
)
force_not_first = types == None
children = option.children
for idx, key in enumerate(self.list_children(option, types)):
if key in children:
value = children[key]
comment = self.get_comment(key, children)
else:
value = {}
comment = None
first_variable = not force_not_first and idx == 0
self.family_or_variable(
key,
path,
value,
comment,
first_variable=first_variable,
custom_type=custom_type,
parent_option=option,
)
def list_children(self, option, types):
"""
my_type: [var1, var2]
family: []
=> [var1, var2]
family: [var1, var3, var2]
=> [var1, var3, var2]
family: [var3]
=> [var1, var2, var3]
family: [var3, var2]
=> [var1, var3, var2]
family: [var1, var3]
=> [var1, var2, var3]
"""
option_children = list(option.children)
if not types:
yield from option_children
return
types_children = list(types.children)
while True:
if not option_children and not types_children:
break
if not option_children:
yield from types_children
break
elif not types_children:
yield from option_children
break
elif option_children[0] == types_children[0]:
yield option_children.pop(0)
types_children.pop(0)
elif types_children[0] not in option_children:
yield types_children.pop(0)
else:
name = option_children.pop(0)
yield name
if name in types_children:
types_children.remove(name)
def add_family(
self,
option: Collect,
*,
custom_type: bool = False,
) -> None:
"""Add a new family"""
path = option.path
if custom_type:
self.change_namespaces(option.parameters)
family_obj = option.object["object"]
if option.user_type == "dynamic":
# FIXME only for version 1.0 purpose
if "variable" in option.parameters:
raise Exception(
f'dynamic family must not have "variable" attribute for "{path}" in {option.sources}'
)
data = dict(option.parameters)
data["xmlfiles"] = option.sources
data["namespace"] = option.namespace
data["path"] = path
data["version"] = option.version
try:
self.paths.add(
option,
family_obj(
name=option.name,
**data,
),
)
except ValidationError as err:
raise Exception(
f'invalid family "{path}" in "{display_list(option.sources)}": {err}'
) from err
self.set_name(
self.paths[path],
"optiondescription_",
)
if "." not in path:
parent = "."
else:
parent = path.rsplit(".", 1)[0]
self.parents[parent].append(path)
self.parents[path] = []
self.families.append(path)
if self.loaded_custom_types != None:
self.loaded_custom_types[path] = option
def parse_variable(
self,
option: Collect,
*,
first_variable: bool = False,
custom_type: bool = False,
) -> None:
"""Parse variable"""
redefine = option.redefine
exists = option.exists
path = option.path
if option.types:
redefine = True
self.add_variable(
option.types,
first_variable=first_variable,
custom_type=True,
)
if path not in self.paths:
if not self.load_unexist_redefine and exists is True:
# this variable must exist
# but it's not the case
# so do nothing
return
if not self.load_unexist_redefine and redefine:
msg = f'cannot redefine the inexisting variable "{path}"'
raise DictConsistencyError(msg, 46, option.sources)
self.add_variable(
option,
first_variable,
custom_type,
)
else:
if not self.load_unexist_redefine:
if exists is False:
return
if not redefine:
msg = _('variable "{0}" define multiple time').format(path)
raise DictConsistencyError(msg, 45, option.sources)
objects = option.parameters.copy()
objects["xmlfiles"] = option.sources
self.paths.add(
option,
self.paths[path].model_copy(update=objects),
force=True,
)
def add_variable(
self,
option,
first_variable: bool,
custom_type: bool,
) -> None:
"""Add a new variable"""
variable = option.parameters
path = option.path
if custom_type:
self.change_namespaces(variable)
data = dict(variable)
data["xmlfiles"] = option.sources
data["namespace"] = option.namespace
data["path"] = path
data["version"] = option.version
try:
variable_obj = option.object["object"](
name=option.name,
**data,
)
except ValidationError as err:
raise Exception(
f'invalid variable "{path}" in "{display_list(option.sources)}": {err}'
) from err
self.paths.add(
option,
variable_obj,
)
self.variables.append(path)
if "." in path:
parent_path = path.rsplit(".", 1)[0]
else:
parent_path = "."
self.parents[parent_path].append(path)
self.set_name(
variable_obj,
"option_",
)
if option.family_is_sequence:
if first_variable:
self.leaders.append(path)
else:
self.followers.append(path)
if self.loaded_custom_types != None:
self.loaded_custom_types[path] = option
def change_namespaces(self, variable):
for key, value in variable.items():
if isinstance(value, Calculation) and value.namespace != self.namespace:
copy = value.model_copy()
variable[key] = copy
copy.namespace = self.namespace
if not isinstance(value, list):
continue
for idx, val in enumerate(value):
if isinstance(val, Calculation) and val.namespace != self.namespace:
copy = val.model_copy()
value[idx] = copy
copy.namespace = self.namespace
def del_family(
self,
path: str,
) -> None:
"""The family is empty, so delete it"""
del self.paths[path]
self.families.remove(path)
del self.parents[path]
if "." in path:
parent = path.rsplit(".", 1)[0]
else:
parent = "."
self.parents[parent].remove(path)
###############################################################################################
# set tiramisu file name
###############################################################################################
def set_name(
self,
obj: Union[Variable, Family],
option_prefix: str,
):
"""Set Tiramisu object name"""
self.index += 1
self.reflector_names[obj.path] = f"{option_prefix}{self.index}{self.suffix}"
class RougailConvert(ParserVariable):
"""Main Rougail conversion"""
def __init__(
self,
rougailconfig,
*,
custom_variable_types: dict = {},
custom_family_types: dict = {},
) -> None:
self.annotator = False
self.has_namespace = False
self.custom_variable_types = custom_variable_types
self.custom_family_types = custom_family_types
self.loaded_custom_types = None
super().__init__(rougailconfig)
def get_attributes_types(
self,
hint: dict,
variable: bool = False,
) -> dict:
"""attribute is calculated if typing is like: Union[Calculation, xxx]"""
lists = {
"strings": [],
"booleans": [],
"integers": [],
"floats": [],
"calculation": [],
}
if variable:
lists["calculation"].append("identifier")
calculation = ["identifier"]
else:
calculation = []
strings = []
booleans = ["redefine", "exists"]
integers = []
floats = []
params = []
literals = {}
for key, value in hint.items():
if "Union" in value.__class__.__name__:
key_types = value.__args__
if str in key_types:
strings.append(key)
if int in key_types:
integers.append(key)
if bool in key_types:
booleans.append(key)
if float in key_types:
floats.append(key)
if Calculation in key_types or VariableCalculation in key_types:
calculation.append(key)
if "_GenericAlias" in key_types[0].__class__.__name__:
if Calculation in key_types[0].__args__:
lists["calculation"].append(key)
elif "Union" in key_types[0].__args__[0].__class__.__name__:
key_types_list = key_types[0].__args__[0].__args__
if Calculation in key_types_list:
lists["calculation"].append(key)
if str in key_types_list:
lists["strings"].append(key)
if int in key_types_list:
lists["integers"].append(key)
if bool in key_types_list:
lists["booleans"].append(key)
if float in key_types_list:
lists["floats"].append(key)
else:
key_types_list = key_types[0].__args__
if Param in key_types_list:
params.append(key)
if str in key_types_list:
lists["strings"].append(key)
elif value == str:
strings.append(key)
elif value == bool:
booleans.append(key)
elif "Literal" in value.__class__.__name__:
literals[key] = value.__args__
return {
"strings": strings,
"integers": integers,
"booleans": booleans,
"floats": floats,
"literals": literals,
"calculation": calculation,
"lists": lists,
"params": params,
}
def create_namespace(
self,
namespace_description: str,
isolated_namespace: bool = True,
) -> None:
namespace_path = normalize_family(namespace_description)
self.has_namespace = True
if namespace_path in self.parents:
raise DictConsistencyError(
_("duplicate namespace {0}").format(namespace_path),
86,
None,
)
self.namespace = namespace_path
if not self.paths.default_namespace:
self.paths = Paths(
namespace_description,
isolated_namespace,
)
self.version = ""
self.sources = []
option = Collect(
self,
self.namespace,
None,
{
"type": "family",
"description": namespace_description,
},
None,
None,
)
self.parse_family(option)
def get_comment(
self,
name: str,
objects: Any,
) -> Optional[str]:
if self.version == "1.0" or not isinstance(objects, CommentedMap):
return
if name in objects.ca.items:
comment = objects.ca.items[name][2]
else:
comment = None
if comment:
comment = comment.value[1:].strip()
return comment
def parse_root_file(
self,
sources: list[str],
path: str,
version: str,
objects: dict,
) -> None:
self.version = version
self.sources = sources
for name, obj in objects.items():
comment = self.get_comment(name, objects)
self.family_or_variable(
name,
path,
obj,
comment,
)
def validate_file_version(
self,
obj: dict,
sources: list[str],
) -> None:
"""version is mandatory in YAML file"""
if obj is None:
obj = {}
for name in ["_version", "version"]:
if name not in obj:
continue
version = str(obj.pop(name))
break
else:
# the `version` attribute is not mandatory
default_version = self.default_structural_format_version
if default_version is not None:
version = default_version
else:
msg = '"version" attribut is mandatory in YAML file'
raise DictConsistencyError(msg, 27, sources)
if version not in SUPPORTED_VERSION:
msg = f'version "{version}" is not supported, list of supported versions: {display_list(SUPPORTED_VERSION, separator="or", add_quote=True)}'
raise DictConsistencyError(msg, 28, sources)
return version
def annotate(
self,
):
"""Apply annotation"""
if not self.paths.has_value():
self.init()
self.parse_directories()
if self.annotator:
raise DictConsistencyError(
_("Cannot execute annotate multiple time"), 85, None
)
SpaceAnnotator(self)
self.annotator = True
def parse_directories(self) -> None:
if not self.walker:
msg = _(
'invalid "structural" definition ({0}), we cannot load any structural file!'
).format(self.structurals)
raise DictConsistencyError(msg, 51, None)
self.init()
self.walker(self)
def reflect(self) -> None:
"""Apply TiramisuReflector"""
functions_files = [
func for func in self.functions_files if func not in self.exclude_imports
]
self.reflector = TiramisuReflector(
self,
functions_files,
)
def save(
self,
):
"""Return tiramisu object declaration as a string"""
self.init()
self.annotate()
self.reflect()
tiram_obj = self.reflector.get_text() + "\n"
filename = self.tiramisu_cache
if filename:
with open(filename, "w", encoding="utf-8") as tiramisu:
tiramisu.write(tiram_obj)
# print(tiram_obj)
return tiram_obj

File diff suppressed because it is too large Load diff

View file

@ -1,246 +0,0 @@
"""
Copyright (C) 2024-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from typing import (
Any,
Dict,
List,
Union,
)
import logging
from re import compile, findall
from .object_model import Family, Variable
from ..error import DictConsistencyError
from ..i18n import _
from ..tiramisu import normalize_family
class Paths:
regexp_relative = compile(r"^_*\.(.*)$")
def __init__(
self,
default_namespace: str,
isolated_namespace: bool,
) -> None:
self._data: Dict[str, Union[Variable, Family]] = {}
self._dynamics: Dict[str:str] = {}
if default_namespace is not None:
default_namespace = normalize_family(default_namespace)
self.default_namespace = default_namespace
self.isolated_namespace = isolated_namespace
def has_value(self) -> bool:
return self._data != {}
def add(
self,
option: "Collect",
data: Any,
*,
force: bool = False,
) -> None:
path = option.path
self._data[path] = data
if not force and option.family_is_dynamic:
self._dynamics[path] = option.parent_dynamic
def get_full_path(
self,
path: str,
current_path: str,
):
if "{{ suffix }}" in path:
# version 1.0 and 1.1
path = path.replace("{{ suffix }}", "{{ identifier }}")
relative, subpath = path.split(".", 1)
relative_len = len(relative)
path_len = current_path.count(".")
if path_len + 1 == relative_len:
return subpath
parent_path = current_path.rsplit(".", relative_len)[0]
return parent_path + "." + subpath
def get_with_dynamic(
self,
path: str,
current_path: str,
version: str,
namespace: str,
xmlfiles: List[str],
) -> Any:
identifier = None
if version != "1.0" and self.regexp_relative.search(path):
path = self.get_full_path(
path,
current_path,
)
# elif identifier_path:
# path = f"{identifier_path}.{path}"
dynamic = None
# version 1.0
if version == "1.0":
if not path in self._data and "{{ suffix }}" not in path:
new_path = None
current_path = None
identifiers = []
for name in path.split("."):
parent_path = current_path
if current_path:
current_path += "." + name
else:
current_path = name
if current_path in self._data:
if new_path:
new_path += "." + name
else:
new_path = name
continue
for dynamic_path in self._dynamics:
if "." in dynamic_path:
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
else:
parent_dynamic = None
name_dynamic = dynamic_path
if (
parent_dynamic == parent_path
and name_dynamic.endswith("{{ identifier }}")
and name == name_dynamic.replace("{{ identifier }}", "")
):
new_path += "." + name_dynamic
break
regexp = "^" + name_dynamic.replace("{{ identifier }}", "(.*)")
finded = findall(regexp, name)
if len(finded) != 1 or not finded[0]:
continue
if finded[0] == "{{ identifier }}":
identifiers.append(None)
else:
identifiers.append(finded[0])
if new_path is None:
new_path = name_dynamic
else:
new_path += "." + name_dynamic
parent_path = dynamic_path
break
else:
if new_path:
new_path += "." + name
else:
new_path = name
path = new_path
else:
identifiers = None
elif not path in self._data:
new_path = parent_path = current_path = None
identifiers = []
for name in path.split("."):
if current_path:
current_path += "." + name
else:
current_path = name
# parent_path, name_path = path.rsplit('.', 1)
if current_path in self._data:
if new_path:
new_path += "." + name
else:
new_path = name
parent_path = current_path
if "{{ identifier }}" in name:
identifiers.append(None)
continue
for dynamic_path in self._dynamics:
if "." in dynamic_path:
parent_dynamic, name_dynamic = dynamic_path.rsplit(".", 1)
else:
parent_dynamic = None
name_dynamic = dynamic_path
if (
"{{ identifier }}" not in name_dynamic
or parent_path != parent_dynamic
):
continue
regexp = "^" + name_dynamic.replace("{{ identifier }}", "(.*)")
finded = findall(regexp, name)
if len(finded) != 1 or not finded[0]:
continue
if finded[0] == "{{ identifier }}":
identifiers.append(None)
else:
identifiers.append(finded[0])
if new_path is None:
new_path = name_dynamic
else:
new_path += "." + name_dynamic
parent_path = dynamic_path
break
else:
if new_path:
new_path += "." + name
else:
new_path = name
if "{{ identifier }}" in name:
identifiers.append(None)
parent_path = current_path
path = new_path
else:
identifiers = None
if path not in self._data:
return None, None
option = self._data[path]
option_namespace = option.namespace
if (
self.isolated_namespace
and self.default_namespace not in [namespace, option_namespace]
and namespace != option_namespace
):
msg = _(
'The variable or the family "{0}" located in the "{1}" namespace shall not be used in the "{2}" namespace'
).format(path, option_namespace, namespace)
raise DictConsistencyError(msg, 38, xmlfiles)
return option, identifiers
def __getitem__(
self,
path: str,
) -> Union[Family, Variable]:
if not path in self._data:
raise AttributeError(f"cannot find variable or family {path}")
return self._data[path]
def __contains__(
self,
path: str,
) -> bool:
return path in self._data
def __delitem__(
self,
path: str,
) -> None:
logging.info("remove empty family %s", path)
del self._data[path]
def is_dynamic(self, path: str) -> bool:
return path in self._dynamics
def get(self):
return self._data.values()
def replace(self, path, variable):
self._data[path] = variable

View file

@ -9,24 +9,32 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from .i18n import _ from .i18n import _
from .tiramisu import display_xmlfiles
def display_xmlfiles(xmlfiles: list) -> str:
"""The function format xmlfiles informations to generate errors"""
if len(xmlfiles) == 1:
return '"' + xmlfiles[0] + '"'
return '"' + '", "'.join(xmlfiles[:-1]) + '"' + " and " + '"' + xmlfiles[-1] + '"'
class ConfigError(Exception): class ConfigError(Exception):
@ -58,30 +66,21 @@ class DictConsistencyError(Exception):
def __init__(self, msg, errno, xmlfiles): def __init__(self, msg, errno, xmlfiles):
if xmlfiles: if xmlfiles:
msg = _("{0} in {1}").format(msg, display_xmlfiles(xmlfiles)) msg = _(f"{msg} in {display_xmlfiles(xmlfiles)}")
super().__init__(msg) super().__init__(msg)
self.errno = errno self.errno = errno
## ---- generic exceptions ---- class UpgradeError(Exception):
"""Error during XML upgrade"""
## ---- generic exceptions ----
class NotFoundError(Exception): class NotFoundError(Exception):
"not found error" "not found error"
pass pass
class ExtensionError(Exception):
pass
class RougailWarning(UserWarning):
pass
## ---- specific exceptions ---- ## ---- specific exceptions ----
class VariableCalculationDependencyError(Exception): class VariableCalculationDependencyError(Exception):
pass pass

View file

@ -8,25 +8,53 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
import gettext
import os
import sys
import locale
from gettext import translation # Application Name
from pathlib import Path APP_NAME = "rougail"
t = translation("rougail", str(Path(__file__).parent / "locale"), fallback=True) # Traduction dir
APP_DIR = os.path.join(sys.prefix, "share")
LOCALE_DIR = os.path.join(APP_DIR, "locale")
# Default Lanugage
DEFAULT_LANG = os.environ.get("LANG", "").split(":")
DEFAULT_LANG += ["en_US"]
languages = []
lc, encoding = locale.getlocale()
if lc:
languages = [lc]
languages += DEFAULT_LANG
mo_location = LOCALE_DIR
gettext.find(APP_NAME, mo_location)
gettext.textdomain(APP_NAME)
# gettext.bind_textdomain_codeset(APP_NAME, "UTF-8")
# gettext.translation(APP_NAME, fallback=True)
t = gettext.translation(APP_NAME, fallback=True)
_ = t.gettext _ = t.gettext

757
src/rougail/object_model.py Normal file
View file

@ -0,0 +1,757 @@
"""Rougail object model
Silique (https://www.silique.fr)
Copyright (C) 2023-2024
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from typing import Optional, Union, get_type_hints, Any, Literal, List, Dict, Iterator
from pydantic import (
BaseModel,
StrictBool,
StrictInt,
StrictFloat,
StrictStr,
ConfigDict,
)
from tiramisu import undefined
from .utils import get_jinja_variable_to_param, get_realpath
from .error import DictConsistencyError, VariableCalculationDependencyError
BASETYPE = Union[StrictBool, StrictInt, StrictFloat, StrictStr, None]
PROPERTY_ATTRIBUTE = ["frozen", "hidden", "disabled", "mandatory"]
def convert_boolean(value: str) -> bool:
"""Boolean coercion. The Rougail XML may contain srings like `True` or `False`"""
if isinstance(value, bool):
return value
value = value.lower()
if value == "true":
return True
elif value == "false":
return False
elif value in ["", None]:
return None
raise Exception(f'unknown boolean value "{value}"')
CONVERT_OPTION = {
"string": dict(opttype="StrOption", example="example"),
"number": dict(opttype="IntOption", func=int, example=42),
"float": dict(opttype="FloatOption", func=float, example=1.42),
"boolean": dict(opttype="BoolOption", func=convert_boolean),
"secret": dict(opttype="PasswordOption", example="secrets"),
"mail": dict(opttype="EmailOption", example="user@example.net"),
"unix_filename": dict(opttype="FilenameOption", example="/tmp/myfile.txt"),
"date": dict(opttype="DateOption", example="2000-01-01"),
"unix_user": dict(opttype="UsernameOption", example="username"),
"ip": dict(
opttype="IPOption", initkwargs={"allow_reserved": True}, example="1.1.1.1"
),
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}, example="1.1.1.0/24"),
"netmask": dict(opttype="NetmaskOption", example="255.255.255.0"),
"network": dict(opttype="NetworkOption", example="1.1.1.0"),
"network_cidr": dict(
opttype="NetworkOption", initkwargs={"cidr": True}, example="1.1.1.0/24"
),
"broadcast": dict(opttype="BroadcastOption", example="1.1.1.255"),
"netbios": dict(
opttype="DomainnameOption",
initkwargs={"type": "netbios", "warnings_only": True},
example="example",
),
"domainname": dict(
opttype="DomainnameOption",
initkwargs={"type": "domainname", "allow_ip": False},
example="example.net",
),
"hostname": dict(
opttype="DomainnameOption",
initkwargs={"type": "hostname", "allow_ip": False},
example="example",
),
"web_address": dict(
opttype="URLOption",
initkwargs={"allow_ip": False, "allow_without_dot": True},
example="https://example.net",
),
"port": dict(
opttype="PortOption", initkwargs={"allow_private": True}, example="111"
),
"mac": dict(opttype="MACOption", example="00:00:00:00:00"),
"unix_permissions": dict(
opttype="PermissionsOption",
initkwargs={"warnings_only": True},
func=int,
example="644",
),
"choice": dict(opttype="ChoiceOption", example="a_choice"),
"regexp": dict(opttype="RegexpOption"),
#
"symlink": dict(opttype="SymLinkOption"),
}
class Param(BaseModel):
key: str
model_config = ConfigDict(extra="forbid")
def __init__(
self,
path,
attribute,
family_is_dynamic,
is_follower,
xmlfiles,
**kwargs,
) -> None:
super().__init__(**kwargs)
class AnyParam(Param):
type: str
value: Union[BASETYPE, List[BASETYPE]]
class VariableParam(Param):
type: str
variable: str
propertyerror: bool = True
whole: bool = False
optional: bool = False
class SuffixParam(Param):
type: str
suffix: Optional[int] = None
def __init__(
self,
**kwargs,
) -> None:
if not kwargs["family_is_dynamic"]:
msg = f'suffix parameter for "{kwargs["attribute"]}" in "{kwargs["path"]}" cannot be set none dynamic family'
raise DictConsistencyError(msg, 10, kwargs["xmlfiles"])
super().__init__(**kwargs)
class InformationParam(Param):
type: str
information: str
variable: Optional[str] = None
class IndexParam(Param):
type: str
def __init__(
self,
**kwargs,
) -> None:
if not kwargs["is_follower"]:
msg = f'the variable "{kwargs["path"]}" is not a follower, so cannot have index type for param in "{kwargs["attribute"]}"'
raise DictConsistencyError(msg, 25, kwargs["xmlfiles"])
super().__init__(**kwargs)
PARAM_TYPES = {
"any": AnyParam,
"variable": VariableParam,
"suffix": SuffixParam,
"information": InformationParam,
"index": IndexParam,
}
class Calculation(BaseModel):
path_prefix: Optional[str]
path: str
inside_list: bool
version: str
ori_path: Optional[str] = None
default_values: Any = None
namespace: Optional[str]
xmlfiles: List[str]
model_config = ConfigDict(extra="forbid")
def get_realpath(
self,
path: str,
) -> str:
return get_realpath(path, self.path_prefix)
def get_params(self, objectspace):
if not self.params:
return {}
params = {}
for param_obj in self.params:
param = param_obj.model_dump()
if param.get("type") == "variable":
if self.ori_path is None:
path = self.path
else:
path = self.ori_path
variable, suffix = objectspace.paths.get_with_dynamic(
param["variable"],
self.path_prefix,
path,
self.version,
self.namespace,
self.xmlfiles,
)
if not variable:
if not param.get("optional"):
msg = f'cannot find variable "{param["variable"]}" defined attribute in "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 22, self.xmlfiles)
continue
if not isinstance(variable, objectspace.variable):
raise Exception("pfff it's a family")
param["variable"] = variable
if suffix:
param["suffix"] = suffix
if param.get("type") == "information":
if param["variable"]:
if self.ori_path is None:
path = self.path
else:
path = self.ori_path
variable, suffix = objectspace.paths.get_with_dynamic(
param["variable"],
self.path_prefix,
path,
self.version,
self.namespace,
self.xmlfiles,
)
if not variable:
msg = f'cannot find variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}"'
raise DictConsistencyError(msg, 14, self.xmlfiles)
param["variable"] = variable
if suffix:
msg = f'variable "{param["variable"]}" defined in "{self.attribute_name}" for "{self.path}" is a dynamic variable'
raise DictConsistencyError(msg, 15, self.xmlfiles)
else:
del param["variable"]
params[param.pop("key")] = param
return params
class JinjaCalculation(Calculation):
attribute_name: Literal[
"frozen",
"hidden",
"mandatory",
"empty",
"disabled",
"default",
"validators",
"choices",
"dynamic",
]
jinja: StrictStr
params: Optional[List[Param]] = None
return_type: BASETYPE = None
description: Optional[StrictStr] = None
def _jinja_to_function(
self,
function,
return_type,
multi,
objectspace,
*,
add_help=False,
params: Optional[dict] = None,
):
variable = objectspace.paths[self.path]
jinja_path = f"{self.attribute_name}_{self.path}"
idx = 0
while jinja_path in objectspace.jinja:
jinja_path = f"{self.attribute_name}_{self.path}_{idx}"
idx += 1
objectspace.jinja[jinja_path] = self.jinja
default = {
"function": function,
"params": {
"__internal_jinja": jinja_path,
"__internal_type": return_type,
"__internal_multi": multi,
"__internal_files": self.xmlfiles,
"__internal_attribute": self.attribute_name,
"__internal_variable": self.path,
},
}
if self.default_values:
default["params"]["__default_value"] = self.default_values
if add_help:
default["help"] = function + "_help"
if self.params:
default["params"] |= self.get_params(objectspace)
if params:
default["params"] |= params
if self.ori_path is None:
path = self.path
else:
path = self.ori_path
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
path,
self.jinja,
objectspace,
variable.xmlfiles,
objectspace.functions,
self.path_prefix,
self.version,
self.namespace,
):
if true_path in default["params"]:
continue
if isinstance(sub_variable, dict):
default["params"][true_path] = {
"type": "value",
"value": sub_variable,
}
else:
default["params"][true_path] = {
"type": "variable",
"variable": sub_variable,
}
if suffix:
default["params"][true_path]["suffix"] = suffix
return default
def to_function(
self,
objectspace,
) -> dict:
if self.attribute_name == "default":
if self.return_type:
raise Exception("return_type not allowed!")
variable = objectspace.paths[self.path]
return_type = variable.type
if self.inside_list:
multi = False
elif self.path in objectspace.followers:
multi = objectspace.multis[self.path] == "submulti"
else:
multi = self.path in objectspace.multis
return self._jinja_to_function(
"jinja_to_function",
return_type,
multi,
objectspace,
)
elif self.attribute_name == "validators":
if self.return_type:
raise Exception("pfff")
return self._jinja_to_function(
"valid_with_jinja",
"string",
False,
objectspace,
)
elif self.attribute_name in PROPERTY_ATTRIBUTE:
if self.return_type:
raise Exception("return_type not allowed!")
return self._jinja_to_function(
"jinja_to_property",
"string",
False,
objectspace,
add_help=True,
params={None: [self.attribute_name], "when": True, "inverse": False},
)
elif self.attribute_name == "choices":
return_type = self.return_type
if return_type is None:
return_type = "string"
return self._jinja_to_function(
"jinja_to_function",
return_type,
not self.inside_list,
objectspace,
)
elif self.attribute_name == "dynamic":
return self._jinja_to_function(
"jinja_to_function",
"string",
True,
objectspace,
)
raise Exception("hu?")
class _VariableCalculation(Calculation):
variable: StrictStr
propertyerror: bool = True
allow_none: bool = False
def get_variable(self,
objectspace,
) -> "Variable":
if self.ori_path is None:
path = self.path
else:
path = self.ori_path
variable, suffix = objectspace.paths.get_with_dynamic(
self.variable,
self.path_prefix,
path,
self.version,
self.namespace,
self.xmlfiles,
)
if variable and not isinstance(variable, objectspace.variable):
# FIXME remove the pfff
raise Exception("pfff it's a family")
return variable, suffix
def get_params(
self,
objectspace,
variable: "Variable",
suffix: Optional[str],
*,
needs_multi: Optional[bool] = None,
):
if not variable:
msg = f'Variable not found "{self.variable}" for attribut "{self.attribute_name}" for variable "{self.path}"'
raise DictConsistencyError(msg, 88, self.xmlfiles)
param = {
"type": "variable",
"variable": variable,
"propertyerror": self.propertyerror,
}
if suffix:
param["suffix"] = suffix
params = {None: [param]}
if self.default_values:
params["__default_value"] = self.default_values
if self.allow_none:
params["allow_none"] = True
if needs_multi is None:
if self.attribute_name != "default":
needs_multi = True
else:
needs_multi = self.path in objectspace.multis
calc_variable_is_multi = variable.path in objectspace.multis
if not calc_variable_is_multi:
if variable.path in objectspace.paths._dynamics and (
suffix is None or suffix[-1] is None
):
self_dyn_path = objectspace.paths._dynamics.get(self.path)
if self_dyn_path is not None:
var_dyn_path = objectspace.paths._dynamics[variable.path]
if self_dyn_path != var_dyn_path and not self_dyn_path.startswith(
f"{var_dyn_path}."
):
calc_variable_is_multi = True
else:
calc_variable_is_multi = True
elif suffix and '{{ suffix }}' in suffix:
calc_variable_is_multi = True
if needs_multi:
if calc_variable_is_multi:
if self.inside_list:
msg = f'the variable "{self.path}" has an invalid attribute "{self.attribute_name}", the variable "{variable.path}" is multi but is inside a list'
raise DictConsistencyError(msg, 18, self.xmlfiles)
elif not self.inside_list:
msg = f'the variable "{self.path}" has an invalid attribute "{self.attribute_name}", the variable "{variable.path}" is not multi but is not inside a list'
raise DictConsistencyError(msg, 20, self.xmlfiles)
elif self.inside_list:
msg = f'the variable "{self.path}" has an invalid attribute "{self.attribute_name}", it\'s a list'
raise DictConsistencyError(msg, 23, self.xmlfiles)
elif calc_variable_is_multi:
if variable.multi or variable.path.rsplit('.', 1)[0] != self.path.rsplit('.', 1)[0]:
# it's not a follower or not in same leadership
msg = f'the variable "{self.path}" has an invalid attribute "{self.attribute_name}", the variable "{variable.path}" is a multi'
raise DictConsistencyError(msg, 21, self.xmlfiles)
else:
params[None][0]['index'] = {'index': {'type': 'index'}}
return params
class VariableCalculation(_VariableCalculation):
attribute_name: Literal["default", "choices", "dynamic"]
optional: bool = False
def to_function(
self,
objectspace,
) -> dict:
if self.attribute_name != "default" and self.optional:
msg = f'"{self.attribute_name}" variable shall not have an "optional" attribute for variable "{self.variable}"'
raise DictConsistencyError(msg, 33, self.xmlfiles)
variable, suffix = self.get_variable(objectspace)
if not variable and self.optional:
raise VariableCalculationDependencyError()
params = self.get_params(objectspace,
variable,
suffix,
)
return {
"function": "calc_value",
"params": params,
}
class VariablePropertyCalculation(_VariableCalculation):
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
when: Any = undefined
when_not: Any = undefined
def to_function(
self,
objectspace,
) -> dict:
variable, suffix = self.get_variable(objectspace)
params = self.get_params(objectspace,
variable,
suffix,
needs_multi=False,)
variable = params[None][0]["variable"]
if self.when is not undefined:
if self.version == "1.0":
msg = f'when is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
raise DictConsistencyError(msg, 103, variable.xmlfiles)
if self.when_not is not undefined:
msg = f'the variable "{self.path}" has an invalid attribute "{self.attribute_name}", when and when_not cannot set together'
raise DictConsistencyError(msg, 31, variable.xmlfiles)
when = self.when
inverse = False
elif self.when_not is not undefined:
if self.version == "1.0":
msg = f'when_not is not allowed in format version 1.0 for attribute "{self.attribute_name}" for variable "{self.path}"'
raise DictConsistencyError(msg, 104, variable.xmlfiles)
when = self.when_not
inverse = True
else:
if variable.type != "boolean":
raise Exception("only boolean!")
when = True
inverse = False
params[None].insert(0, self.attribute_name)
params["when"] = when
params["inverse"] = inverse
return {
"function": "variable_to_property",
"params": params,
"help": "variable_to_property",
}
class InformationCalculation(Calculation):
attribute_name: Literal["default", "choice", "dynamic"]
information: StrictStr
variable: Optional[StrictStr]
def to_function(
self,
objectspace,
) -> dict:
params = {
None: [
{
"type": "information",
"information": self.information,
}
]
}
if self.variable:
if self.ori_path is None:
path = self.path
else:
path = self.ori_path
variable, suffix = objectspace.paths.get_with_dynamic(
self.variable,
self.path_prefix,
path,
self.version,
self.namespace,
self.xmlfiles,
)
if variable is None or suffix is not None:
raise Exception("pfff")
params[None][0]["variable"] = variable
if self.default_values:
params["__default_value"] = self.default_values
return {
"function": "calc_value",
"params": params,
}
class _SuffixCalculation(Calculation):
suffix: Optional[int] = None
def get_suffix(self) -> dict:
suffix = {"type": "suffix"}
if self.suffix is not None:
suffix["suffix"] = self.suffix
return suffix
class SuffixCalculation(_SuffixCalculation):
attribute_name: Literal["default", "choice", "dynamic"]
def to_function(
self,
objectspace,
) -> dict:
suffix = {"type": "suffix"}
if self.suffix is not None:
suffix["suffix"] = self.suffix
return {
"function": "calc_value",
"params": {None: [self.get_suffix()]},
}
class SuffixPropertyCalculation(_SuffixCalculation):
attribute_name: Literal[*PROPERTY_ATTRIBUTE]
when: Any = undefined
when_not: Any = undefined
def to_function(
self,
objectspace,
) -> dict:
if self.version == "1.0":
msg = f'when is not allowed in format version 1.0 for attribute "{self.attribute_name}"'
raise DictConsistencyError(msg, 105, variable.xmlfiles)
if self.when is not undefined:
if self.when_not is not undefined:
msg = f'the suffix has an invalid attribute "{self.attribute_name}", when and when_not cannot set together'
raise DictConsistencyError(msg, 35, variable.xmlfiles)
when = self.when
inverse = False
elif self.when_not is not undefined:
when = self.when_not
inverse = True
else:
msg = f'the suffix has an invalid attribute "{self.attribute_name}", when and when_not cannot set together'
raise DictConsistencyError
params = {None: [self.attribute_name, self.get_suffix()],
"when": when,
"inverse": inverse,
}
return {
"function": "variable_to_property",
"params": params,
"help": "variable_to_property",
}
class IndexCalculation(Calculation):
attribute_name: Literal["default", "choice", "dynamic"]
def to_function(
self,
objectspace,
) -> dict:
if self.path not in objectspace.followers:
msg = f'the variable "{self.path}" is not a follower, so cannot have index type for "{self.attribute_name}"'
raise DictConsistencyError(msg, 60, self.xmlfiles)
return {
"function": "calc_value",
"params": {None: [{"type": "index"}]},
}
CALCULATION_TYPES = {
"jinja": JinjaCalculation,
"variable": VariableCalculation,
"information": InformationCalculation,
"suffix": SuffixCalculation,
"index": IndexCalculation,
}
CALCULATION_PROPERTY_TYPES = {
"jinja": JinjaCalculation,
"variable": VariablePropertyCalculation,
"information": InformationCalculation,
"suffix": SuffixPropertyCalculation,
"index": IndexCalculation,
}
BASETYPE_CALC = Union[StrictBool, StrictInt, StrictFloat, StrictStr, Calculation, None]
class Family(BaseModel):
name: str
description: Optional[str] = None
type: Literal["family", "leadership", "dynamic"] = "family"
path: str
help: Optional[str] = None
mode: Optional[str] = None
hidden: Union[bool, Calculation] = False
disabled: Union[bool, Calculation] = False
namespace: Optional[str]
version: str
xmlfiles: List[str] = []
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
class Dynamic(Family):
# None only for format 1.0
variable: str = None
dynamic: Union[List[Union[StrictStr, Calculation]], Calculation]
class Variable(BaseModel):
# type will be set dynamically in `annotator/value.py`, default is None
type: str = None
name: str
description: Optional[str] = None
default: Union[List[BASETYPE_CALC], BASETYPE_CALC] = None
choices: Optional[Union[List[BASETYPE_CALC], Calculation]] = None
regexp: Optional[str] = None
params: Optional[List[Param]] = None
validators: Optional[List[Calculation]] = None
multi: Optional[bool] = None
unique: Optional[bool] = None
help: Optional[str] = None
hidden: Union[bool, Calculation] = False
disabled: Union[bool, Calculation] = False
mandatory: Union[None, bool, Calculation] = True
empty: Union[None, bool, Calculation] = True
auto_save: bool = False
mode: Optional[str] = None
test: Optional[list] = None
examples: Optional[list] = None
path: str
namespace: Optional[str]
version: str
path_prefix: Optional[str]
xmlfiles: List[str] = []
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
class SymLink(BaseModel):
type: Literal["symlink"] = "symlink"
name: str
path: str
opt: Variable
namespace: Optional[str]
version: str
path_prefix: Optional[str]
xmlfiles: List[str] = []
model_config = ConfigDict(extra="forbid")

View file

@ -0,0 +1,41 @@
"""Provider/supplier
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
# from rougail.objspace import get_variables
# from rougail.utils import normalize_family
#
#
# def provider_supplier(objectspace,
# path_prefix,
# ):
# n_path_prefix = normalize_family(path_prefix)
# for variable in get_variables(objectspace):
# if variable.path_prefix != n_path_prefix:
# continue
# if hasattr(variable, 'provider'):
# family_name, variable.name = variable.path.rsplit('.', 1)
# objectspace.paths.set_provider(variable,
# variable.name,
# family_name,
# )
# if hasattr(variable, 'supplier'):
# family_name, variable.name = variable.path.rsplit('.', 1)
# objectspace.paths.set_supplier(variable,
# variable.name,
# family_name,
# )

View file

@ -1,22 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .object_model import Variable, Family
__all__ = ("Variable", "Family")

View file

@ -1,31 +1,30 @@
"""Annotate to add specify attribute for tiramisu-cmdline """Annotate to add specify attribute for tiramisu-cmdline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2026 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from rougail.annotator.variable import Walk from rougail.annotator.variable import Walk
from rougail.utils import _ from rougail.utils import _
from rougail.error import DictConsistencyError from rougail.error import DictConsistencyError
from rougail.convert.collect import Collect
class Annotator(Walk): class Annotator(Walk):
"""Annotate value""" """Annotate value"""
level = 80 level = 80
def __init__(self, objectspace, *args) -> None: def __init__(self, objectspace, *args) -> None:
@ -38,9 +37,9 @@ class Annotator(Walk):
if family.commandline: if family.commandline:
continue continue
self.not_for_commandline(family) self.not_for_commandline(family)
not_for_commandlines.append(family.path + ".") not_for_commandlines.append(family.path + '.')
for variable in self.get_variables(): for variable in self.get_variables():
if variable.type == "symlink": if variable.type == 'symlink':
continue continue
variable_path = variable.path variable_path = variable.path
for family_path in not_for_commandlines: for family_path in not_for_commandlines:
@ -51,50 +50,40 @@ class Annotator(Walk):
self.not_for_commandline(variable) self.not_for_commandline(variable)
else: else:
self.manage_alternative_name(variable) self.manage_alternative_name(variable)
self.manage_negative_description(variable)
def not_for_commandline(self, variable) -> None: def not_for_commandline(self, variable) -> None:
self.objectspace.properties.add(variable.path, "not_for_commandline", True) self.objectspace.properties.add(variable.path, 'not_for_commandline', True)
def manage_alternative_name(self, variable) -> None: def manage_alternative_name(self, variable) -> None:
if not variable.alternative_name: if not variable.alternative_name:
return return
alternative_name = variable.alternative_name alternative_name = variable.alternative_name
variable_path = variable.path variable_path = variable.path
self.objectspace.informations.add( all_letters = ''
variable_path, "alternative_name", alternative_name
)
all_letters = ""
for letter in alternative_name: for letter in alternative_name:
all_letters += letter all_letters += letter
if all_letters == "h": if all_letters == 'h':
msg = _('alternative_name "{0}" conflict with "--help"').format( msg = _(f'alternative_name "{alternative_name}" conflict with "--help"')
alternative_name
)
raise DictConsistencyError(msg, 202, variable.xmlfiles) raise DictConsistencyError(msg, 202, variable.xmlfiles)
if all_letters in self.alternative_names: if all_letters in self.alternative_names:
msg = _('conflict alternative_name "{0}": "{1}" and "{2}"').format( msg = _(f'conflict alternative_name "{alternative_name}": "{variable_path}" and "{self.alternative_names[all_letters]}"')
alternative_name, variable_path, self.alternative_names[all_letters]
)
raise DictConsistencyError(msg, 202, variable.xmlfiles) raise DictConsistencyError(msg, 202, variable.xmlfiles)
self.alternative_names[alternative_name] = variable_path self.alternative_names[alternative_name] = variable_path
if "." not in variable_path: if '.' not in variable_path:
subpath = None path = alternative_name
else: else:
subpath = variable_path.rsplit(".", 1)[0] path = variable_path.rsplit('.', 1)[0] + '.' + alternative_name
self.objectspace.version = variable.version self.objectspace.add_variable(alternative_name, {'type': 'symlink', 'path': path, 'opt': variable}, variable.xmlfiles, False, False, variable.version)
# FIXME dynamic_family peut etre == true ??
# FIXME objectspace ? zut peut avoir une version différente !! def manage_negative_description(self, variable) -> None:
option = Collect( if not variable.negative_description:
self.objectspace, if variable.type == 'boolean' and not self.objectspace.add_extra_options:
alternative_name, raise DictConsistencyError(_(f'negative_description is mandatory for boolean variable, but "{variable.path}" hasn\'t'), 200, variable.xmlfiles)
subpath, return
{"type": "symlink", "opt": variable}, if variable.type != 'boolean':
None, raise DictConsistencyError(_(f'negative_description is only available for boolean variable, but "{variable.path}" is "{variable.type}"'), 201, variable.xmlfiles)
None, self.objectspace.informations.add(
) variable.path, "negative_description", variable.negative_description
self.objectspace.add_variable(
option,
False,
False,
) )

View file

@ -2,42 +2,41 @@
Config file for Rougail-structural_commandline Config file for Rougail-structural_commandline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2026 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
def get_rougail_config(*,
def get_rougail_config(
*,
backward_compatibility=True, backward_compatibility=True,
) -> dict: ) -> dict:
options = """ options = """
structural_commandline: structural_commandline:
description: Configuration rougail-structural_commandline description: Configuration rougail-structural_commandline
commandline: false commandline: false
add_extra_options: add_extra_options:
description: Add extra options to tiramisu-cmdline-parser description: Add extra options to tiramisu-cmdline-parser
default: true default: true
""" """
return { return {'name': 'exporter',
"name": "commandline", 'process': 'structural',
"process": "structural", 'options': options,
"options": options, 'level': 20,
"level": 20,
} }
__all__ = "get_rougail_config" __all__ = ('get_rougail_config')

View file

@ -1,30 +1,36 @@
"""Annotate to add specify attribute for tiramisu-cmdline """Annotate to add specify attribute for tiramisu-cmdline
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2024-2026 Copyright (C) 2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import Optional from typing import Optional
from pydantic import BaseModel from pydantic import BaseModel
class Variable(BaseModel): class Variable(BaseModel):
alternative_name: Optional[str] = None alternative_name: Optional[str]=None
commandline: bool = True commandline: bool=True
negative_description: Optional[str]=None
class Family(BaseModel): class Family(BaseModel):
commandline: bool = True commandline: bool=True
__all__ = ('Variable', 'Family')

View file

@ -1,142 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2022-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from typing import Union, List, Iterator, Optional
from itertools import chain
from pathlib import Path
from ruamel.yaml import YAML
from ..convert.path import Paths
from ..error import DictConsistencyError
from ..i18n import _
class Walker:
def __init__(
self,
convert,
) -> None:
"""Parse directories content"""
self.convert = convert
self.yaml = YAML()
self.sort_structural_files_all = True
self.walk()
def walk(self) -> None:
rougailconfig = self.convert.rougailconfig
self.sort_structural_files_all = rougailconfig["sort_structural_files_all"]
if rougailconfig["main_namespace"]:
self.load_with_extra(
rougailconfig["extra_namespaces"],
rougailconfig["main_namespace"],
rougailconfig["main_structural_directories"],
rougailconfig["isolated_namespace"],
)
else:
self.convert.namespace = None
for filename in self.get_sorted_filenames(
rougailconfig["main_structural_directories"]
):
self.parse_variable_file(
filename,
)
def load_with_extra(
self,
extra_structures: dict,
main_namespace: Optional[str] = None,
main_structures: Optional[List[str]] = None,
isolated_namespace: bool = True,
) -> None:
directory_dict = chain(
(
(
main_namespace,
main_structures,
),
),
extra_structures.items(),
)
for namespace, directories in directory_dict:
self.convert.create_namespace(namespace, isolated_namespace)
for filename in self.get_sorted_filenames(directories):
self.parse_variable_file(
filename,
)
def get_sorted_filenames(
self,
directories: Union[str, List[str]],
) -> Iterator[str]:
"""Sort filename"""
if not isinstance(directories, list):
directories = [directories]
if self.sort_structural_files_all:
filenames = {}
for directory_name in directories:
directory = Path(directory_name)
if not self.sort_structural_files_all:
filenames = {}
if directory.is_file():
self.get_filename(directory, filenames)
else:
for file_path in directory.iterdir():
self.get_filename(file_path, filenames)
if not self.sort_structural_files_all:
yield from self._get_sorted_filenames(filenames)
if self.sort_structural_files_all:
yield from self._get_sorted_filenames(filenames)
def _get_sorted_filenames(self, filenames):
for filename in sorted(filenames):
yield filenames[filename]
def get_filename(self, file_path, filenames: List[str]) -> None:
if file_path.suffix not in [".yml", ".yaml"]:
return
if file_path.name in filenames:
raise DictConsistencyError(
_("duplicate structural file name {0}").format(file_path.name),
78,
[filenames[file_path.name], str(file_path)],
)
filenames[file_path.name] = str(file_path)
def parse_variable_file(
self,
filename: str,
) -> None:
"""Parse file"""
with open(filename, encoding="utf8") as file_fh:
objects = self.yaml.load(file_fh)
if objects is None:
return
version = self.convert.validate_file_version(
objects,
filename,
)
self.convert.parse_root_file(
[filename],
self.convert.namespace,
version,
objects,
)
__all__ = ("Walker",)

View file

@ -1,114 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from ..utils import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
if backward_compatibility:
main_namespace_default = "rougail"
else:
main_namespace_default = "null"
options = f"""
main_namespace:
description: {_("Main namespace name")}
default: {main_namespace_default}
alternative_name: s
mandatory: false
disabled:
jinja: >-
{{{{ 'directory' not in _.step.structural and 'string' not in _.step.structural }}}}
return_type: boolean
description: {_('directory or string is not in "_.step.structural"')}
main_structural_directories:
description: {_("Directories where structural files are placed")}
type: unix_filename
alternative_name: m
params:
allow_relative: True
test_existence: True
multi: true
disabled:
jinja: >-
{{% if 'directory' not in _.step.structural %}}
directory is not in _.step.structural
{{% endif %}}
{{% if cli is defined and cli.versions is defined and cli.versions %}}
cli.versions is specified
{{% endif %}}
sort_structural_files_all:
description: {_("Sort structural from differents directories")}
default: false
disabled:
jinja: >-
{{% if 'directory' not in _.step.structural %}}
directory is not in _.step.structural
{{% endif %}}
isolated_namespace:
description: {_("Namespaces are isolated")}
default: true
disabled:
jinja: >-
{{{{ 'directory' not in _.step.structural and 'string' not in _.step.structural }}}}
return_type: boolean
description: {_('directory or string is not in "_.step.structural" or "_.main_namespace" is not set')}
extra_namespaces:
description: {_("Extra namespaces")}
type: sequence
disabled:
jinja: >-
{{{{ ('directory' not in _.step.structural and 'string' not in _.step.structural) or not _.main_namespace }}}}
return_type: boolean
description: directory is not in _.step.structural or main_namespace is not set
names:
description: {_("Extra namespace name")}
alternative_name: xn
multi: true
mandatory: false
directories:
description: {_("Directories where extra structural files are placed")}
alternative_name: xd
type: unix_filename
params:
allow_relative: true
test_existence: true
multi: true
disabled:
jinja: >-
{{{{ 'directory' not in __.step.structural }}}}
return_type: boolean
description: {_('directory is not in "__.step.structural"')}
"""
return {
"name": "directory",
"process": "structural",
"options": options,
"level": 5,
}
__all__ = "get_rougail_config"

View file

@ -1,103 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from typing import List, Optional
from itertools import chain
from ruamel.yaml import YAML
from ..tiramisu import normalize_family
from ..convert.path import Paths
# from ..error import DictConsistencyError
# from ..i18n import _
class Walker:
def __init__(
self,
convert,
) -> None:
"""Parse directories content"""
self.convert = convert
self.yaml = YAML()
rougailconfig = self.convert.rougailconfig
if rougailconfig["main_namespace"]:
self.load_with_extra(
rougailconfig["extra_namespaces"],
rougailconfig["main_namespace"],
rougailconfig["main_structural_strings"],
rougailconfig["isolated_namespace"],
)
else:
self.convert.namespace = None
for string in rougailconfig["main_structural_strings"]:
self.parse_variable(
string,
)
def load_with_extra(
self,
extra_structures: dict,
main_namespace: str,
main_strings: Optional[List[str]] = None,
isolated_namespace: bool = True,
) -> None:
directory_dict = chain(
(
(
main_namespace,
main_strings,
),
),
extra_structures.items(),
)
for namespace, extra_objects in directory_dict:
namespace_path = normalize_family(namespace)
for idx, string in enumerate(extra_objects):
if not idx:
# create only for the first file
self.convert.create_namespace(namespace, isolated_namespace)
self.parse_variable(
string,
)
def parse_variable(
self,
string: str,
) -> None:
objects = self.yaml.load(string)
if objects is None:
return
path = self.convert.namespace
if path:
name = f"yaml file for {path}"
else:
name = "yaml file"
version = self.convert.validate_file_version(
objects,
name,
)
self.convert.parse_root_file(
[name],
path,
version,
objects,
)
__all__ = ("Walker",)

View file

@ -1,68 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from ..utils import _
def get_rougail_config(
*,
backward_compatibility=True,
) -> dict:
if backward_compatibility:
main_namespace_default = "rougail"
else:
main_namespace_default = "null"
options = f"""
main_structural_strings:
description: {_("Structural files contents")}
help: {_("This variable is a list of string with YAML file format")}
multi: true
disabled:
jinja: >-
{{% if 'string' not in _.step.structural %}}
true
{{% elif cli is defined and cli.versions is defined and cli.versions %}}
true
{{% else %}}
false
{{% endif %}}
return_type: boolean
description: {_('string is not in "_.step.structural"')}
extra_namespaces:
strings:
description: {_("Extra structural contents")}
help: {_("This variable is a list of string with YAML file format")}
alternative_name: xc
multi: true
disabled:
jinja: >-
{{{{ 'string' not in __.step.structural }}}}
return_type: boolean
description: {_('string is not in "__.step.structural"')}
"""
return {
"name": "string",
"process": "structural",
"options": options,
"level": 15,
}
__all__ = "get_rougail_config"

View file

@ -9,551 +9,99 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
try:
from typing import Any from tiramisu5 import DynOptionDescription, calc_value
import atexit except ModuleNotFoundError:
from tempfile import mkdtemp from tiramisu import DynOptionDescription, calc_value
from shutil import rmtree
from importlib.machinery import SourceFileLoader as _SourceFileLoader from importlib.machinery import SourceFileLoader as _SourceFileLoader
from importlib.util import ( from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
spec_from_loader as _spec_from_loader,
module_from_spec as _module_from_spec,
)
from unicodedata import normalize, combining
from jinja2 import StrictUndefined, DictLoader from jinja2 import StrictUndefined, DictLoader
from jinja2.sandbox import SandboxedEnvironment from jinja2.sandbox import SandboxedEnvironment
from re import findall from rougail.object_model import CONVERT_OPTION
from tiramisu import ( from rougail.error import display_xmlfiles
DynOptionDescription, from tiramisu.error import ValueWarning, ConfigError
calc_value, from .utils import normalize_family
function_waiting_for_error,
undefined,
)
from tiramisu.error import (
ValueWarning,
ConfigError,
PropertiesOptionError,
CancelParam,
errors,
)
ori_raise_carry_out_calculation_error = errors.raise_carry_out_calculation_error
try:
from .i18n import _
except ModuleNotFoundError:
# FIXME
def _(msg):
return msg
def display_xmlfiles(xmlfiles: list) -> str:
"""The function format xmlfiles informations to generate errors"""
if not isinstance(xmlfiles, list):
xmlfiles = [xmlfiles]
if len(xmlfiles) == 1:
return '"' + xmlfiles[0] + '"'
return '"' + '", "'.join(xmlfiles[:-1]) + '"' + " and " + '"' + xmlfiles[-1] + '"'
def convert_boolean(value: str) -> bool:
"""Boolean coercion. The Rougail XML may contain srings like `True` or `False`"""
if isinstance(value, bool):
return value
value = value.lower()
if value == "true":
return True
elif value == "false":
return False
elif value in ["", None]:
return None
raise Exception(_('unknown boolean value "{0}"').format(value))
_ip_params = {
"cidr": {"description": _("IP must be in CIDR format")},
"private_only": {"description": _("private IP are allowed")},
"allow_reserved": {"description": _("reserved IP are allowed")},
}
_network_params = {
"cidr": {"description": _("network must be in CIDR format")},
"private_only": {"description": _("private network are allowed")},
"allow_reserved": {"description": _("reserved network are allowed")},
}
_port_params = {
"allow_range": {"description": _("can be range of port")},
"allow_protocol": {"description": _("can have the protocol")},
"allow_zero": {"description": _("port 0 is allowed")},
"allow_wellknown": {"description": _("well-known ports (1 to 1023) are allowed")},
"allow_registred": {
"description": _("registred ports (1024 to 49151) are allowed")
},
"allow_private": {
"description": _("private ports (greater than 49152) are allowed")
},
}
_domain_params = {
"type": {
"description": _("type of domainname"),
"choices": ("domainname", "netbios", "hostname"),
"doc": _("type {0}"),
},
"allow_startswith_dot": {"description": _("the domain name can starts by a dot")},
"allow_without_dot": {"description": _("the domain name can be a hostname")},
"allow_ip": {"description": _("the domain name can be an IP")},
"allow_cidr_network": {
"description": _("the domain name can be network in CIDR format")
},
"test_existence": {"description": _("the domain name must exist")},
}
_web_params = _port_params | _domain_params
CONVERT_OPTION = {
"string": dict(opttype="StrOption", example="example"),
"number": dict(
opttype="IntOption",
func=int,
params={
"min_number": {
"description": _("the minimum value"),
"doc": _("the minimum value is {0}"),
},
"max_number": {
"description": _("the maximum value"),
"doc": _("the maximum value is {0}"),
},
},
example=42,
),
"integer": dict(
opttype="IntOption",
params={
"min_integer": {
"description": _("the minimum value"),
"doc": _("the minimum value is {0}"),
},
"max_integer": {
"description": _("the maximum value"),
"doc": _("the maximum value is {0}"),
},
},
func=int,
example=42,
),
"float": dict(opttype="FloatOption", func=float, example=1.42),
"boolean": dict(opttype="BoolOption", func=convert_boolean, example=True),
"secret": dict(
opttype="PasswordOption",
params={
"min_len": {
"description": _("minimum characters length for the secret"),
"doc": _("minimum length for the secret is {0} characters"),
},
"max_len": {
"description": _("maximum characters length for the secret"),
"doc": _("maximum length for the secret is {0} characters"),
},
"forbidden_char": {
"description": _("forbidden characters"),
"doc": _("forbidden characters: {0}"),
},
},
example="secrets",
),
"mail": dict(opttype="EmailOption", example="user@example.net"),
"unix_filename": dict(
opttype="FilenameOption",
msg="UNIX filename",
params={
"allow_relative": {
"description": _("this filename could be a relative path")
},
"test_existence": {"description": _("this file must exist")},
"types": {
"description": _("file type allowed"),
"doc": _("file type allowed: {0}"),
"choices": ("file", "directory"),
"multi": True,
},
},
example="/tmp/myfile.txt",
),
"date": dict(opttype="DateOption", example="2000-01-01"),
"unix_user": dict(opttype="UsernameOption", example="username", msg="UNIX user"),
"ip": dict(
opttype="IPOption",
initkwargs={"allow_reserved": True},
msg="IP",
params=_ip_params,
example="1.1.1.1",
),
"cidr": dict(
opttype="IPOption",
msg="CIDR",
initkwargs={"cidr": True},
params=_ip_params,
example="1.1.1.0/24",
),
"netmask": dict(opttype="NetmaskOption", example="255.255.255.0"),
"network": dict(opttype="NetworkOption", params=_network_params, example="1.1.1.0"),
"network_cidr": dict(
opttype="NetworkOption",
initkwargs={"cidr": True},
example="1.1.1.0/24",
params=_network_params,
msg="network CIDR",
),
"broadcast": dict(opttype="BroadcastOption", example="1.1.1.255"),
"netbios": dict(
opttype="DomainnameOption",
initkwargs={"type": "netbios", "warnings_only": True},
params=_domain_params,
example="example",
),
"domainname": dict(
opttype="DomainnameOption",
initkwargs={"type": "domainname", "allow_ip": False},
params=_domain_params,
example="example.net",
),
"hostname": dict(
opttype="DomainnameOption",
initkwargs={"type": "hostname", "allow_ip": False},
params=_domain_params,
example="example",
),
"web_address": dict(
opttype="URLOption",
initkwargs={"allow_ip": False, "allow_without_dot": True},
msg="web address",
params=_web_params,
example="https://example.net",
),
"port": dict(
opttype="PortOption",
initkwargs={"allow_private": True},
params=_port_params,
example="111",
func=str,
),
"mac": dict(opttype="MACOption", example="00:00:00:00:00"),
"unix_permissions": dict(
opttype="PermissionsOption",
msg="UNIX permissions",
initkwargs={"warnings_only": True},
func=int,
example="644",
),
"choice": dict(opttype="ChoiceOption", example="a_choice"),
"regexp": dict(opttype="RegexpOption"),
#
"symlink": dict(opttype="SymLinkOption"),
}
# only version 1.1
RENAME_TYPE = {
"number": "integer",
"leadership": "sequence",
}
def get_identifier_from_dynamic_family(true_name, name) -> str:
if true_name == "{{ identifier }}":
return name
regexp = true_name.replace("{{ identifier }}", "(.*)")
finded = findall(regexp, name)
if len(finded) != 1 or not finded[0]:
return None
return finded[0]
def raise_carry_out_calculation_error(subconfig, *args, **kwargs):
try:
ori_raise_carry_out_calculation_error(subconfig, *args, **kwargs)
except ConfigError as err:
ymlfiles = subconfig.config_bag.context.get_values().get_information(
subconfig, "ymlfiles", []
)
raise ConfigError(
_("{0} in {1}").format(err, display_xmlfiles(ymlfiles)), subconfig=subconfig
)
errors.raise_carry_out_calculation_error = raise_carry_out_calculation_error
global func global func
dict_env = {} dict_env = {}
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined) ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
ENV.add_extension("jinja2.ext.do")
func = ENV.filters func = ENV.filters
ENV.compile_templates('jinja_caches', zip=None)
TMP_TEMPLATE = mkdtemp()
ENV.compile_templates(TMP_TEMPLATE, zip=None)
atexit.register(rmtree, TMP_TEMPLATE)
class JinjaError: def load_functions(path):
__slot__ = ("_err",)
def __init__(self, err):
self._err = err
def __str__(self):
raise self._err from self._err
def __repr__(self):
raise self._err from self._err
def __eq__(self, *args, **kwargs):
raise self._err from self._err
def __ge__(self, *args, **kwargs):
raise self._err from self._err
def __gt__(self, *args, **kwargs):
raise self._err from self._err
def __le__(self, *args, **kwargs):
raise self._err from self._err
def __lt__(self, *args, **kwargs):
raise self._err from self._err
def __ne__(self, *args, **kwargs):
raise self._err from self._err
def test_propertyerror(value: Any) -> bool:
return isinstance(value, JinjaError)
ENV.tests["propertyerror"] = test_propertyerror
def load_functions(path, dict_func=None):
global _SourceFileLoader, _spec_from_loader, _module_from_spec, func global _SourceFileLoader, _spec_from_loader, _module_from_spec, func
if dict_func is None: loader = _SourceFileLoader('func', path)
dict_func = func
loader = _SourceFileLoader("func", path)
spec = _spec_from_loader(loader.name, loader) spec = _spec_from_loader(loader.name, loader)
func_ = _module_from_spec(spec) func_ = _module_from_spec(spec)
loader.exec_module(func_) loader.exec_module(func_)
for function in dir(func_): for function in dir(func_):
if function.startswith("_"): if function.startswith('_'):
continue continue
dict_func[function] = getattr(func_, function) func[function] = getattr(func_, function)
def normalize_family(family_name: str) -> str: def rougail_calc_value(*args, __default_value=None, **kwargs):
"""replace space, accent, uppercase, ... by valid character"""
if not family_name:
return
family_name = family_name.lower()
family_name = family_name.replace("-", "_").replace(" ", "_").replace(".", "_")
nfkd_form = normalize("NFKD", family_name)
family_name = "".join([c for c in nfkd_form if not combining(c)])
return family_name.lower()
def tiramisu_display_name(
kls,
subconfig,
with_quote: bool = False,
) -> str:
"""Replace the Tiramisu display_name function to display path + description"""
def get_path():
if description_type in ["description", "name", "name_and_description"]:
path = kls.impl_getname()
else:
path = kls.impl_getpath()
if "{{ identifier }}" in path and subconfig.identifiers:
path = path.replace(
"{{ identifier }}", normalize_family(str(subconfig.identifiers[-1]))
)
return path
config_bag = subconfig.config_bag
context = config_bag.context
values = context.get_values()
context_subconfig = context.get_root(config_bag)
description_type = values.get_information(
context_subconfig, "description_type", "name_and_description"
)
if description_type in [
"description",
"name_and_description",
"path_and_description",
]:
doc = values.get_information(subconfig, "doc", None)
description = doc if doc and doc != kls.impl_getname() else ""
if "{{ identifier }}" in description and subconfig.identifiers:
description = description.replace(
"{{ identifier }}", str(subconfig.identifiers[-1])
)
if description_type in [
"name",
"path",
"name_and_description",
"path_and_description",
]:
path = get_path()
if description_type in ["name_and_description", "path_and_description"]:
if description:
if with_quote:
description = f'"{path}" ({description})'
else:
description = f"{path} ({description})"
else:
if with_quote:
description = f'"{path}"'
else:
description = path
else:
if description_type in ["name", "path"]:
description = path
elif not description:
description = get_path()
if with_quote:
description = f'"{description}"'
return description
def rougail_calc_value(*args, __default_value=None, __internal_multi=False, **kwargs):
values = calc_value(*args, **kwargs) values = calc_value(*args, **kwargs)
if values is None and __internal_multi:
values = []
if __default_value is not None and values in [None, []]: if __default_value is not None and values in [None, []]:
return __default_value return __default_value
return values return values
def kw_to_string(kw, root=None): def jinja_to_function(__internal_variable, __internal_attribute, __internal_jinja, __internal_type, __internal_multi, __internal_files, __default_value=None, **kwargs):
for name, data in kw.items():
if root is None:
path = name
else:
path = root + "." + name
if isinstance(data, dict):
yield from kw_to_string(data, root=path)
else:
yield f"{path}={data}"
pass
@function_waiting_for_error
def jinja_to_function(
__internal_variable,
__internal_attribute,
__internal_jinja,
__internal_type,
__internal_multi,
__internal_files,
__default_value=None,
**kwargs,
):
global ENV, CONVERT_OPTION global ENV, CONVERT_OPTION
kw = {} kw = {}
for key, value in kwargs.items(): for key, value in kwargs.items():
if isinstance(value, list): if '.' in key:
val = []
for v in value:
if isinstance(v, PropertiesOptionError):
v = JinjaError(v)
# if v is None:
# v = ''
val.append(v)
value = val
else:
if isinstance(value, PropertiesOptionError):
value = JinjaError(value)
# if value is None:
# value = ''
if "." in key:
c_kw = kw c_kw = kw
path, var = key.rsplit(".", 1) path, var = key.rsplit('.', 1)
if isinstance(value, CancelParam): for subkey in path.split('.'):
count_o_path = value.origin_path.count(".") - value.current_path.count(
"."
)
path = path.rsplit(".", count_o_path)[0]
for subkey in path.split("."):
c_kw = c_kw.setdefault(subkey, {}) c_kw = c_kw.setdefault(subkey, {})
if not isinstance(value, CancelParam):
c_kw[var] = value c_kw[var] = value
else: else:
if key in kw: if key in kw:
raise ConfigError( raise ConfigError(f'internal error, multi key for "{key}" in jinja_to_function')
f'internal error, multi key for "{key}" in jinja_to_function'
)
kw[key] = value kw[key] = value
try: try:
values = ENV.get_template(__internal_jinja).render(kw, **func).strip() values = ENV.get_template(__internal_jinja).render(kw, **func).strip()
except Exception as err: except Exception as err:
kw_str = ", ".join(kw_to_string(kw)) raise ConfigError(f'cannot calculating "{__internal_attribute}" attribute for variable "{__internal_variable}" in {display_xmlfiles(__internal_files)}: {err}') from err
prefix = _('cannot calculate the variable "{0}"').format(__internal_variable) convert = CONVERT_OPTION[__internal_type].get('func', str)
msg = _(
'the attribute "{0}" in {1} with the parameters "{2}" causes the error: {3}'
).format(
__internal_attribute,
display_xmlfiles(__internal_files),
kw_str,
err,
)
raise ConfigError(msg, prefix=prefix) from err
convert = CONVERT_OPTION[__internal_type].get("func", str)
if __internal_multi: if __internal_multi:
values = [ values = [convert(val) for val in values.split('\n') if val != ""]
convert(val.strip()) for val in values.split("\n") if val.strip() != ""
]
if not values and __default_value is not None: if not values and __default_value is not None:
return __default_value return __default_value
return values return values
try: try:
values = convert(values) values = convert(values)
except Exception as err: except Exception as err:
prefix = _('cannot converting the variable "{0}"').format(__internal_variable) raise ConfigError(f'cannot converting "{__internal_attribute}" attribute for variable "{__internal_variable}" in {display_xmlfiles(__internal_files)}: {err}') from err
msg = _('"{0}" is an invalid {1}').format(values, __internal_type) values = values if values != '' and values != 'None' else None
if __internal_attribute != "default":
msg = _('the attribute "{0}" in {1} causes the error: {2}').format(
__internal_attribute,
display_xmlfiles(__internal_files),
msg,
)
raise ConfigError(msg, prefix=prefix) from err
values = values if values != "" and values != "None" else None
if values is None and __default_value is not None: if values is None and __default_value is not None:
return __default_value return __default_value
return values return values
def variable_to_property(*, prop, value=undefined, when, inverse, **kwargs): def variable_to_property(prop, value, when, inverse):
if value is undefined:
return None
if isinstance(value, PropertiesOptionError):
raise value from value
if inverse: if inverse:
is_match = value != when is_match = value != when
else: else:
@ -561,96 +109,64 @@ def variable_to_property(*, prop, value=undefined, when, inverse, **kwargs):
return prop if is_match else None return prop if is_match else None
def variable_to_property_transitive(*args, **kwargs): def jinja_to_property(prop, when, inverse, **kwargs):
# do nothing, if associate variable is not accessible, autolib will raise directly value = func['jinja_to_function'](**kwargs)
pass return func['variable_to_property'](prop, value is not None, when, inverse)
@function_waiting_for_error def jinja_to_property_help(prop, **kwargs):
def jinja_to_property(prop, description, when, inverse, **kwargs): value = func['jinja_to_function'](**kwargs)
value = func["jinja_to_function"](**kwargs) return (prop, f'\"{prop}\" ({value})')
if kwargs["__internal_type"] == "string":
value = value is not None
return func["variable_to_property"](
prop=prop, value=value, when=when, inverse=inverse
)
@function_waiting_for_error def valid_with_jinja(warnings_only=False, **kwargs):
def jinja_to_property_help(prop, description, **kwargs):
if kwargs["__internal_type"] == "string":
description = func["jinja_to_function"](**kwargs)
return (prop, f'"{prop}" ({description})')
@function_waiting_for_error
def valid_with_jinja(warnings_only=False, description=None, **kwargs):
global ValueWarning global ValueWarning
value = func["jinja_to_function"](**kwargs) value = func['jinja_to_function'](**kwargs)
if value: if value:
if description is None:
description = value
if warnings_only: if warnings_only:
raise ValueWarning(description) raise ValueWarning(value)
else: else:
raise ValueError(description) raise ValueError(value)
func["calc_value"] = rougail_calc_value func['calc_value'] = rougail_calc_value
func["jinja_to_function"] = jinja_to_function func['jinja_to_function'] = jinja_to_function
func["jinja_to_property"] = jinja_to_property func['jinja_to_property'] = jinja_to_property
func["jinja_to_property_help"] = jinja_to_property_help func['jinja_to_property_help'] = jinja_to_property_help
func["variable_to_property"] = variable_to_property func['variable_to_property'] = variable_to_property
func["variable_to_property_transitive"] = variable_to_property_transitive func['valid_with_jinja'] = valid_with_jinja
func["valid_with_jinja"] = valid_with_jinja
func["normalize_family"] = normalize_family
class ConvertDynOptionDescription(DynOptionDescription): class ConvertDynOptionDescription(DynOptionDescription):
"""Identifier could be an integer, we should convert it in str """Suffix could be an integer, we should convert it in str
Identifier could also contain invalid character, so we should "normalize" it Suffix could also contain invalid character, so we should "normalize" it
""" """
@staticmethod def convert_suffix_to_path(self, suffix):
def convert_identifier_to_path(identifier): if suffix is None:
if identifier is None: return suffix
return identifier if not isinstance(suffix, str):
if not isinstance(identifier, str): suffix = str(suffix)
identifier = str(identifier) return normalize_family(suffix)
return normalize_family(identifier)
def impl_getname( def impl_getname(
self, self,
identifier=None, suffix=None,
) -> str: ) -> str:
"""get name""" """get name"""
name = super().impl_getname(None) name = super().impl_getname(None)
if identifier is None: if suffix is None:
return name return name
path_identifier = self.convert_identifier_to_path(identifier) path_suffix = self.convert_suffix_to_path(suffix)
if "{{ identifier }}" in name: if "{{ suffix }}" in name:
return name.replace("{{ identifier }}", path_identifier) return name.replace("{{ suffix }}", path_suffix)
return name + path_identifier return name + path_suffix
def impl_get_display_name( def impl_get_display_name(
self, self,
subconfig, subconfig,
with_quote: bool = False,
) -> str: ) -> str:
display = super().impl_get_display_name(subconfig, with_quote=with_quote) display = super().impl_get_display_name(subconfig)
if "{{ identifier }}" in display: if "{{ suffix }}" in display:
return display.replace( return display.replace("{{ suffix }}", self.convert_suffix_to_path(self.get_suffixes(subconfig)[-1]))
"{{ identifier }}",
self.convert_identifier_to_path(
self.get_identifiers(subconfig, from_display_name=True)[-1]
),
)
return display return display
def name_could_conflict(self, dynchild, child):
return (
get_identifier_from_dynamic_family(
dynchild.impl_getname(), child.impl_getname()
)
is not None
)

View file

@ -10,30 +10,32 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import Optional, Union from typing import Optional, Union
from json import dumps from json import dumps
from os.path import isfile, basename from os.path import isfile, basename
from ..i18n import _ from .i18n import _
from ..error import DictConsistencyError, VariableCalculationDependencyError from .error import DictConsistencyError, VariableCalculationDependencyError
from ..tiramisu import normalize_family, CONVERT_OPTION from .utils import normalize_family
from .object_model import Calculation from .object_model import Calculation, CONVERT_OPTION
class BaseElt: # pylint: disable=R0903 class BaseElt: # pylint: disable=R0903
@ -73,7 +75,12 @@ class TiramisuReflector:
"from tiramisu import *", "from tiramisu import *",
"from tiramisu.setting import ALLOWED_LEADER_PROPERTIES", "from tiramisu.setting import ALLOWED_LEADER_PROPERTIES",
"from re import compile as re_compile", "from re import compile as re_compile",
"from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription", ]
)
if self.objectspace.export_with_import:
self.text["header"].extend(
[
"from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"
] ]
) )
if funcs_paths: if funcs_paths:
@ -82,15 +89,6 @@ class TiramisuReflector:
continue continue
self.text["header"].append(f"load_functions('{funcs_path}')") self.text["header"].append(f"load_functions('{funcs_path}')")
if self.objectspace.export_with_import: if self.objectspace.export_with_import:
# if self.objectspace.has_namespace:
self.text["header"].extend(
[
"try:",
" groups.namespace",
"except:",
" groups.addgroup('namespace')",
]
)
for mode in self.objectspace.modes_level: for mode in self.objectspace.modes_level:
self.text["header"].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")') self.text["header"].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")')
self.make_tiramisu_objects() self.make_tiramisu_objects()
@ -108,9 +106,9 @@ class TiramisuReflector:
def make_tiramisu_objects(self) -> None: def make_tiramisu_objects(self) -> None:
"""make tiramisu objects""" """make tiramisu objects"""
baseelt = BaseElt() baseelt = BaseElt()
self.objectspace.reflector_names[baseelt.path] = ( self.objectspace.reflector_names[
f"option_0{self.objectspace.suffix}" baseelt.path
) ] = f"option_0{self.objectspace.suffix}"
basefamily = Family( basefamily = Family(
baseelt, baseelt,
self, self,
@ -126,6 +124,33 @@ class TiramisuReflector:
elt, elt,
self, self,
) )
# else:
# path_prefixes = self.objectspace.paths.get_path_prefixes()
# for path_prefix in path_prefixes:
# space = self.objectspace.space.variables[path_prefix]
# self.set_name(space)
# baseprefix = Family(
# space,
# self,
# )
# basefamily.add(baseprefix)
# for elt in self.reorder_family(space):
# self.populate_family(
# baseprefix,
# elt,
# )
# if not hasattr(baseprefix.elt, "information"):
# baseprefix.elt.information = self.objectspace.information(
# baseprefix.elt.xmlfiles
# )
# for key, value in self.objectspace.paths.get_providers_path(
# path_prefix
# ).items():
# setattr(baseprefix.elt.information, key, value)
# for key, value in self.objectspace.paths.get_suppliers_path(
# path_prefix
# ).items():
# setattr(baseprefix.elt.information, key, value)
baseelt.name = normalize_family(self.objectspace.base_option_name) baseelt.name = normalize_family(self.objectspace.base_option_name)
baseelt.description = self.objectspace.base_option_name baseelt.description = self.objectspace.base_option_name
self.reflector_objects[baseelt.path].get( self.reflector_objects[baseelt.path].get(
@ -187,7 +212,7 @@ class Common:
def populate_attrib(self): def populate_attrib(self):
"""Populate attributes""" """Populate attributes"""
keys = {"name": self.convert_str(self.elt.name)} keys = {"name": self.convert_str(self.elt.name)}
if self.elt.type != "symlink": if hasattr(self.elt, "description") and self.elt.description:
keys["doc"] = self.convert_str(self.elt.description) keys["doc"] = self.convert_str(self.elt.description)
self._populate_attrib(keys) self._populate_attrib(keys)
if self.elt.path in self.objectspace.properties: if self.elt.path in self.objectspace.properties:
@ -221,31 +246,14 @@ class Common:
properties = [] properties = []
calc_properties = [] calc_properties = []
for property_, value in values.items(): for property_, value in values.items():
if not isinstance(value, list): if value is True:
value = [value]
for val in value:
ret = self.calculation_property(val)
if isinstance(ret, bool):
if ret:
properties.append(self.convert_str(property_)) properties.append(self.convert_str(property_))
elif ret is not None: elif isinstance(value, list):
calc_properties.append(ret) for val in value:
if properties or calc_properties: calc_properties.append(self.calculation_value(val))
return ( else:
"frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})" calc_properties.append(self.calculation_value(value))
) return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})"
raise Exception("ca existe alors ...")
def calculation_property(
self,
value: Union[Calculation, bool],
) -> Optional[bool]:
if isinstance(value, Calculation):
try:
return self.calculation_value(value)
except VariableCalculationDependencyError:
return None
return value
def calc_properties( def calc_properties(
self, self,
@ -280,22 +288,54 @@ class Common:
): ):
"""Populate variable parameters""" """Populate variable parameters"""
if not isinstance(param, dict): if not isinstance(param, dict):
param = { if isinstance(param, str):
"type": "any", value = self.convert_str(param)
"value": param, else:
} value = param
return f"ParamValue({value})"
if param["type"] == "value": if param["type"] == "value":
return f"ParamValue({param['value']})" return f"ParamValue({param['value']})"
if param["type"] == "information": if param["type"] == "information":
return self.build_information_param(param) # default? really?
if param["type"] == "identifier": if self.elt.multi:
if "identifier" in param and param["identifier"] != None: default = []
return f"ParamIdentifier(identifier_index={param['identifier']})" else:
return "ParamIdentifier()" default = None
if "variable" in param:
if param["variable"].path == self.elt.path:
return f'ParamSelfInformation("{param["information"]}", {default})'
information_variable_path = param["variable"].path
information_variable = self.tiramisu.reflector_objects[
information_variable_path
]
if information_variable_path not in self.calls:
option_name = information_variable.get(self.calls, self.elt.path)
return f'ParamInformation("{param["information"]}", {default}, option={option_name})'
else:
information = (
f'ParamInformation("{param["information"]}", {default})'
)
information_name = self.tiramisu.get_information_name()
self.tiramisu.text["option"].append(
f"{information_name} = {information}"
)
information_variable.informations.append(information_name)
return information_name
return f'ParamInformation("{param["information"]}", {default})'
if param["type"] == "suffix":
if "suffix" in param and param["suffix"] != None:
return f"ParamSuffix(suffix_index={param['suffix']})"
return "ParamSuffix()"
if param["type"] == "index": if param["type"] == "index":
return "ParamIndex()" return "ParamIndex()"
if param["type"] == "variable": if param["type"] == "variable":
return self.build_variable_param(param) return self.build_option_param(
param["variable"],
param.get("propertyerror", True),
param.get("suffix"),
param.get("dynamic"),
param.get('whole', False),
)
if param["type"] == "any": if param["type"] == "any":
if isinstance(param["value"], str): if isinstance(param["value"], str):
value = self.convert_str(param["value"]) value = self.convert_str(param["value"])
@ -304,87 +344,31 @@ class Common:
return "ParamValue(" + value + ")" return "ParamValue(" + value + ")"
raise Exception("pfff") raise Exception("pfff")
def build_information_param(self, param: dict) -> str: def build_option_param(
# default? really?
if self.elt.multi:
default = []
else:
default = None
if "variable" in param:
information_variable_path = param["variable"].path
if information_variable_path == self.elt.path:
return f'ParamSelfInformation("{param["information"]}", {default})'
information_variable = self.tiramisu.reflector_objects[
information_variable_path
]
if information_variable_path not in self.calls:
option_name = information_variable.get(self.calls, self.elt.path)
return f'ParamInformation("{param["information"]}", {default}, option={option_name})'
else:
# if we want to get information from the a parent family
information = f'ParamInformation("{param["information"]}", {default})'
information_name = self.tiramisu.get_information_name()
self.tiramisu.text["option"].append(
f"{information_name} = {information}"
)
information_variable.informations.append(information_name)
return information_name
return f'ParamInformation("{param["information"]}", {default})'
def build_variable_param(
self, self,
param: dict, variable,
propertyerror,
suffix: Optional[str],
dynamic,
whole: bool,
) -> str: ) -> str:
"""build variable parameters""" """build variable parameters"""
variable = param["variable"]
whole = param.get("whole", False)
dynamic = param.get("dynamic", True)
if variable.path == self.elt.path: if variable.path == self.elt.path:
ret = f"ParamSelfOption(whole={whole}" return f"ParamSelfOption(whole={whole})"
if not dynamic:
ret += ", dynamic=False"
return ret + ")"
if whole: if whole:
msg = _( msg = f'variable param "{variable.path}" has whole attribute but it\'s not allowed for external variable'
'variable param "{0}" has whole attribute but it\'s not allowed for external variable' raise DictConsistencyError(msg, 34, self.elt.xmlfiles)
)
raise DictConsistencyError(msg.format(variable.path), 34, self.elt.xmlfiles)
if not dynamic:
msg = _(
'variable param "{0}" has dynamic attribute but it\'s not allowed for external variable'
)
raise DictConsistencyError(msg.format(variable.path), 34, self.elt.xmlfiles)
option_name = self.tiramisu.reflector_objects[variable.path].get( option_name = self.tiramisu.reflector_objects[variable.path].get(
self.calls, self.elt.path self.calls, self.elt.path
) )
params = [f"{option_name}"] params = [f"{option_name}"]
identifier = param.get("identifier") if suffix is not None:
if identifier is not None:
if not self.objectspace.paths.is_dynamic(variable.path):
msg = _("internal error, {0} is not a dynamic variable").format(
variable.path
)
raise DictConsistencyError(msg, 49, self.elt.xmlfiles)
param_type = "ParamDynOption" param_type = "ParamDynOption"
if isinstance(identifier, Calculation): params.append(self.convert_str(suffix))
identifiers = self.populate_calculation(identifier)
else:
identifiers = []
for ident in identifier:
if isinstance(ident, str):
ident = self.convert_str(ident)
identifiers.append(str(ident))
identifiers = "[" + ", ".join(identifiers) + "]"
params.append(identifiers)
if param.get("optional", False):
params.append("optional=True")
else: else:
param_type = "ParamOption" param_type = "ParamOption"
propertyerror = param.get("propertyerror", True)
if not propertyerror: if not propertyerror:
params.append("notraisepropertyerror=True") params.append("notraisepropertyerror=True")
elif propertyerror == "transitive":
params.append("raisepropertyerror=True")
return f'{param_type}({", ".join(params)})' return f'{param_type}({", ".join(params)})'
def calculation_value( def calculation_value(
@ -392,16 +376,12 @@ class Common:
function, function,
) -> str: ) -> str:
"""Generate calculated value""" """Generate calculated value"""
child = function.to_function(self.objectspace, self.elt.path) child = function.to_function(self.objectspace)
if isinstance(child, str):
return self.convert_str(child)
elif not isinstance(child, dict):
return child
new_args = [] new_args = []
kwargs = [] kwargs = []
if "params" in child: if "params" in child:
for key, value in child["params"].items(): for key, value in child["params"].items():
if key is None: if not key:
for val in value: for val in value:
new_args.append(self.populate_param(val)) new_args.append(self.populate_param(val))
else: else:
@ -414,8 +394,9 @@ class Common:
if kwargs: if kwargs:
ret += ", kwargs={" + ", ".join(kwargs) + "}" ret += ", kwargs={" + ", ".join(kwargs) + "}"
ret += ")" ret += ")"
if "warnings_only" in child: if hasattr(child, "warnings_only"):
ret += f", warnings_only={child['warnings_only']}" print("HU????")
ret += f", warnings_only={child.warnings_only}"
if "help" in child: if "help" in child:
ret += f", help_function=func['{child['help']}']" ret += f", help_function=func['{child['help']}']"
ret = ret + ")" ret = ret + ")"
@ -426,10 +407,10 @@ class Common:
datas: Union[Calculation, str, list], datas: Union[Calculation, str, list],
return_a_tuple: bool = False, return_a_tuple: bool = False,
) -> str: ) -> str:
if isinstance(datas, str):
return self.convert_str(datas)
if isinstance(datas, Calculation): if isinstance(datas, Calculation):
datas = self.calculation_value(datas) return self.calculation_value(datas)
elif isinstance(datas, str):
datas = self.convert_str(datas)
if not isinstance(datas, list): if not isinstance(datas, list):
return datas return datas
params = [] params = []
@ -438,11 +419,9 @@ class Common:
try: try:
params.append(self.calculation_value(data)) params.append(self.calculation_value(data))
except VariableCalculationDependencyError: except VariableCalculationDependencyError:
continue pass
elif isinstance(data, str): elif isinstance(data, str):
params.append(self.convert_str(data)) params.append(self.convert_str(data))
elif isinstance(data, dict):
params.append(data)
else: else:
params.append(str(data)) params.append(str(data))
if return_a_tuple: if return_a_tuple:
@ -483,23 +462,16 @@ class Variable(Common):
) )
return return
if self.elt.type == "choice": if self.elt.type == "choice":
try:
keys["values"] = self.populate_calculation( keys["values"] = self.populate_calculation(
self.elt.choices, return_a_tuple=True self.elt.choices, return_a_tuple=True
) )
if keys["values"] == "(,)": if self.elt.type == 'regexp':
keys["values"] = tuple() self.object_type = 'Regexp_' + self.option_name
except VariableCalculationDependencyError: self.tiramisu.text['header'].append(f'''class {self.object_type}(RegexpOption):
keys["values"] = tuple()
if self.elt.type == "regexp":
self.object_type = "Regexp_" + self.option_name
self.tiramisu.text["header"].append(
f"""class {self.object_type}(RegexpOption):
__slots__ = tuple() __slots__ = tuple()
_type = 'value' _type = 'value'
{self.object_type}._regexp = re_compile(r"{self.elt.regexp}") {self.object_type}._regexp = re_compile(r"{self.elt.regexp}")
""" ''')
)
if self.elt.path in self.objectspace.multis: if self.elt.path in self.objectspace.multis:
keys["multi"] = self.objectspace.multis[self.elt.path] keys["multi"] = self.objectspace.multis[self.elt.path]
if hasattr(self.elt, "default") and self.elt.default is not None: if hasattr(self.elt, "default") and self.elt.default is not None:
@ -516,8 +488,6 @@ class Variable(Common):
pass pass
if self.elt.validators: if self.elt.validators:
keys["validators"] = self.populate_calculation(self.elt.validators) keys["validators"] = self.populate_calculation(self.elt.validators)
if self.elt.warnings:
keys["warnings_only"] = True
for key, value in ( for key, value in (
CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items() CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items()
): ):
@ -544,14 +514,10 @@ class Family(Common):
if self.elt.type == "dynamic": if self.elt.type == "dynamic":
self.tiramisu.objectspace.has_dyn_option = True self.tiramisu.objectspace.has_dyn_option = True
self.object_type = "ConvertDynOptionDescription" self.object_type = "ConvertDynOptionDescription"
elif self.elt.type == "sequence": elif self.elt.type == "leadership":
self.object_type = "Leadership" self.object_type = "Leadership"
else: else:
self.object_type = "OptionDescription" self.object_type = "OptionDescription"
if hasattr(self.elt, "name") and self.elt.name == self.elt.namespace:
self.group_type = "groups.namespace"
else:
self.group_type = None
self.children = [] self.children = []
def add(self, child): def add(self, child):
@ -562,13 +528,8 @@ class Family(Common):
self, self,
keys: list, keys: list,
) -> None: ) -> None:
if self.group_type:
keys["group_type"] = self.group_type
if self.elt.type == "dynamic": if self.elt.type == "dynamic":
try: keys["suffixes"] = self.populate_calculation(self.elt.dynamic)
keys["identifiers"] = self.populate_calculation(self.elt.dynamic)
except VariableCalculationDependencyError:
keys["identifiers"] = []
children = [] children = []
for path in self.objectspace.parents[self.elt.path]: for path in self.objectspace.parents[self.elt.path]:
children.append(self.objectspace.paths[path]) children.append(self.objectspace.paths[path])

View file

@ -1,84 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2025-2026
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from .config import StaticRougailConvert
from .i18n import _
from .error import DictConsistencyError
class TypeRougailConvert(StaticRougailConvert):
def __init__(
self,
main_structural_directories: list[str],
secret_pattern: str,
default_structural_format_version: str,
) -> None:
super().__init__(
False,
{
"sort_structural_files_all": True,
"main_namespace": None,
"main_structural_directories": main_structural_directories,
},
)
self.default_structural_format_version = default_structural_format_version
self.secret_pattern = secret_pattern
self.loaded_custom_types = {}
def load_config(self) -> None:
super().load_config()
# self.add_extra_options = self.add_extra_options
self.sort_structural_files_all = False
self.structurals = ["directory"]
def rougail_type(rougailconfig):
types = rougailconfig["types"]
if not types:
return {"custom_variable_types": {}, "custom_family_types": {}}
convert = TypeRougailConvert(
types,
rougailconfig["secret_manager.pattern"],
rougailconfig["default_structural_format_version"],
)
convert.init()
convert.parse_directories()
loaded_custom_types_keys = list(convert.loaded_custom_types)
loaded_custom_types_keys.sort()
for path in loaded_custom_types_keys:
if "." not in path:
continue
current = None
*spath, name = path.split(".")
for subpath in spath:
if not current:
current = convert.loaded_custom_types[subpath]
else:
current = current.children[subpath]
current.children[name] = convert.loaded_custom_types.pop(path)
custom_variable_types = {}
custom_family_types = {}
for typ, data in convert.loaded_custom_types.items():
if data.option_type == "variable":
custom_variable_types[typ] = data
else:
custom_family_types[typ] = data
return {
"custom_variable_types": custom_variable_types,
"custom_family_types": custom_family_types,
}

View file

@ -0,0 +1,21 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2024
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from .update import RougailUpgrade

1299
src/rougail/update/update.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,717 +0,0 @@
"""
Silique (https://www.silique.fr)
Copyright (C) 2022-2026
distribued with GPL-2 or later license
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
from typing import List
from tiramisu import Calculation, Params, ParamValue, owners
from tiramisu.error import (
PropertiesOptionError,
AttributeOptionError,
LeadershipError,
ConfigError,
CancelParam,
display_list,
)
from .utils import undefined, get_properties_to_string
from .tiramisu import (
normalize_family,
CONVERT_OPTION,
get_identifier_from_dynamic_family,
)
from .error import DictConsistencyError
from .i18n import _
class UserData:
def __init__(self, config) -> None:
self.config = config
def user_data(
self,
user_data: List[dict],
*,
invalid_user_data_error: bool = False,
unknown_user_data_error: bool = False,
):
self.values = {}
self.errors = []
self.warnings = []
self.invalid_user_data_error = invalid_user_data_error
self.unknown_user_data_error = unknown_user_data_error
if self.invalid_user_data_error:
self.invalids = self.errors
else:
self.invalids = self.warnings
if self.unknown_user_data_error:
self.unknowns = self.errors
else:
self.unknowns = self.warnings
self.show_secrets = False
self._populate_values(user_data)
self._auto_configure_dynamics()
self._populate_config()
self.properties_to_string = get_properties_to_string()
self._populate_error_warnings()
return {
"errors": self.errors,
"warnings": self.warnings,
}
def _populate_values(self, user_data):
for datas in user_data:
options = datas.get("options", {})
source = datas["source"]
for name, data in datas.get("values", {}).items():
self.values.setdefault(name, []).append(
{
"source": source,
"values": data,
"options": options.copy(),
}
)
self.errors.extend(datas.get("errors", []))
self.warnings.extend(datas.get("warnings", []))
def _get_variable(self, config):
try:
for subconfig in config:
if subconfig.isoptiondescription():
yield from self._get_variable(subconfig)
else:
yield subconfig
except (ConfigError, ValueError) as err:
err.prefix = ""
if self.invalid_user_data_error:
msg = str(err)
else:
msg = _("{0}, it will be ignored").format(err)
self.invalids.append({msg: err.subconfig})
def _auto_configure_dynamics(self):
cache = {}
added = []
for path, data in list(self.values.items()):
try:
option = self.config.option(path)
option.name()
except (ConfigError, PropertiesOptionError):
pass
except AttributeError:
self._not_found_is_dynamic(self.config, path, cache, added, data[-1])
def _not_found_is_dynamic(self, config, path, cache, added, data):
"""if path is not found, check if parent is a dynamic family"""
current_path = ""
identifiers = []
# get parent
for name in path.split(".")[:-1]:
if current_path:
current_path += "."
current_path += name
if current_path in cache:
config, identifier = cache[current_path]
identifiers.append(identifier)
continue
tconfig = config.option(name)
try:
tconfig.group_type()
# object exists, so current config is the temporary config
config = tconfig
if config.isdynamic(only_self=True):
config_identifiers = config.identifiers()
if config_identifiers:
identifiers.append(config_identifiers[-1])
except AttributeError:
# try to found the good dynamic family
try:
lists = config.list(uncalculated=True)
except PropertiesOptionError:
lists = []
for tconfig in lists:
if not tconfig.isdynamic(only_self=True):
# it's not a dynamic variable
continue
identifier = get_identifier_from_dynamic_family(
tconfig.name(uncalculated=True), name
)
if identifier == "{{ identifier }}":
continue
if identifier != normalize_family(identifier):
msg = _(
'cannot load variable path "{0}", the identifier "{1}" is not valid in {2}'
).format(path, identifier, data["source"])
self.invalids.append(msg)
continue
if identifier is None:
# it's a dynamic variable but doesn't match the current name
continue
# get the variable associate to this dynamic family
dynamic_variable = tconfig.information.get(
"dynamic_variable",
None,
)
if not dynamic_variable:
# it's the good dynamic variable but it's not linked to a variable
# so cannot change the variable
continue
option = self.config.option(dynamic_variable)
option_type = option.information.get(
"type"
)
dyn_options_values = option.value.default(uncalculated=True)
if "{{ identifier }}" in dynamic_variable:
for s in identifiers:
dynamic_variable = dynamic_variable.replace(
"{{ identifier }}", str(s), 1
)
# do not add values in variable if has already a value
if dynamic_variable not in self.values and not dyn_options_values:
self.values[dynamic_variable] = [{"values": option.value.get()}]
added.append(dynamic_variable)
elif dynamic_variable not in added:
continue
config = tconfig
identifiers.append(identifier)
typ = CONVERT_OPTION.get(option_type, {}).get("func")
if typ:
identifier = typ(identifier)
if identifier not in self.values[dynamic_variable][-1]["values"]:
self.values[dynamic_variable][-1]["values"].append(identifier)
cache[current_path] = config, identifier
break
def convert_value(self, path, option, options, value):
# converted value
needs_convert = options.get("needs_convert", False)
if option.ismulti():
if options.get("multi_separator") and not isinstance(value, list):
value = value.split(options["multi_separator"])
self.values[path][-1]["values"] = value
if option.issubmulti():
value = [[val] for val in value]
if option.issubmulti():
for idx, val in enumerate(value):
if isinstance(val, list):
value[idx] = [
convert_value(option, v, needs_convert) for v in val
]
elif isinstance(value, list):
value = [convert_value(option, val, needs_convert) for val in value]
if needs_convert:
self.values[path][-1]["values"] = value
self.values[path][-1]["options"]["needs_convert"] = needs_convert
elif not isinstance(value, list):
value = convert_value(option, value, needs_convert)
return value
def _populate_config(self):
dynamics_variable = []
while self.values:
value_is_set = False
for option in self._get_variable(self.config):
values_path = path = option.path()
if path not in self.values:
if path in dynamics_variable or not option.isdynamic():
continue
values_path = option.path(uncalculated=True)
if values_path not in self.values:
continue
if option.type() == "password":
one_is_in_error = False
for values in self.values[values_path]:
if (
values.get("options", {}).get(
"allow_secrets_variables", True
)
is False
):
one_is_in_error = True
self.errors.append(
{
_(
"the variable contains secrets and should not be defined in {0}"
).format(values["source"]): option._subconfig
}
)
if one_is_in_error:
self.values.pop(values_path)
continue
values = self.values[values_path][-1]
options = values.get("options", {})
value = self.convert_value(path, option, options, values["values"])
index = option.index()
if index is not None:
if isinstance(value, tuple):
values["values"] = []
# for i in range(len(option.parent().leader().value.get())):
for i in range(option.value.len()):
values["values"].append(value)
value = values["values"]
if not isinstance(value, list) or index >= len(value):
continue
value = value[index]
option_without_index = option.index(None)
else:
option_without_index = option
if option.isleader():
# set value for a leader, it began to remove all values!
len_leader = option.value.len()
if len_leader:
for idx in range(len_leader - 1, -1, -1):
option.value.pop(idx)
if value is undefined:
continue
try:
self.set_value(option, value, options, index)
value_is_set = True
except Exception as err:
pass
# if path != option.path():
# self.values[option.path()] = self.values.pop(values_path)
else:
# value is correctly set, remove variable to the set
if index is not None:
# if it's a follower waiting for all followers are sets
values["values"][index] = undefined
for tmp_value in values["values"]:
if tmp_value != undefined:
break
else:
if path in self.values:
self.values.pop(path)
else:
dynamics_variable.append(path)
elif path in self.values:
self.values.pop(path)
else:
dynamics_variable.append(path)
if not value_is_set:
break
def _display_value(self, option, value):
if not self.show_secrets and option.type() == "password":
if not isinstance(value, list):
value = "*" * 10
else:
value = ["*" * 10 for val in value]
if isinstance(value, list):
value = display_list(value, add_quote=True)
else:
value = '"' + str(value) + '"'
return value
def _populate_error_warnings(self):
# we don't find variable, apply value just to get error or warning messages
for path, full_options in self.values.items():
options = full_options[-1]
value = options["values"]
if options.get("secret_manager"):
option = self.config.forcepermissive.option(path)
else:
option = self.config.option(path)
try:
if option.isoptiondescription():
if value:
if self.invalid_user_data_error:
msg = _(
"it's a family so we cannot set the value {0}, it has been loading from {1}"
)
else:
msg = _(
"it's a family so we cannot set the value {0}, it will be ignored when loading from {1}"
)
self.invalids.append(
{
msg.format(
self._display_value(option, value),
options["source"],
): option._subconfig
}
)
continue
if option.issymlinkoption():
err = _(
"it's a symlink option so we cannot set the value {0}"
).format(self._display_value(option, value))
if self.invalid_user_data_error:
msg = _("{0}, it has been loading from {1}").format(
err, options["source"]
)
else:
msg = _("{0}, it will be ignored when loading from {1}").format(
err, options["source"]
)
self.unknowns.append({msg: option._subconfig})
continue
except ConfigError as err:
self.invalids.append(
{
_("{0}, it has been loaded from {1}").format(
err, options["source"]
): option._subconfig
}
)
continue
except PropertiesOptionError as err:
self.unknowns.append(
{
_("{0}, it has been loaded from {1}").format(
err, options["source"]
): option._subconfig
}
)
continue
except AttributeOptionError as err:
if err.code == "option-not-found":
err_path = err.path
if "." not in err_path:
subconfig = None
child_name = err_path
else:
parent_path, child_name = err_path.rsplit(".", 1)
subconfig = self.config.option(parent_path)
subconfig._set_subconfig()
err_msg = _(
'variable or family "{0}" does not exist so cannot load "{1}"'
).format(child_name, path)
if self.unknown_user_data_error:
msg = _("{0}, it has been loading from {1}")
else:
msg = _("{0}, it will be ignored when loading from {1}")
msg = msg.format(err_msg, options["source"])
if subconfig is not None:
msg = {msg: subconfig._subconfig}
self.unknowns.append(msg)
elif err.code == "option-dynamic":
if self.invalid_user_data_error:
msg = _(
'"{0}" is the name of a dynamic family, it has been loading from {1}'
)
else:
msg = _(
'"{0}" is the name of a dynamic family, it will be ignored when loading from {1}'
)
self.invalids.append(
{
msg.format(
option.description(with_quote=True), options["source"]
): option._subconfig
}
)
else:
self.invalids.append(
_("{0} loaded from {1}").format(err, options["source"])
)
continue
value = self.convert_value(
path, option, self.values[path][-1].get("options", {}), value
)
if option.isfollower():
if not isinstance(value, tuple):
indexes = range(len(value))
else:
try:
indexes = range(len(option.parent().leader().value.get()))
except:
continue
values = value
else:
indexes = [None]
for index in indexes:
try:
if option.isfollower():
if not isinstance(value, tuple):
value = values[index]
if value is undefined or isinstance(value, CancelParam):
continue
index_ = index
else:
index_ = None
if value is undefined:
continue
self.set_value(option, value, options.get("options", {}), index_)
except PropertiesOptionError as err:
if err.code == "property-error":
properties = display_list(
[_(prop) for prop in err.proptype], add_quote=False
)
err_path = err.subconfig.path
err_description = err.subconfig.option.impl_get_display_name(
err.subconfig, with_quote=True
)
display_name = option.description(with_quote=True)
if index is not None:
if path == err_path:
if self.unknown_user_data_error:
msg = _(
'variable {0} at index "{1}" is {2}, it has been loading from {3}'
)
else:
msg = _(
'variable {0} at index "{1}" is {2}, it will be ignored when loading from {3}'
)
self.unknowns.append(
{
msg.format(
display_name,
index,
properties,
options["source"],
): option._subconfig
}
)
else:
if self.unknown_user_data_error:
msg = _(
'family {0} is {1}, {2} at index "{3}", it has been loading from {4}'
)
else:
msg = _(
'family {0} is {1}, {2} at index "{3}", it will be ignored when loading from {4}'
)
self.unknowns.append(
{
msg.format(
err_description,
properties,
display_name,
index,
options["source"],
): option._subconfig
}
)
else:
if path == err_path:
if self.unknown_user_data_error:
msg = _(
"variable has propery {0}, it has been loading from {1}"
)
else:
msg = _(
"variable has property {0}, it will be ignored when loading from {1}"
)
self.unknowns.append(
{
msg.format(
properties, options["source"]
): option._subconfig
}
)
else:
if not options.get("options", {}).get(
"secret_manager", False
):
if self.unknown_user_data_error:
msg = _(
"family {0} has property {1}, so cannot access to {2}, it has been loading from {3}"
)
else:
msg = _(
"family {0} has property {1}, so cannot access to {2}, it will be ignored when loading from {3}"
)
self.unknowns.append(
{
msg.format(
err_description,
properties,
display_name,
options["source"],
): option._subconfig
}
)
else:
if self.unknown_user_data_error:
msg = _("{0}, it has been loading from {1}")
else:
msg = _("{0}, it will be ignored when loading from {1}")
self.unknowns.append(
{msg.format(err, options["source"]): option._subconfig}
)
except LeadershipError as err:
if self.unknown_user_data_error:
msg = _("{0}, it has been loading from {1}")
else:
msg = _("{0}, it will be ignored when loading from {1}")
self.unknowns.append(
{msg.format(err, options["source"]): option._subconfig}
)
except ConfigError as err:
err.prefix = ""
if self.invalid_user_data_error:
msg = _("{0}, it has been loading from {1}").format(
err, options["source"]
)
else:
msg = _("{0}, it will be ignored when loading from {1}").format(
err, options["source"]
)
self.invalids.append({msg: option._subconfig})
except ValueError as err:
err.prefix = ""
type_ = option.type(translation=True)
msg = _("the value {0} is an invalid {1}, {2}").format(
self._display_value(option, value),
type_,
err,
)
if self.invalid_user_data_error:
msg += _(", it has been loading from {0}").format(
options["source"]
)
else:
msg += _(", it will be ignored when loading from {0}").format(
options["source"]
)
self.invalids.append({msg: option._subconfig})
except AttributeOptionError as err:
err.prefix = ""
if err.code == "option-dynamic":
continue
raise err from err
def set_value(self, option, value, options, index):
is_secret_manager = options.get("secret_manager", False)
option_without_index = option
if is_secret_manager and isinstance(value, tuple):
# it's a function
params = tuple([ParamValue(val) for val in value[1:]])
option.information.set("secret_manager", True)
if index is not None:
option = option.forcepermissive.index(index)
value = Calculation(
value[0], Params(params, kwargs={"option": ParamValue(option)})
)
option = option.forcepermissive
add_validation = True
else:
if index is not None:
option = option.index(index)
add_validation = False
if isinstance(value, list) and undefined in value:
val = []
for v in value:
if v is undefined:
val.append(None)
else:
val.append(v)
value = val
option.value.set(value)
if add_validation:
option.property.add("validator")
path = option.path()
if path not in self.values:
path = option.path(uncalculated=True)
if path in self.values and "source" in self.values[path][-1]:
if option.isfollower():
key = f"loaded_from_{index}"
else:
key = "loaded_from"
value = _("loaded from {0}").format(self.values[path][-1]["source"])
if options.get("secret_manager"):
# FIXME (true_config ???)
default = option.value.default()
if option.isleader():
default = default[0]
value = _('{0} (the search key is "{1}")').format(value, default)
option_without_index.information.set(
key,
value,
)
def convert_value(option, value, needs_convert):
if value == "":
return None
option_type = option.information.get("type")
if option_type == "port":
func = CONVERT_OPTION[option_type]["func"]
try:
return func(value)
except:
return value
if option_type == "choice":
try:
choices = option.value.list()
if value not in choices and isinstance(value, str):
# FIXME add other tests (boolean, float, ...)
if value.isnumeric() and int(value) in choices:
value = int(value)
except:
pass
func = CONVERT_OPTION.get(option_type, {}).get("func")
if func:
try:
return func(value)
except:
pass
return value
def mandatories(config, errors: list) -> None:
try:
mandatories = config.value.mandatory()
except (ConfigError, PropertiesOptionError, ValueError) as err:
try:
subconfig = err.subconfig
except AttributeError:
subconfig = None
if subconfig:
err.prefix = ""
errors.append({str(err): subconfig})
else:
errors.append(str(err))
else:
for option in mandatories:
_populate_mandatory(option, errors)
def _populate_mandatory(option, errors: list) -> None:
try:
option.value.get()
except PropertiesOptionError as err:
index = err.subconfig.index
if "empty" in err.proptype:
msg = _("null is not a valid value for a multi")
elif "mandatory" in err.proptype:
if index is None:
msg = _("mandatory variable but has no value")
else:
msg = _('mandatory variable at index "{0}" but has no value').format(
index
)
else:
if index is None:
msg = _(
"mandatory variable but is inaccessible and has no value or has null in value"
)
else:
msg = _(
'mandatory variable at index "{0}" but is inaccessible and has no value or has null in value'
).format(index)
else:
proptype = option.value.mandatory(return_type=True)
if proptype == "empty":
msg = _("null is not a valid value for a multi")
elif proptype == "mandatory":
msg = _("mandatory variable but has no value")
errors.append({msg: option._subconfig})

View file

@ -9,23 +9,26 @@ Cadoles (http://www.cadoles.com)
Copyright (C) 2019-2021 Copyright (C) 2019-2021
Silique (https://www.silique.fr) Silique (https://www.silique.fr)
Copyright (C) 2022-2026 Copyright (C) 2022-2024
This program is free software: you can redistribute it and/or modify it distribued with GPL-2 or later license
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT This program is free software; you can redistribute it and/or modify
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS it under the terms of the GNU General Public License as published by
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more the Free Software Foundation; either version 2 of the License, or
details. (at your option) any later version.
You should have received a copy of the GNU Lesser General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <http://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
""" """
from typing import List, Union from typing import List, Union
from unicodedata import normalize, combining
import re import re
from itertools import chain from itertools import chain
@ -44,8 +47,6 @@ from .error import DictConsistencyError
NAME_REGEXP = re.compile(r"^[a-z0-9_]*$") NAME_REGEXP = re.compile(r"^[a-z0-9_]*$")
PROPERTY_ATTRIBUTE = ["frozen", "hidden", "disabled", "mandatory"]
def valid_variable_family_name( def valid_variable_family_name(
name: str, name: str,
@ -54,11 +55,23 @@ def valid_variable_family_name(
match = NAME_REGEXP.search(name) match = NAME_REGEXP.search(name)
if not match: if not match:
msg = _( msg = _(
'invalid variable or family name "{0}" must only contains lowercase ascii character, number or _' f'invalid variable or family name "{name}" must only contains '
).format(name) "lowercase ascii character, number or _"
)
raise DictConsistencyError(msg, 76, xmlfiles) raise DictConsistencyError(msg, 76, xmlfiles)
def normalize_family(family_name: str) -> str:
"""replace space, accent, uppercase, ... by valid character"""
if not family_name:
return
family_name = family_name.lower()
family_name = family_name.replace("-", "_").replace(" ", "_").replace(".", "_")
nfkd_form = normalize("NFKD", family_name)
family_name = "".join([c for c in nfkd_form if not combining(c)])
return family_name.lower()
def load_modules(name, module) -> List[str]: def load_modules(name, module) -> List[str]:
"""list all functions in a module""" """list all functions in a module"""
loader = SourceFileLoader(name, module) loader = SourceFileLoader(name, module)
@ -68,10 +81,13 @@ def load_modules(name, module) -> List[str]:
return eosfunc return eosfunc
# def get_realpath( def get_realpath(
# path: str, path: str,
# ) -> str: path_prefix: str,
# return path ) -> str:
if path_prefix:
return f"{path_prefix}.{path}"
return path
def get_jinja_variable_to_param( def get_jinja_variable_to_param(
@ -80,12 +96,12 @@ def get_jinja_variable_to_param(
objectspace, objectspace,
xmlfiles, xmlfiles,
functions, functions,
path_prefix,
version, version,
namespace, namespace,
): ):
try: try:
env = SandboxedEnvironment(loader=DictLoader({"tmpl": jinja_text})) env = SandboxedEnvironment(loader=DictLoader({"tmpl": jinja_text}))
env.add_extension("jinja2.ext.do")
env.filters = functions env.filters = functions
parsed_content = Parser(env, jinja_text, "", "").parse() parsed_content = Parser(env, jinja_text, "", "").parse()
@ -101,33 +117,31 @@ def get_jinja_variable_to_param(
for g in parsed_content.find_all(Getattr): for g in parsed_content.find_all(Getattr):
variables.add(recurse_getattr(g)) variables.add(recurse_getattr(g))
except TemplateSyntaxError as err: except TemplateSyntaxError as err:
msg = _('error for the variable "{1}" in jinja "{0}": {2}').format( msg = _(f'error in jinja "{jinja_text}" for the variable "{ current_path }": {err}')
jinja_text, current_path, err
)
raise DictConsistencyError(msg, 39, xmlfiles) from err raise DictConsistencyError(msg, 39, xmlfiles) from err
except AttributeError:
pass
variables = list(variables) variables = list(variables)
variables.sort(reverse=True) variables.sort(reverse=True)
founded_variables = {} founded_variables = {}
unknown_variables = [] unknown_variables = []
for variable_path in variables: for variable_path in variables:
variable, identifier = objectspace.paths.get_with_dynamic( variable, suffix = objectspace.paths.get_with_dynamic(
variable_path, variable_path,
path_prefix,
current_path, current_path,
version, version,
namespace, namespace,
xmlfiles, xmlfiles,
) )
if variable and variable.path in objectspace.variables: if variable and variable.path in objectspace.variables:
founded_variables[variable_path] = (identifier, variable) founded_variables[variable_path] = (suffix, variable)
else: else:
sub_family = variable_path + "." sub_family = variable_path + '.'
for founded_variable in chain(founded_variables, unknown_variables): for founded_variable in chain(founded_variables, unknown_variables):
if founded_variable.startswith(sub_family): if founded_variable.startswith(sub_family):
break break
else: else:
unknown_variables.append(variable_path) unknown_variables.append(variable_path)
for variable_path in unknown_variables: for variable_path in unknown_variables:
for v in founded_variables: for v in founded_variables:
if get_common_path(v, variable_path) == v: if get_common_path(v, variable_path) == v:
@ -135,10 +149,11 @@ def get_jinja_variable_to_param(
else: else:
root_path = None root_path = None
vpath = variable_path vpath = variable_path
while "." in vpath: while '.' in vpath:
vpath = vpath.rsplit(".", 1)[0] vpath = vpath.rsplit('.', 1)[0]
variable, identifier = objectspace.paths.get_with_dynamic( variable, suffix = objectspace.paths.get_with_dynamic(
vpath, vpath,
path_prefix,
current_path, current_path,
version, version,
namespace, namespace,
@ -151,74 +166,3 @@ def get_jinja_variable_to_param(
yield {}, None, root_path yield {}, None, root_path
for variable_path, data in founded_variables.items(): for variable_path, data in founded_variables.items():
yield data[1], data[0], variable_path yield data[1], data[0], variable_path
def calc_multi_for_type_variable(
local_variable: "Variable",
variable_in_calculation_path: str,
variable_in_calculation: "Variable",
identifier_is_a_calculation: bool,
objectspace: "RougailConvert",
) -> Union[bool, str]:
variable_in_calculation_multi = variable_in_calculation.multi
if local_variable.path in objectspace.families:
# it's a family
local_variable_multi = None
else:
local_variable_multi = local_variable.multi
# variable is a leader
if variable_in_calculation.path in objectspace.leaders:
local_variable_parent = local_variable.path.rsplit(".", 1)[0]
variable_in_calculation_parent = variable_in_calculation.path.rsplit(
".", 1
)[0]
if local_variable_parent == variable_in_calculation_parent:
variable_in_calculation_multi = False
# variable is a follower
elif variable_in_calculation.path in objectspace.followers:
local_variable_parent = local_variable.path.rsplit(".", 1)[0]
variable_in_calculation_parent = variable_in_calculation.path.rsplit(
".", 1
)[0]
if local_variable_parent != variable_in_calculation_parent:
if variable_in_calculation_multi:
variable_in_calculation_multi = "submulti"
else:
variable_in_calculation_multi = True
# variable is in a dynamic family
if objectspace.paths.is_dynamic(variable_in_calculation.path):
common_path = get_common_path(
local_variable.path, variable_in_calculation_path
)
common_variable_path = variable_in_calculation_path
if common_path:
common_variable_path = common_variable_path[len(common_path) + 1 :]
if identifier_is_a_calculation:
count_identifiers = 0
else:
count_identifiers = common_variable_path.count("{{ identifier }}")
if count_identifiers == 1:
if variable_in_calculation_multi is False:
variable_in_calculation_multi = True
else:
variable_in_calculation_multi = "submulti"
elif count_identifiers > 1:
variable_in_calculation_multi = "submulti"
return local_variable_multi, variable_in_calculation_multi
class Undefined:
pass
def get_properties_to_string():
return [
("mandatory", _("mandatory")),
("hidden", _("hidden")),
("disabled", _("disabled")),
("unique", _("unique")),
("force_store_value", _("auto modified")),
]
undefined = Undefined()

View file

@ -1,8 +0,0 @@
version: 1.1
file:
type: unix_filename
params:
allow_relative: true
default:
test/unknown_file

View file

@ -2,11 +2,7 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")

View file

@ -2,12 +2,10 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[]) optiondescription_1 = OptionDescription(name="1", doc="1", children=[], properties=frozenset({"advanced"}))
optiondescription_2 = OptionDescription(name="2", doc="2", children=[], properties=frozenset({"advanced"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_2])

View file

@ -2,11 +2,7 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")

View file

@ -1,13 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])

View file

@ -1,13 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])

View file

@ -0,0 +1,3 @@
---
_version: '1.1'
version: # a variable

View file

@ -1,3 +0,0 @@
{
"rougail.version": null
}

View file

@ -2,14 +2,10 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_0version_underscore/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"basic"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,15 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_3 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
option_6 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"basic"}))
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])

View file

@ -2,13 +2,9 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_0version_underscore/rougail/00-base.yml'], 'type': 'string'}) option_1 = StrOption(name="version", doc="a variable", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -0,0 +1,3 @@
---
version: '1.0'
empty:

View file

@ -1,3 +0,0 @@
{
"rougail.empty": null
}

View file

@ -2,14 +2,10 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_2 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_1empty_variable/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"basic"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,15 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
option_3 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3], properties=frozenset({"basic"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"basic"}))
option_6 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
optiondescription_5 = OptionDescription(name="rougail", doc="Rougail", children=[option_6], properties=frozenset({"basic"}))
optiondescription_4 = OptionDescription(name="2", doc="2", children=[optiondescription_5], properties=frozenset({"basic"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_4])

View file

@ -2,13 +2,9 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
option_1 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_1empty_variable/rougail/00-base.yml'], 'type': 'string'}) option_1 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])

View file

@ -0,0 +1,10 @@
---
version: 1.1
var1: "no" # a first variable
var2:
description: a second variable
multi: true
default:
jinja: |
{{ _.var1 }}
description: the value of var1

View file

@ -1,6 +0,0 @@
{
"rougail.var1": "no",
"rougail.var2": [
"no"
]
}

View file

@ -2,16 +2,12 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_rougail.var2'] = "{{ _.var1 }}\n" dict_env['default_rougail.var2'] = "{{ _.var1 }}\n"
option_2 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), '_.var1': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml'], 'type': 'string'}) option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), '_.var1': ParamOption(option_2)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,19 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_1.rougail.var2'] = "{{ _.var1 }}\n"
dict_env['default_2.rougail.var2'] = "{{ _.var1 }}\n"
option_3 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("1.rougail.var2"), '_.var1': ParamOption(option_3)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
option_7 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_8 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("2.rougail.var2"), '_.var1': ParamOption(option_7)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"}))
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])

View file

@ -2,15 +2,11 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_var2'] = "{{ _.var1 }}\n" dict_env['default_var2'] = "{{ _.var1 }}\n"
option_1 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml'], 'type': 'string'}) option_1 = StrOption(name="var1", doc="a first variable", default="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("var2"), '_.var1': ParamOption(option_1, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("var2"), '_.var1': ParamOption(option_1)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -0,0 +1,15 @@
---
version: 1.1
var1: # a first variable
- 'no'
- 'yes'
- maybe
var2:
description: a second variable
multi: true
default:
jinja: |
{% for val in _.var1 %}
{{ val }}
{% endfor %}
description: the value of _.var1

View file

@ -1,12 +0,0 @@
{
"rougail.var1": [
"no",
"yes",
"maybe"
],
"rougail.var2": [
"no",
"yes",
"maybe"
]
}

View file

@ -2,16 +2,12 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n" dict_env['default_rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
option_2 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), '_.var1': ParamOption(option_2, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml'], 'type': 'string'}) option_3 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated_multi/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), '_.var1': ParamOption(option_2)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"})) optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", children=[option_2, option_3], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -0,0 +1,19 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('tests/dictionaries/../eosfunc/test.py')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_1.rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
dict_env['default_2.rougail.var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
option_3 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_4 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated_multi/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("1.rougail.var2"), '_.var1': ParamOption(option_3)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", children=[option_3, option_4], properties=frozenset({"standard"}))
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
option_7 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_8 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated_multi/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("2.rougail.var2"), '_.var1': ParamOption(option_7)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
optiondescription_6 = OptionDescription(name="rougail", doc="Rougail", children=[option_7, option_8], properties=frozenset({"standard"}))
optiondescription_5 = OptionDescription(name="2", doc="2", children=[optiondescription_6], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_5])

View file

@ -2,15 +2,11 @@ from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py') load_functions('tests/dictionaries/../eosfunc/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic") ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard") ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced") ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n" dict_env['default_var2'] = "{% for val in _.var1 %}\n{{ val }}\n{% endfor %}\n"
option_1 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml'], 'type': 'string'}) option_1 = StrOption(name="var1", doc="a first variable", multi=True, default=["no", "yes", "maybe"], default_multi="no", properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("var2"), '_.var1': ParamOption(option_1, notraisepropertyerror=True)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_multi/rougail/00-base.yml'], 'type': 'string'}) option_2 = StrOption(name="var2", doc="a second variable", multi=True, default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(True), '__internal_files': ParamValue(['tests/dictionaries/00_2default_calculated_multi/dictionaries/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("var2"), '_.var1': ParamOption(option_1)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2]) option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])

View file

@ -1,20 +0,0 @@
{
"rougail.leadership.var1": {
"owner": "default",
"value": [
"a_value"
]
},
"rougail.leadership.var2": {
"owner": [
"default"
],
"value": [
"a_value"
]
},
"rougail.var2": {
"owner": "default",
"value": "a_value"
}
}

View file

@ -1,9 +0,0 @@
{
"rougail.leadership.var1": [
{
"rougail.leadership.var1": "a_value",
"rougail.leadership.var2": "a_value"
}
],
"rougail.var2": "a_value"
}

View file

@ -1,20 +0,0 @@
{
"rougail.leadership.var1": {
"owner": "default",
"value": [
"a_value"
]
},
"rougail.leadership.var2": {
"owner": [
"default"
],
"value": [
"a_value"
]
},
"rougail.var2": {
"owner": "default",
"value": "a_value"
}
}

View file

@ -1,3 +0,0 @@
{
"rougail.var2": "a_value"
}

View file

@ -1,19 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_rougail.var2'] = "{{ var1[0] }}"
option_3 = StrOption(name="var1", doc="a first variable", multi=True, default=["a_value"], properties=frozenset({"force_default_on_freeze", "frozen", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
option_4 = StrOption(name="var2", doc="a first variable", multi=True, default_multi="a_value", properties=frozenset({"force_default_on_freeze", "frozen", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
optiondescription_2 = Leadership(name="leadership", doc="leadership", children=[option_3, option_4], properties=frozenset({"hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml']})
option_5 = StrOption(name="var2", doc="a second variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.var2"), 'var1': ParamOption(option_3)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[optiondescription_2, option_5], properties=frozenset({"standard"}))
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])

View file

@ -1,18 +0,0 @@
from tiramisu import *
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
from re import compile as re_compile
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
load_functions('../rougail-tests/funcs/test.py')
try:
groups.namespace
except:
groups.addgroup('namespace')
ALLOWED_LEADER_PROPERTIES.add("basic")
ALLOWED_LEADER_PROPERTIES.add("standard")
ALLOWED_LEADER_PROPERTIES.add("advanced")
dict_env['default_var2'] = "{{ var1[0] }}"
option_2 = StrOption(name="var1", doc="a first variable", multi=True, default=["a_value"], properties=frozenset({"force_default_on_freeze", "frozen", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
option_3 = StrOption(name="var2", doc="a first variable", multi=True, default_multi="a_value", properties=frozenset({"force_default_on_freeze", "frozen", "mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
optiondescription_1 = Leadership(name="leadership", doc="leadership", children=[option_2, option_3], properties=frozenset({"hidden", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml']})
option_4 = StrOption(name="var2", doc="a second variable", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_var2"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("var2"), 'var1': ParamOption(option_2)})), properties=frozenset({"mandatory", "standard"}), informations={'ymlfiles': ['../rougail-tests/structures/00_2default_calculated_params_permissive/rougail/00-base.yml'], 'type': 'string'})
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, option_4])

View file

@ -1,10 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": []
},
"rougail.var2": {
"owner": "default",
"value": []
}
}

View file

@ -1,4 +0,0 @@
{
"rougail.var1": [],
"rougail.var2": []
}

View file

@ -1,10 +0,0 @@
{
"rougail.var1": {
"owner": "default",
"value": []
},
"rougail.var2": {
"owner": "default",
"value": []
}
}

View file

@ -1 +0,0 @@
["rougail.var1", "rougail.var2"]

View file

@ -1,4 +0,0 @@
{
"rougail.var1": [],
"rougail.var2": []
}

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