WIP: Expand the developer documentation #27
4691 changed files with 28929 additions and 30518 deletions
409
CHANGELOG.md
409
CHANGELOG.md
|
|
@ -1,3 +1,412 @@
|
|||
## 1.2.0a44 (2025-11-28)
|
||||
|
||||
### Fix
|
||||
|
||||
- disabled choices must not generate error when loaded from .rougailcli.yml
|
||||
|
||||
## 1.2.0a43 (2025-11-21)
|
||||
|
||||
### Feat
|
||||
|
||||
- add boolean return_type in validators
|
||||
|
||||
### Fix
|
||||
|
||||
- better rougailconfig copy
|
||||
- port is a string
|
||||
|
||||
## 1.2.0a42 (2025-11-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- can add limit length for a variable
|
||||
|
||||
### Fix
|
||||
|
||||
- black
|
||||
|
||||
## 1.2.0a41 (2025-11-06)
|
||||
|
||||
### Feat
|
||||
|
||||
- choice if invalid value or unknown variable in user data is a fatal error or not
|
||||
|
||||
## 1.2.0a40 (2025-11-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- can add name for a tiramisu config
|
||||
- active warnings for validators
|
||||
|
||||
## 1.2.0a39 (2025-10-29)
|
||||
|
||||
### Feat
|
||||
|
||||
- add tags support
|
||||
|
||||
### Fix
|
||||
|
||||
- load config leadership
|
||||
- do not load secrets if not allowed
|
||||
- update translation
|
||||
- add test
|
||||
|
||||
## 1.2.0a38 (2025-10-22)
|
||||
|
||||
## 1.2.0a37 (2025-10-16)
|
||||
|
||||
### Feat
|
||||
|
||||
- keep forced_descriptions information (mostly for rougail-output-doc)
|
||||
|
||||
### Fix
|
||||
|
||||
- name is uncalculated
|
||||
|
||||
## 1.2.0a36 (2025-10-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- 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
|
||||
|
||||
### Fix
|
||||
|
||||
- translation for property is now in rougail
|
||||
- error in InformationCalculation errors
|
||||
- proprerty with unknown variable
|
||||
|
||||
## 1.2.0a35 (2025-10-02)
|
||||
|
||||
### Feat
|
||||
|
||||
- add warning class
|
||||
|
||||
## 1.2.0a34 (2025-09-30)
|
||||
|
||||
### Feat
|
||||
|
||||
- for formatter
|
||||
|
||||
## 1.2.0a33 (2025-09-29)
|
||||
|
||||
### Fix
|
||||
|
||||
- better doc for calculation with unknown variable
|
||||
|
||||
## 1.2.0a32 (2025-09-29)
|
||||
|
||||
### Feat
|
||||
|
||||
- **#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
|
||||
|
||||
## 1.2.0a31 (2025-09-22)
|
||||
|
||||
### Fix
|
||||
|
||||
- dictionary => structure
|
||||
|
||||
## 1.2.0a30 (2025-09-20)
|
||||
|
||||
### Feat
|
||||
|
||||
- **40**: better conflict error message with dynamic name
|
||||
- add new get_root_option function
|
||||
|
||||
### Fix
|
||||
|
||||
- update test
|
||||
|
||||
## 1.2.0a29 (2025-06-20)
|
||||
|
||||
### Fix
|
||||
|
||||
- UserDatas, do now set modified option in second round
|
||||
|
||||
## 1.2.0a28 (2025-06-18)
|
||||
|
||||
### Fix
|
||||
|
||||
- conversion
|
||||
|
||||
## 1.2.0a27 (2025-06-18)
|
||||
|
||||
### Feat
|
||||
|
||||
- separate rougail and rougail-base
|
||||
|
||||
## 1.2.0a26 (2025-05-26)
|
||||
|
||||
### Fix
|
||||
|
||||
- user_data better support for follower variable
|
||||
|
||||
## 1.2.0a25 (2025-05-14)
|
||||
|
||||
### Feat
|
||||
|
||||
- can launch UserDatas twice
|
||||
|
||||
## 1.2.0a24 (2025-05-12)
|
||||
|
||||
### Fix
|
||||
|
||||
- upgrade translation
|
||||
- black
|
||||
|
||||
## 1.2.0a23 (2025-05-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- add_quotes
|
||||
- tiramisu_display_name could display only description
|
||||
- use own undefined
|
||||
- support of default_dictionary_format_version file in tests
|
||||
- simplify version support
|
||||
|
||||
## 1.2.0a22 (2025-05-05)
|
||||
|
||||
### Fix
|
||||
|
||||
- user_datas support empty directory
|
||||
|
||||
## 1.2.0a21 (2025-05-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- support {{ suffix }} name in 1.1 format version
|
||||
- do not force use_data usage
|
||||
- validators for an index
|
||||
|
||||
## 1.2.0a20 (2025-04-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- remove symlink
|
||||
|
||||
## 1.2.0a19 (2025-04-30)
|
||||
|
||||
### Feat
|
||||
|
||||
- add ymlfile names in ConfigError message
|
||||
|
||||
### Fix
|
||||
|
||||
- update translation
|
||||
- remove negative_description support
|
||||
- redefine family in flatten mode
|
||||
- update tests
|
||||
- better multi check
|
||||
|
||||
## 1.2.0a18 (2025-04-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- version
|
||||
|
||||
## 1.2.0a17 (2025-04-09)
|
||||
|
||||
### Fix
|
||||
|
||||
- better detection of multi variable in default attribute
|
||||
- better error message
|
||||
|
||||
## 1.2.0a16 (2025-04-03)
|
||||
|
||||
### Feat
|
||||
|
||||
- reoganise param conversion + better variable validation
|
||||
|
||||
### Fix
|
||||
|
||||
- correction in namespace calculation
|
||||
|
||||
## 1.2.0a15 (2025-04-01)
|
||||
|
||||
### Feat
|
||||
|
||||
- can link regexp variable
|
||||
- can link choice variable
|
||||
|
||||
### Fix
|
||||
|
||||
- update tests
|
||||
- do not raise variable in property with force_optional
|
||||
- update translation
|
||||
|
||||
## 1.2.0a14 (2025-03-30)
|
||||
|
||||
### Fix
|
||||
|
||||
- strutural step should not be available in commandline
|
||||
|
||||
## 1.2.0a13 (2025-03-27)
|
||||
|
||||
### Fix
|
||||
|
||||
- allow no user_datas installation (for example to generate doc)
|
||||
|
||||
## 1.2.0a12 (2025-03-19)
|
||||
|
||||
### Feat
|
||||
|
||||
- add rougail secret_manager
|
||||
|
||||
## 1.2.0a11 (2025-02-17)
|
||||
|
||||
### Fix
|
||||
|
||||
- add get remove properties
|
||||
|
||||
## 1.2.0a10 (2025-02-17)
|
||||
|
||||
### Fix
|
||||
|
||||
- we can define structural plugin when generate documentation
|
||||
- if a variable in user_data not existe, it's no a warnings
|
||||
|
||||
## 1.2.0a9 (2025-02-10)
|
||||
|
||||
### Feat
|
||||
|
||||
- can change defaut params for an option
|
||||
|
||||
### Fix
|
||||
|
||||
- if no description, generate negative_description too
|
||||
- error messages
|
||||
|
||||
## 1.2.0a8 (2025-01-04)
|
||||
|
||||
### Fix
|
||||
|
||||
- better support of not_for_commandline feature
|
||||
|
||||
## 1.2.0a7 (2025-01-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- add structural_directory
|
||||
|
||||
## 1.2.0a6 (2025-01-02)
|
||||
|
||||
### Fix
|
||||
|
||||
- add path.py
|
||||
|
||||
## 1.2.0a5 (2025-01-02)
|
||||
|
||||
### Feat
|
||||
|
||||
- upgrade is not in formatter
|
||||
- remove prefix
|
||||
|
||||
## 1.2.0a4 (2024-12-11)
|
||||
|
||||
### Feat
|
||||
|
||||
- move test to a new project rougail-tests
|
||||
- output could have annotator
|
||||
|
||||
### Fix
|
||||
|
||||
- remove link
|
||||
- reorganise user_datas
|
||||
- only change prefix if path is relative
|
||||
|
||||
## 1.2.0a3 (2024-11-28)
|
||||
|
||||
### Fix
|
||||
|
||||
- add user_datas file
|
||||
|
||||
## 1.2.0a2 (2024-11-27)
|
||||
|
||||
### Feat
|
||||
|
||||
- add "exists" attribut for a family
|
||||
|
||||
### Fix
|
||||
|
||||
- separate UserDatas
|
||||
- options could be a list
|
||||
|
||||
## 1.2.0a1 (2024-11-25)
|
||||
|
||||
### Fix
|
||||
|
||||
- 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
|
||||
|
||||
## 1.2.0a0 (2024-11-08)
|
||||
|
||||
### Feat
|
||||
|
||||
- add force_optional option to allow charging structure even if all variables are not available
|
||||
|
||||
## 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)
|
||||
|
||||
### Fix
|
||||
|
|
|
|||
388
LICENSE
388
LICENSE
|
|
@ -1,235 +1,165 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 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.
|
||||
|
||||
Preamble
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
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.
|
||||
0. Additional Definitions.
|
||||
|
||||
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.
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public 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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"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.
|
||||
|
||||
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.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Source Code.
|
||||
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.
|
||||
|
||||
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 "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.
|
||||
|
||||
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
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
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:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||
|
||||
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".
|
||||
|
||||
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.
|
||||
|
||||
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/>.
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
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
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
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
|
||||
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
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
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
|
||||
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
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
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
|
||||
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
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
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:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
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
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
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
|
||||
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.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
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
|
||||
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
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser 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
|
||||
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
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
|
|
|||
37
README.md
37
README.md
|
|
@ -28,20 +28,27 @@ Create the file `dict/dictionary.yml`:
|
|||
|
||||
```yml
|
||||
---
|
||||
version: '1.0'
|
||||
version: 1.1
|
||||
# describe a variable my_first_variable
|
||||
# and a family with a variable my_second_variable
|
||||
my_first_variable:
|
||||
default: my_value
|
||||
my_first_variable: my_value
|
||||
my_family:
|
||||
my_second_variable:
|
||||
type: number
|
||||
mandatory: true
|
||||
value: 1
|
||||
my_second_variable: 1
|
||||
```
|
||||
|
||||
## Generate variable
|
||||
|
||||
### With commandline:
|
||||
|
||||
```bash
|
||||
# rougail -m dict
|
||||
Variables:
|
||||
┣━━ 📓 my_first_variable: my_value
|
||||
┗━━ 📂 my_family
|
||||
┗━━ 📓 my_second_variable: 1
|
||||
|
||||
```
|
||||
|
||||
### With default value:
|
||||
|
||||
Here is a python3 example file:
|
||||
|
|
@ -51,19 +58,16 @@ from rougail import Rougail, RougailConfig
|
|||
from pprint import pprint
|
||||
|
||||
RougailConfig['dictionaries_dir'] = ['dict']
|
||||
RougailConfig['templates_dir'] = ['tmpl']
|
||||
RougailConfig['tmp_dir'] = 'tmp'
|
||||
RougailConfig['destinations_dir'] = 'dest'
|
||||
rougail = Rougail()
|
||||
config = rougail.get_config()
|
||||
config = rougail.run()
|
||||
pprint(config.value.get(), sort_dicts=False)
|
||||
```
|
||||
|
||||
The result is:
|
||||
|
||||
```json
|
||||
{'rougail.my_first_variable': 'my_value',
|
||||
'rougail.my_family.my_second_variable': 1}
|
||||
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'my_value',
|
||||
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 1}}}
|
||||
```
|
||||
|
||||
### With modified value
|
||||
|
|
@ -76,9 +80,6 @@ from rougail import Rougail, RougailConfig
|
|||
from pprint import pprint
|
||||
|
||||
RougailConfig['dictionaries_dir'] = ['dict']
|
||||
RougailConfig['templates_dir'] = ['tmpl']
|
||||
RougailConfig['tmp_dir'] = 'tmp'
|
||||
RougailConfig['destinations_dir'] = 'dest'
|
||||
rougail = Rougail()
|
||||
config = rougail.get_config()
|
||||
config.option('rougail.my_first_variable').value.set('modified_value')
|
||||
|
|
@ -89,8 +90,8 @@ pprint(config.value.get(), sort_dicts=False)
|
|||
The destination file is generated with new values:
|
||||
|
||||
```json
|
||||
{'rougail.my_first_variable': 'modified_value',
|
||||
'rougail.my_family.my_second_variable': 2}
|
||||
{<TiramisuOption path="rougail">: {<TiramisuOption path="rougail.my_first_variable">: 'modified_value',
|
||||
<TiramisuOption path="rougail.my_family">: {<TiramisuOption path="rougail.my_family.my_second_variable">: 2}}}
|
||||
```
|
||||
|
||||
# Link
|
||||
|
|
|
|||
|
|
@ -394,6 +394,24 @@ Copy a variable in another:
|
|||
type: variable
|
||||
variable: _.my_variable
|
||||
|
||||
Copy the default value from a variable, means copy type, params and multi attribute too if not define in second variable.
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
---
|
||||
version: 1.1
|
||||
my_variable:
|
||||
multi: true
|
||||
type: domainname
|
||||
params:
|
||||
allow_ip: true
|
||||
my_calculated_variable:
|
||||
default:
|
||||
type: variable
|
||||
variable: _.var1
|
||||
|
||||
Here my_calculated_variable is a domainname variable with parameter allow_ip=True and multi to true.
|
||||
|
||||
Copy one variable to another if the source has no `property` problem:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
|
|
|||
825
locale/fr/LC_MESSAGES/rougail.po
Normal file
825
locale/fr/LC_MESSAGES/rougail.po
Normal file
|
|
@ -0,0 +1,825 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: 2025-11-21 08:31+0100\n"
|
||||
"PO-Revision-Date: 2025-11-21 08:31+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: fr\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"
|
||||
"X-Generator: Poedit 3.8\n"
|
||||
|
||||
#: src/rougail/annotator/family.py:151
|
||||
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
|
||||
msgstr ""
|
||||
"le mode d'une variable par défaut \"{0}\" n'est pas un mode valide, les "
|
||||
"modes valides sont {1}"
|
||||
|
||||
#: src/rougail/annotator/family.py:157
|
||||
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
|
||||
msgstr ""
|
||||
"le mode d'une famille par défaut \"{0}\" n'est pas un mode valide, les modes "
|
||||
"valides sont {1}"
|
||||
|
||||
#: src/rougail/annotator/family.py:189
|
||||
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
|
||||
msgstr ""
|
||||
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, les modes valides "
|
||||
"sont {2}"
|
||||
|
||||
#: src/rougail/annotator/family.py:193
|
||||
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
|
||||
msgstr ""
|
||||
"le mode \"{0}\" pour \"{1}\" n'est pas un mode valide, aucun mode ne sont "
|
||||
"définis"
|
||||
|
||||
#: src/rougail/annotator/family.py:257
|
||||
msgid ""
|
||||
"the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the "
|
||||
"higher family mode \"{2}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" est obligatoire, donc en mode \"{1}\", mais la famille a "
|
||||
"un mode supérieur \"{2}\""
|
||||
|
||||
#: src/rougail/annotator/family.py:295
|
||||
msgid ""
|
||||
"the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode "
|
||||
"\"{2}\""
|
||||
msgstr ""
|
||||
"la variable suiveuse \"{0}\" a le mode \"{1}\" mais la variable leader a un "
|
||||
"mode supérieur \"{2}\""
|
||||
|
||||
#: src/rougail/annotator/family.py:328
|
||||
msgid ""
|
||||
"the family \"{0}\" is in \"{1}\" mode but variables and families inside have "
|
||||
"the higher modes \"{2}\""
|
||||
msgstr ""
|
||||
"la famille \"{0}\" a le mode \"{1}\" mais les variables et les familles à "
|
||||
"l'intérieur ont des modes supérieurs \"{2}\""
|
||||
|
||||
#: src/rougail/annotator/family.py:346
|
||||
msgid ""
|
||||
"the variable \"{0}\" is in \"{1}\" mode but family has the higher family "
|
||||
"mode \"{2}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" est dans le mode \"{1}\" mais la famille a le mode "
|
||||
"supérieur \"{2}\""
|
||||
|
||||
#: src/rougail/annotator/property.py:161
|
||||
msgid ""
|
||||
"invalid tag name \"{0}\" should only contains lowercase ascii character, "
|
||||
"number or _"
|
||||
msgstr ""
|
||||
"nom de l'étiquette invalide \"{0}\" doit seulement contenir des caractères "
|
||||
"ascii minuscule, nombre or _"
|
||||
|
||||
#: src/rougail/annotator/property.py:166
|
||||
msgid "invalid tag name \"{0}\" should not be a name of an existing mode"
|
||||
msgstr ""
|
||||
"nom de l'étiquette invalide \"{0}\" ne doit pas être un nom de mode existant"
|
||||
|
||||
#: src/rougail/annotator/property.py:171
|
||||
msgid ""
|
||||
"invalid tag name \"{0}\" should not be the name of an available properties"
|
||||
msgstr ""
|
||||
"nom de l'étiquette invalide \"{0}\" ne doit pas être le nom d'une propriétés "
|
||||
"existantes"
|
||||
|
||||
#: src/rougail/annotator/value.py:78
|
||||
msgid ""
|
||||
"the follower \"{0}\" is not multi, so cannot have a list has default value"
|
||||
msgstr ""
|
||||
"la variable suiveuse \"{0}\" n'est pas multiple, donc ne peut avoir une "
|
||||
"liste comme valeur par défaut"
|
||||
|
||||
#: src/rougail/annotator/value.py:94
|
||||
msgid "the variable \"{0}\" is multi but has a non list default value"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" est multiple mais a une valeur par défaut sans être une "
|
||||
"liste"
|
||||
|
||||
#: src/rougail/annotator/value.py:118
|
||||
msgid "the variable \"{0}\" is a \"choice\" variable but don't have any choice"
|
||||
msgstr "la variable \"{0}\" a une variable à \"choix\" mais n'a aucun choix"
|
||||
|
||||
#: src/rougail/annotator/value.py:137
|
||||
msgid "the variable \"{0}\" is a \"regexp\" variable but don't have any regexp"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a une variable \"regexp\" mais n'a pas de \"regexp\""
|
||||
|
||||
#: src/rougail/annotator/variable.py:95
|
||||
msgid ""
|
||||
"only \"unix_user\" or \"secret\" variable type can have \"secret_manager\" "
|
||||
"attribute, but \"{0}\" has type \"{1}\""
|
||||
msgstr ""
|
||||
"seul une variable de type \"unix_user\" ou \"secret\" peut avoir l'attribut "
|
||||
"\"secret_manager\", mais \"{0}\" a le type \"{1}\""
|
||||
|
||||
#: src/rougail/annotator/variable.py:102
|
||||
msgid ""
|
||||
"the variable \"{0}\" has attribute \"secret_manager\" but is a multi variable"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a l'attribut \"secret_manager\" mais est une variable "
|
||||
"multiple"
|
||||
|
||||
#: src/rougail/annotator/variable.py:107
|
||||
msgid ""
|
||||
"the variable \"{0}\" has attribute \"secret_manager\" so must not have "
|
||||
"default value"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a l'attribut \"secret_manager\" donc ne devrait pas "
|
||||
"avoir de valeur par défaut"
|
||||
|
||||
#: src/rougail/annotator/variable.py:161
|
||||
msgid "{0} values needed, but there are {{{{ var | length }}}}"
|
||||
msgstr "il faut {0} valeurs, mais il y en a {{{{ var | length }}}}"
|
||||
|
||||
#: src/rougail/annotator/variable.py:162
|
||||
msgid "needs exactly {0} values"
|
||||
msgstr "nécessite exactement {0} valeurs"
|
||||
|
||||
#: src/rougail/annotator/variable.py:164
|
||||
msgid ""
|
||||
"a maximum of {0} values are needed, but there are {{{{ var | length }}}}"
|
||||
msgstr "il faut au maximum {0} valeurs, mais il y en a {{{{ var | length }}}}"
|
||||
|
||||
#: src/rougail/annotator/variable.py:165
|
||||
msgid "needs a maximum of {0} values"
|
||||
msgstr "nécessite au maximum {0} valeurs"
|
||||
|
||||
#: src/rougail/annotator/variable.py:169
|
||||
msgid ""
|
||||
"a minimum of {0} values are needed, but there are {{{{ var | length }}}}"
|
||||
msgstr "il faut au minimum {0} valeurs, mais il y en a {{{{ var | length }}}}"
|
||||
|
||||
#: src/rougail/annotator/variable.py:170
|
||||
msgid "needs a minimum of {0} values"
|
||||
msgstr "nécessite au minimum {0} valeurs"
|
||||
|
||||
#: src/rougail/annotator/variable.py:247
|
||||
msgid "the \"{0}\" default value is a calculation with itself"
|
||||
msgstr "la valeur par défaut \"{0}\" est un calcul avec elle-même"
|
||||
|
||||
#: src/rougail/annotator/variable.py:308
|
||||
msgid ""
|
||||
"the variable \"{0}\" has regexp attribut but has not the \"regexp\" type"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut regexp mais n'a pas le type \"regexp\""
|
||||
|
||||
#: src/rougail/annotator/variable.py:351
|
||||
msgid ""
|
||||
"the variable \"{0}\" has choices attribut but has not the \"choice\" type"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut choices mais n'a pas le type \"choice\""
|
||||
|
||||
#: src/rougail/annotator/variable.py:379
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a la valeur par défaut invalide \"{1}\" devrait être {2}"
|
||||
|
||||
#: src/rougail/config/__init__.py:276
|
||||
msgid "Structure format version by default, if not specified in structure file"
|
||||
msgstr ""
|
||||
"La version du format de la structure par défaut, si non spécifier dans le "
|
||||
"fichier de structure"
|
||||
|
||||
#: src/rougail/config/__init__.py:284
|
||||
msgid "File with functions"
|
||||
msgstr "Fichier avec les fonctions"
|
||||
|
||||
#: src/rougail/config/__init__.py:296
|
||||
msgid "All modes level available"
|
||||
msgstr "Tous les niveaux de modes valides"
|
||||
|
||||
#: src/rougail/config/__init__.py:308
|
||||
msgid "Default mode for a family"
|
||||
msgstr "Mode par défaut pour une famille"
|
||||
|
||||
#: src/rougail/config/__init__.py:328
|
||||
msgid "Default mode for a variable"
|
||||
msgstr "Mode par défaut pour une variable"
|
||||
|
||||
#: src/rougail/config/__init__.py:352
|
||||
msgid "Option name for the base option"
|
||||
msgstr "Nom de l'option pour l'option de base"
|
||||
|
||||
#: src/rougail/config/__init__.py:357
|
||||
msgid "In cache file, do not importation of Tiramisu and other dependencies"
|
||||
msgstr ""
|
||||
"Dans le fichier de cache, ne pas importer Tiramisu et autres dépendances"
|
||||
|
||||
#: src/rougail/config/__init__.py:362
|
||||
msgid "Tiramisu cache filename"
|
||||
msgstr "Nom du fichier du cache Tiramisu"
|
||||
|
||||
#: src/rougail/config/__init__.py:370
|
||||
msgid "Name of internal functions that we can use as a function"
|
||||
msgstr ""
|
||||
"Nom des fonctions internes qu'il est possible d'utiliser comme fonction"
|
||||
|
||||
#: src/rougail/config/__init__.py:376
|
||||
msgid "Name of extra annotators"
|
||||
msgstr "Nom des annotators supplémentaires"
|
||||
|
||||
#: src/rougail/config/__init__.py:382
|
||||
msgid "Suffix add to generated options name"
|
||||
msgstr "Suffix ajouté pour généré le nom des options"
|
||||
|
||||
#: src/rougail/config/__init__.py:388
|
||||
msgid "Every variables in calculation are optionals"
|
||||
msgstr "Toutes les variables dans un calcul sont optionnelles"
|
||||
|
||||
#: src/rougail/config/__init__.py:392
|
||||
msgid "Loads redefine variables even if there don't already exists"
|
||||
msgstr "Charger les variables redéfinis même si elles n'existe pas"
|
||||
|
||||
#: src/rougail/config/__init__.py:399
|
||||
msgid "The secret pattern to build item name in Bitwarden"
|
||||
msgstr "Le patron de secret pour construire le nom de l'élément dans Bitwarden"
|
||||
|
||||
#: src/rougail/config/__init__.py:400
|
||||
msgid "The pattern is in Jinja format"
|
||||
msgstr "Le patron est au format Jinja"
|
||||
|
||||
#: src/rougail/config/__init__.py:428
|
||||
msgid "Select for {0}"
|
||||
msgstr "Sélection pour {0}"
|
||||
|
||||
#: src/rougail/config/__init__.py:508
|
||||
msgid "Override default parameters for option type"
|
||||
msgstr "Sur charger les paramètre par défaut pour le type d'option"
|
||||
|
||||
#: src/rougail/config/__init__.py:511
|
||||
msgid "Default parameters for option type"
|
||||
msgstr "Paramètre par défaut pour le type d'option"
|
||||
|
||||
#: src/rougail/convert/convert.py:281
|
||||
msgid "unknown type {0} for {1}"
|
||||
msgstr "type {0} inconnu pour {1}"
|
||||
|
||||
#: src/rougail/convert/convert.py:419
|
||||
msgid "family \"{0}\" define multiple time"
|
||||
msgstr "la famille \"{0}\" est définit plusieurs fois"
|
||||
|
||||
#: src/rougail/convert/convert.py:673
|
||||
msgid "variable \"{0}\" define multiple time"
|
||||
msgstr "la variable \"{0}\" est définit plusieurs fois"
|
||||
|
||||
#: src/rougail/convert/convert.py:771
|
||||
msgid "params must be a dict for {0}"
|
||||
msgstr "params doit être une dict pour {0}"
|
||||
|
||||
#: src/rougail/convert/convert.py:792
|
||||
msgid "\"{0}\" has an invalid \"params\" for {1}: {2}"
|
||||
msgstr "\"{0}\" a un attribut \"params\" invalide pour {1}: {2}"
|
||||
|
||||
#: src/rougail/convert/convert.py:806
|
||||
msgid "secret_manager must be a dict for {0}"
|
||||
msgstr "secret_manager doit être une dict pour {0}"
|
||||
|
||||
#: src/rougail/convert/convert.py:1135
|
||||
msgid "Cannot execute annotate multiple time"
|
||||
msgstr "Ne peut exécuter l'annotation plusieurs fois"
|
||||
|
||||
#: src/rougail/convert/convert.py:1142
|
||||
msgid ""
|
||||
"invalid \"structural\" definition ({0}), we cannot load any structural file!"
|
||||
msgstr ""
|
||||
"définition invalide pour la définition des \"structures\" ({0}), aucun "
|
||||
"fichier de structure ne peut être chargé !"
|
||||
|
||||
#: src/rougail/convert/object_model.py:121
|
||||
msgid "cannot find variable \"{0}\" defined in attribute \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
"ne peut trouver la variable \"{0}\" défini dans l'attribut \"{1}\" pour "
|
||||
"\"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:127
|
||||
msgid ""
|
||||
"the variable \"{0}\" is in fact a family in attribute \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" est en faite une famille dans l'attribut \"{1}\" pour "
|
||||
"\"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:132
|
||||
#: src/rougail/convert/object_model.py:513
|
||||
msgid "unknown object \"{0}\" in attribute \"{1}\" for \"{2}\""
|
||||
msgstr "objet inconnu \"{0}\" dans l'attribut \"{1}\" pour \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:151
|
||||
msgid ""
|
||||
"identifier parameter for \"{0}\" in \"{1}\" cannot be set none dynamic family"
|
||||
msgstr ""
|
||||
"le paramètre identifier pour \"{0}\" dans \"{1}\" ne peut être placé pour "
|
||||
"une famille non dynamique"
|
||||
|
||||
#: src/rougail/convert/object_model.py:180
|
||||
msgid "cannot find variable \"{0}\" defined in \"{1}\" for \"{2}\""
|
||||
msgstr "ne peut trouver la variable \"{0}\" défini dans \"{1}\" pour \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:185
|
||||
msgid "variable \"{0}\" defined in \"{1}\" for \"{2}\" is a dynamic variable"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" défini dans \"{1}\" pour \"{2}\" est une variable "
|
||||
"dynamique"
|
||||
|
||||
#: src/rougail/convert/object_model.py:202
|
||||
msgid ""
|
||||
"the variable \"{0}\" is not a follower, so cannot have index type for param "
|
||||
"in \"{1}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" n'est pas suiveuse, donc ne peut avoir de type index "
|
||||
"comme paramètre dans \"{1}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:252
|
||||
msgid ""
|
||||
"\"warnings\" are only available with attribute \"{self.attribute_name}\" for "
|
||||
"variable \"{self.ori_path}\""
|
||||
msgstr ""
|
||||
"\"warnings\" est seulement utilisable avec l'attribut \"{self.attribute_name}"
|
||||
"\" pour la variable \"{self.ori_path}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:314
|
||||
msgid ""
|
||||
"the variable \"{0}\" has a depreciated return_type \"{1}\", please use "
|
||||
"\"{2}\" instead in \"{3}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut return_type déprécié \"{1}\", veuillez "
|
||||
"utiliser\"{2}\" au lieu de \"{3}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:404
|
||||
#: src/rougail/convert/object_model.py:435
|
||||
msgid ""
|
||||
"variable \"{0}\" has a calculating \"{1}\" with an invalid return_type, "
|
||||
"should be boolean or string, not \"{2}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un calcul \"{1}\" avec un return_type invalide, "
|
||||
"devrait être un booléen ou une chaîne de caractère, et pas \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:411
|
||||
msgid ""
|
||||
"the variable \"{0}\" has a return_type \"{1}\", for attribute \"{2}\" but "
|
||||
"has not description in {3}"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un return_type \"{1}\", pour l'attribut \"{2}\" mais "
|
||||
"n'a pas de description dans {3}"
|
||||
|
||||
#: src/rougail/convert/object_model.py:416
|
||||
msgid "value is invalid"
|
||||
msgstr "la valeur est invalide"
|
||||
|
||||
#: src/rougail/convert/object_model.py:508
|
||||
msgid ""
|
||||
"a variable \"{0}\" is needs in attribute \"{1}\" for \"{2}\" but it's a "
|
||||
"family"
|
||||
msgstr ""
|
||||
"une variable \"{0}\" est nécessaire pour l'attribut \"{1}\" pour \"{2}\" "
|
||||
"mais c'est une famille"
|
||||
|
||||
#: src/rougail/convert/object_model.py:533
|
||||
msgid ""
|
||||
"variable \"{0}\" has an attribute \"{1}\" calculated with the unknown "
|
||||
"variable \"{2}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\" calculé avec la variable "
|
||||
"inconnue \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:585
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid \"{1}\" the variable \"{2}\" is in a sub "
|
||||
"dynamic option"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" est "
|
||||
"dans une sous option dynamique"
|
||||
|
||||
#: src/rougail/convert/object_model.py:594
|
||||
msgid ""
|
||||
"the leader \"{0}\" has an invalid \"{1}\" the follower \"{2}\" is a multi"
|
||||
msgstr ""
|
||||
"la variable meneuse \"{0}\" a un attribut invalide \"{1}\", la variable "
|
||||
"suiveuse \"{2}\" est multiple"
|
||||
|
||||
#: src/rougail/convert/object_model.py:636
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" "
|
||||
"must not be multi"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" ne "
|
||||
"doit pas être multiple"
|
||||
|
||||
#: src/rougail/convert/object_model.py:650
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable must not "
|
||||
"be a multi or the variable \"{2}\" must be multi"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable ne doit pas "
|
||||
"être multiple ou la variable \"{2}\" doit être multiple"
|
||||
|
||||
#: src/rougail/convert/object_model.py:664
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable must be "
|
||||
"a multi or the variable \"{2}\" must not be multi"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable doit être "
|
||||
"multiple ou la variable \"{2}\" ne doit pas être multiple"
|
||||
|
||||
#: src/rougail/convert/object_model.py:678
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" "
|
||||
"is multi but is inside a list"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" est "
|
||||
"multiple mais est dans une liste"
|
||||
|
||||
#: src/rougail/convert/object_model.py:700
|
||||
msgid ""
|
||||
"the variable \"{0}\" is waiting for a list as \"{1}\" but the attribute "
|
||||
"\"default\" is not a list (\"{2}\")"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" attend une liste comme \"{1}\" mais l'attribut "
|
||||
"\"default\" n'est pas une liste \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:704
|
||||
msgid ""
|
||||
"the variable \"{0}\" is not waiting for a list as \"{1}\" but the attribute "
|
||||
"\"default\" is a list (\"{2}\")"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" n'attend pas une liste comme \"{1}\" mais l'attribut "
|
||||
"\"default\" est une liste \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:726
|
||||
msgid ""
|
||||
"\"{0}\" attribut shall not have an \"optional\" attribute without the "
|
||||
"\"default\" attribute for variable \"{1}\""
|
||||
msgstr ""
|
||||
"l'attribut \"{0}\" ne devrait pas avoir d'attribut \"optional\" sans "
|
||||
"l'attribut \"default\" pour la variable \"{1}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:748
|
||||
msgid ""
|
||||
"variable \"{0}\" has a default value calculated with \"{1}\" which has "
|
||||
"incompatible type"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a une valeur par défaut calculé a partir de \"{1}\" "
|
||||
"laquelle a un type incompatible"
|
||||
|
||||
#: src/rougail/convert/object_model.py:790
|
||||
msgid ""
|
||||
"the variable \"{0}\" is waiting for a boolean as \"{1}\" but the attribute "
|
||||
"\"default\" is not a boolean (\"{2}\")"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" attend un booléan comme \"{1}\" mais l'attribut "
|
||||
"\"default\" n'est pas une booléan (\"{2}\")"
|
||||
|
||||
#: src/rougail/convert/object_model.py:812
|
||||
msgid ""
|
||||
"\"when\" is not allowed in format version 1.0 for attribute \"{0}\" for "
|
||||
"variable \"{1}\""
|
||||
msgstr ""
|
||||
"\"when\" n'est pas autorisé avec le format en version 1.0 pour l'attribut "
|
||||
"\"{0}\" pour la variable \"{1}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:817
|
||||
msgid ""
|
||||
"the variable \"{0}\" has an invalid attribute \"{1}\", \"when\" and "
|
||||
"\"when_not\" cannot set together"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" a un attribut invalide \"{1}\", \"when\" et \"when_not\" "
|
||||
"ne peuvent pas être défini ensemble"
|
||||
|
||||
#: src/rougail/convert/object_model.py:825
|
||||
msgid ""
|
||||
"\"when_not\" is not allowed in format version 1.0 for attribute \"{0}\" for "
|
||||
"variable \"{1}\""
|
||||
msgstr ""
|
||||
"\"when_not\" n'est pas autorisé au format 1.0 pour l'attribut \"{0}\" pour "
|
||||
"la variable variable \"{1}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:881
|
||||
msgid ""
|
||||
"cannot find variable \"{0}\" for the information \"{1}\" when calculating "
|
||||
"\"{2}\""
|
||||
msgstr ""
|
||||
"ne peut trouver la variable \"{0}\" pour l'information \"{1}\" lors du "
|
||||
"calcul de \"{2}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:886
|
||||
msgid ""
|
||||
"identifier not allowed for the information \"{0}\" when calculating \"{1}\""
|
||||
msgstr ""
|
||||
"identifier n'est pas autorisé pour l'information \"{0}\" lors du calcul de "
|
||||
"\"{1}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:938
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\""
|
||||
msgstr "\"when\" n'est pas autorisé au format 1.0 pour l'attribut \"{0}\""
|
||||
|
||||
#: src/rougail/convert/object_model.py:944
|
||||
#: src/rougail/convert/object_model.py:954
|
||||
msgid ""
|
||||
"the identifier has an invalid attribute \"{0}\", \"when\" and \"when_not\" "
|
||||
"cannot set together"
|
||||
msgstr ""
|
||||
"l'identifiant a un attribut invalide \"{0}\", \"when\" et \"when_not\" ne "
|
||||
"peuvent pas être défini ensemble"
|
||||
|
||||
#: src/rougail/convert/object_model.py:980
|
||||
msgid ""
|
||||
"the variable \"{0}\" is not a follower, so cannot have index type for \"{1}\""
|
||||
msgstr ""
|
||||
"la variable \"{0}\" n'est pas suiveuse, donc ne peut avoir de type index "
|
||||
"pour \"{1}\""
|
||||
|
||||
#: src/rougail/convert/path.py:211
|
||||
msgid ""
|
||||
"A variable or a family located in the \"{0}\" namespace shall not be used in "
|
||||
"the \"{1}\" namespace"
|
||||
msgstr ""
|
||||
"Une variable ou une famille localisé dans l'espace de nom \"{0}\" ne devrait "
|
||||
"pas être utilisé dans l'espace de nom \"{1}\""
|
||||
|
||||
#: src/rougail/convert/tiramisureflector.py:353
|
||||
msgid "internal error, {0} is not a dynamic variable"
|
||||
msgstr "erreur interne, \"{0}\" n'est pas une variable dynamique"
|
||||
|
||||
#: src/rougail/error.py:61 src/rougail/tiramisu.py:162
|
||||
#: src/rougail/user_datas.py:412 src/rougail/user_datas.py:415
|
||||
msgid "{0} in {1}"
|
||||
msgstr "{0} dans {1}"
|
||||
|
||||
#: src/rougail/structural_commandline/annotator.py:66
|
||||
msgid "alternative_name \"{0}\" conflict with \"--help\""
|
||||
msgstr "alternative_name \"{0}\" est en conflit avec \"--help\""
|
||||
|
||||
#: src/rougail/structural_commandline/annotator.py:71
|
||||
msgid "conflict alternative_name \"{0}\": \"{1}\" and \"{2}\""
|
||||
msgstr "conflit dans les \"alternative_name\" \"{0}\": \"{1}\" et \"{2}\""
|
||||
|
||||
#: src/rougail/structural_directory/__init__.py:130
|
||||
msgid "duplicate structural file name {0}"
|
||||
msgstr "nom de fichier {0} de structure dupliqué"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:32
|
||||
msgid "Directories where structural files are placed"
|
||||
msgstr "Répertoires où sont placés les fichiers de structure"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:49
|
||||
msgid "Sort structural from differents directories"
|
||||
msgstr "Trier les fichiers de structure à partir de différents répertoires"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:58
|
||||
msgid "Main namespace name"
|
||||
msgstr "Nom de l'espace de nom principal"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:69
|
||||
msgid "Namespaces are isolated"
|
||||
msgstr "Les espaces de noms sont isolés"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:78
|
||||
msgid "Extra namespaces"
|
||||
msgstr "Espaces de nom supplémentaires"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:87
|
||||
msgid "Extra namespace name"
|
||||
msgstr "Nom de l'espace de nom supplémentaire"
|
||||
|
||||
#: src/rougail/structural_directory/config.py:93
|
||||
msgid "Directories where extra structural files are placed"
|
||||
msgstr ""
|
||||
"Répertoires où sont placés les fichiers de structure de l'espace de nom "
|
||||
"supplémentaire"
|
||||
|
||||
#: src/rougail/tiramisu.py:83
|
||||
msgid "unknown boolean value \"{0}\""
|
||||
msgstr "valeur du booléen inconnue \"{0}\""
|
||||
|
||||
#: src/rougail/tiramisu.py:335
|
||||
msgid ""
|
||||
"cannot calculating \"{0}\" attribute for variable \"{1}\" in {2} with "
|
||||
"parameters \"{3}\": {4}"
|
||||
msgstr ""
|
||||
"ne peut calculer l'attribut \"{0}\" pour la variable \"{1}\" dans {2} avec "
|
||||
"les paramètres \"{3}\" : {4}"
|
||||
|
||||
#: src/rougail/user_datas.py:145
|
||||
msgid ""
|
||||
"cannot load variable path \"{0}\", the identifier \"{1}\" is not valid in {2}"
|
||||
msgstr ""
|
||||
"ne peut charger la variable \"{0}\", l'identifiant \"{1}\" n'est pas valide "
|
||||
"dans {2}"
|
||||
|
||||
#: src/rougail/user_datas.py:229
|
||||
msgid "the variable \"{0}\" contains secrets and should not be defined in {1}"
|
||||
msgstr ""
|
||||
"la variable \"{0}\" contient des secrets et ne devrait pas être défini dans "
|
||||
"{1}"
|
||||
|
||||
#: src/rougail/user_datas.py:269
|
||||
msgid "loaded from {0}"
|
||||
msgstr "chargée depuis {0}"
|
||||
|
||||
#: src/rougail/user_datas.py:311
|
||||
msgid ""
|
||||
"cannot set the value \"{0}\" to the family {1}, it will be ignored when "
|
||||
"loading from {2}"
|
||||
msgstr ""
|
||||
"impossible de définir la valeur \"{0}\" à la famille {1}, elle sera ignorée "
|
||||
"lors du chargement depuis {2}"
|
||||
|
||||
#: src/rougail/user_datas.py:322 src/rougail/user_datas.py:339
|
||||
msgid "{0} loaded from {1}"
|
||||
msgstr "{0} chargée depuis {1}"
|
||||
|
||||
#: src/rougail/user_datas.py:327
|
||||
msgid ""
|
||||
"variable or family \"{0}\" does not exist, it will be ignored when loading "
|
||||
"from {1}"
|
||||
msgstr ""
|
||||
"la variable ou la famille \"{0}\" n'existe pas, elle sera ignorée lors du "
|
||||
"chargement depuis {1}"
|
||||
|
||||
#: src/rougail/user_datas.py:333
|
||||
msgid ""
|
||||
"\"{0}\" is the name of a dynamic family, it will be ignored when loading "
|
||||
"from {1}"
|
||||
msgstr ""
|
||||
"\"{0}\" est le nom d'une famille dynamique, il sera ignoré lors du "
|
||||
"chargement depuis {1}"
|
||||
|
||||
#: src/rougail/user_datas.py:369
|
||||
msgid ""
|
||||
"variable {0} at index \"{1}\" is {2}, it will be ignored when loading from "
|
||||
"{3}"
|
||||
msgstr ""
|
||||
"la variable {0} à l'index \"{1}\" est {2}, elle sera ignorée lors du "
|
||||
"chargement depuis {3}"
|
||||
|
||||
#: src/rougail/user_datas.py:380
|
||||
msgid ""
|
||||
"family {0} is {1}, {2} at index \"{3}\" will be ignored when loading from {4}"
|
||||
msgstr ""
|
||||
"la famille {0} est {1}, {2} à l'index \"{3}\" sera ignorée lors du "
|
||||
"chargement depuis {4}"
|
||||
|
||||
#: src/rougail/user_datas.py:393
|
||||
msgid "variable {0} is {1}, it will be ignored when loading from {2}"
|
||||
msgstr ""
|
||||
"la variable {0} est {1}, elle sera ignorée lors du chargement depuis {2}"
|
||||
|
||||
#: src/rougail/user_datas.py:401
|
||||
msgid "family {0} is {1}, {2} will be ignored when loading from {3}"
|
||||
msgstr "la famille {0} est {1}, {2} sera ignorée lors du chargement depuis {3}"
|
||||
|
||||
#: src/rougail/user_datas.py:421
|
||||
msgid ""
|
||||
"the value \"{0}\" is an invalid {1} for {2} at index \"{3}\", {4}, it will "
|
||||
"be ignored when loading from {5}"
|
||||
msgstr ""
|
||||
"la valeur \"{0}\" est un {1} invalide pour {2} à l'index \"{3}\", {4}, elle "
|
||||
"sera ignorée lors du chargement depuis {5}"
|
||||
|
||||
#: src/rougail/user_datas.py:435
|
||||
msgid ""
|
||||
"the value \"{0}\" is an invalid {1} for {2}, {3}, it will be ignored when "
|
||||
"loading from {4}"
|
||||
msgstr ""
|
||||
"la valeur \"{0}\" est un {1} invalide pour {2}, {3}, elle sera ignorée lors "
|
||||
"du chargement depuis {4}"
|
||||
|
||||
#: src/rougail/utils.py:56
|
||||
msgid ""
|
||||
"invalid variable or family name \"{0}\" must only contains lowercase ascii "
|
||||
"character, number or _"
|
||||
msgstr ""
|
||||
"nom invalide pour la variable ou famille \"{0}\" doit seulement contenir des "
|
||||
"caractères ascii minuscule, nombre or _"
|
||||
|
||||
#: src/rougail/utils.py:103
|
||||
msgid "error in jinja \"{0}\" for the variable \"{1}\": {2}"
|
||||
msgstr "erreur dans Jinja \"{0}\" pour la variable \"{1}\": {2}"
|
||||
|
||||
#: src/rougail/utils.py:212
|
||||
msgid "mandatory"
|
||||
msgstr "obligatoire"
|
||||
|
||||
#: src/rougail/utils.py:213
|
||||
msgid "hidden"
|
||||
msgstr "cachée"
|
||||
|
||||
#: src/rougail/utils.py:214
|
||||
msgid "disabled"
|
||||
msgstr "désactivé"
|
||||
|
||||
#: src/rougail/utils.py:215
|
||||
msgid "unique"
|
||||
msgstr "unique"
|
||||
|
||||
#: src/rougail/utils.py:216
|
||||
msgid "auto modified"
|
||||
msgstr "auto modifiée"
|
||||
|
||||
#, fuzzy
|
||||
#~| msgid ""
|
||||
#~| "we need {0} values when there are {{{{ var | length }}}} ({{{{ var | "
|
||||
#~| "join(\", \")}}}})"
|
||||
#~ msgid ""
|
||||
#~ "it needs {0} values maximum when there are {{{{ var | length }}}} "
|
||||
#~ "({{{{ var | join(\", \")}}}})"
|
||||
#~ msgstr ""
|
||||
#~ "we need {0} values when there are {{{{ var | length }}}} ({{{{ var | "
|
||||
#~ "join(\", \")}}}})"
|
||||
|
||||
#, fuzzy
|
||||
#~| msgid ""
|
||||
#~| "we need {0} values when there are {{{{ var | length }}}} ({{{{ var | "
|
||||
#~| "join(\", \")}}}})"
|
||||
#~ msgid ""
|
||||
#~ "it needs {0} values minimum when there are {{{{ var | length }}}} "
|
||||
#~ "({{{{ var | join(\", \")}}}})"
|
||||
#~ msgstr ""
|
||||
#~ "we need {0} values when there are {{{{ var | length }}}} ({{{{ var | "
|
||||
#~ "join(\", \")}}}})"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "the variable \"{0}\" is a family, so cannot set the value \"{1}\" in {2}"
|
||||
#~ msgstr ""
|
||||
#~ "la variable \"{0}\" est une famille, donc ne peut avoir l'avoir \"{1}\" "
|
||||
#~ "dans {2}"
|
||||
|
||||
#~ msgid "the follower \"{0}\" without multi attribute can only have one value"
|
||||
#~ msgstr ""
|
||||
#~ "la variable suiveuse \"{0}\" sans l'attribut multi peut avoir seulement "
|
||||
#~ "une valeur"
|
||||
|
||||
#~ msgid "In cache file, do importation of Tiramisu and other dependencies"
|
||||
#~ msgstr "Dans le fichier de cache, importer Tiramisu et autres dépendances"
|
||||
|
||||
#~ msgid "Variables in calculation are not optional by default"
|
||||
#~ msgstr "Les variables dans un calcul sont optionnelles par défaut"
|
||||
|
||||
#~ msgid "Variable not found \"{0}\" for attribut \"{1}\" in variable \"{2}\""
|
||||
#~ msgstr ""
|
||||
#~ "La variable \"{0}\" n'est pas trouvé pour l'attribut \"{1}\" dans la "
|
||||
#~ "variable \"{2}\""
|
||||
|
||||
#~ msgid ""
|
||||
#~ "the variable \"{0}\" has an invalid attribute \"{1}\", the variable "
|
||||
#~ "\"{2}\" is not multi but is not inside a list"
|
||||
#~ msgstr ""
|
||||
#~ "la variable \"{0}\" a un attribut invalide \"{1}\", la variable \"{2}\" "
|
||||
#~ "n'est pas multiple mais n'est pas dans une liste"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "negative_description is mandatory for boolean variable, but \"{0}\" hasn't"
|
||||
#~ msgstr ""
|
||||
#~ "l'attribut negative_description est obligatoire pour des variables "
|
||||
#~ "\"boolean\", mais \"{0}\" n'en a pas"
|
||||
|
||||
#~ msgid ""
|
||||
#~ "negative_description is only available for boolean variable, but \"{0}\" "
|
||||
#~ "is \"{1}\""
|
||||
#~ msgstr ""
|
||||
#~ "l'attribut negative_description est seulement valide pour des variables "
|
||||
#~ "\"boolean\", mais \"{0}\" est \"{1}\""
|
||||
|
||||
#~ msgid "error in {0}: {1}"
|
||||
#~ msgstr "erreur dans {0} : {1}"
|
||||
|
||||
#~ msgid "cannot find variable \"{0}\" from {1}: {2}"
|
||||
#~ msgstr "ne peut trouver la variable \"{0}\" depuis {1} : {2}"
|
||||
|
||||
#~ msgid "the option \"{0}\" is an option description"
|
||||
#~ msgstr "l'option \"{0}\" est une option description"
|
||||
|
||||
#~ msgid "Update dictionaries to newest Rougail format version"
|
||||
#~ msgstr ""
|
||||
#~ "Mettre à jour le fichier de structure vers la dernière version du format "
|
||||
#~ "de Rougail"
|
||||
|
||||
#~ msgid "Do not update dictionaries to newest Rougail format version"
|
||||
#~ msgstr ""
|
||||
#~ "Ne pas mettre à jour le fichier de structure vers la dernière version du "
|
||||
#~ "format de Rougail"
|
||||
|
||||
#~ msgid "Update informations"
|
||||
#~ msgstr "Mise à jour des informations"
|
||||
|
||||
#~ msgid "Directories where dictionary files will be placed"
|
||||
#~ msgstr "Répertoires où sont placés les fichiers de structure"
|
||||
|
||||
#~ msgid "Directories where extra files will be placed"
|
||||
#~ msgstr "Répertoires où sont placés les fichiers de structure supplémentaire"
|
||||
|
||||
#~ msgid "The family \"{0}\" already exists and it is not redefined"
|
||||
#~ msgstr "La famille \"{0}\" existe déjà et n'est pas redéfinie"
|
||||
|
||||
#~ msgid "not a XML file: {0}"
|
||||
#~ msgstr "fichier XML invalid : {0}"
|
||||
509
locale/rougail.pot
Normal file
509
locale/rougail.pot
Normal file
|
|
@ -0,0 +1,509 @@
|
|||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR ORGANIZATION
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"POT-Creation-Date: 2025-11-21 08:31+0100\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:151
|
||||
msgid "default variable mode \"{0}\" is not a valid mode, valid modes are {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:157
|
||||
msgid "default family mode \"{0}\" is not a valid mode, valid modes are {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:189
|
||||
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, valid modes are {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:193
|
||||
msgid "mode \"{0}\" for \"{1}\" is not a valid mode, no modes are available"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:257
|
||||
msgid "the variable \"{0}\" is mandatory so in \"{1}\" mode but family has the higher family mode \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:295
|
||||
msgid "the follower \"{0}\" is in \"{1}\" mode but leader have the higher mode \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:328
|
||||
msgid "the family \"{0}\" is in \"{1}\" mode but variables and families inside have the higher modes \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/family.py:346
|
||||
msgid "the variable \"{0}\" is in \"{1}\" mode but family has the higher family mode \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/property.py:161
|
||||
msgid "invalid tag name \"{0}\" should only contains lowercase ascii character, number or _"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/property.py:166
|
||||
msgid "invalid tag name \"{0}\" should not be a name of an existing mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/property.py:171
|
||||
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:95
|
||||
msgid "only \"unix_user\" or \"secret\" variable type can have \"secret_manager\" attribute, but \"{0}\" has type \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:102
|
||||
msgid "the variable \"{0}\" has attribute \"secret_manager\" but is a multi variable"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:107
|
||||
msgid "the variable \"{0}\" has attribute \"secret_manager\" so must not have default value"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:161
|
||||
msgid "{0} values needed, but there are {{{{ var | length }}}}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:162
|
||||
msgid "needs exactly {0} values"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:164
|
||||
msgid "a maximum of {0} values are needed, but there are {{{{ var | length }}}}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:165
|
||||
msgid "needs a maximum of {0} values"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:169
|
||||
msgid "a minimum of {0} values are needed, but there are {{{{ var | length }}}}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:170
|
||||
msgid "needs a minimum of {0} values"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:247
|
||||
msgid "the \"{0}\" default value is a calculation with itself"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:308
|
||||
msgid "the variable \"{0}\" has regexp attribut but has not the \"regexp\" type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:351
|
||||
msgid "the variable \"{0}\" has choices attribut but has not the \"choice\" type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/annotator/variable.py:379
|
||||
msgid "the variable \"{0}\" has an unvalid default value \"{1}\" should be in {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:276
|
||||
msgid "Structure format version by default, if not specified in structure file"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:284
|
||||
msgid "File with functions"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:296
|
||||
msgid "All modes level available"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:308
|
||||
msgid "Default mode for a family"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:328
|
||||
msgid "Default mode for a variable"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:352
|
||||
msgid "Option name for the base option"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:357
|
||||
msgid "In cache file, do not importation of Tiramisu and other dependencies"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:362
|
||||
msgid "Tiramisu cache filename"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:370
|
||||
msgid "Name of internal functions that we can use as a function"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:376
|
||||
msgid "Name of extra annotators"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:382
|
||||
msgid "Suffix add to generated options name"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:388
|
||||
msgid "Every variables in calculation are optionals"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:392
|
||||
msgid "Loads redefine variables even if there don't already exists"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:399
|
||||
msgid "The secret pattern to build item name in Bitwarden"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:400
|
||||
msgid "The pattern is in Jinja format"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:428
|
||||
msgid "Select for {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:508
|
||||
msgid "Override default parameters for option type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/config/__init__.py:511
|
||||
msgid "Default parameters for option type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:281
|
||||
msgid "unknown type {0} for {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:419
|
||||
msgid "family \"{0}\" define multiple time"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:673
|
||||
msgid "variable \"{0}\" define multiple time"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:771
|
||||
msgid "params must be a dict for {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:792
|
||||
msgid "\"{0}\" has an invalid \"params\" for {1}: {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:806
|
||||
msgid "secret_manager must be a dict for {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:1135
|
||||
msgid "Cannot execute annotate multiple time"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/convert.py:1142
|
||||
msgid "invalid \"structural\" definition ({0}), we cannot load any structural file!"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:121
|
||||
msgid "cannot find variable \"{0}\" defined in attribute \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:127
|
||||
msgid "the variable \"{0}\" is in fact a family in attribute \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:132
|
||||
#: src/rougail/convert/object_model.py:513
|
||||
msgid "unknown object \"{0}\" in attribute \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:151
|
||||
msgid "identifier parameter for \"{0}\" in \"{1}\" cannot be set none dynamic family"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:180
|
||||
msgid "cannot find variable \"{0}\" defined in \"{1}\" for \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:185
|
||||
msgid "variable \"{0}\" defined in \"{1}\" for \"{2}\" is a dynamic variable"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:202
|
||||
msgid "the variable \"{0}\" is not a follower, so cannot have index type for param in \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:252
|
||||
msgid "\"warnings\" are only available with attribute \"{self.attribute_name}\" for variable \"{self.ori_path}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:314
|
||||
msgid "the variable \"{0}\" has a depreciated return_type \"{1}\", please use \"{2}\" instead in \"{3}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:404
|
||||
#: src/rougail/convert/object_model.py:435
|
||||
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:411
|
||||
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:416
|
||||
msgid "value is invalid"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:508
|
||||
msgid "a variable \"{0}\" is needs in attribute \"{1}\" for \"{2}\" but it's a family"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:533
|
||||
msgid "variable \"{0}\" has an attribute \"{1}\" calculated with the unknown variable \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:585
|
||||
msgid "the variable \"{0}\" has an invalid \"{1}\" the variable \"{2}\" is in a sub dynamic option"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:594
|
||||
msgid "the leader \"{0}\" has an invalid \"{1}\" the follower \"{2}\" is a multi"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:636
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", the variable \"{2}\" must not be multi"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:650
|
||||
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:664
|
||||
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:678
|
||||
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:700
|
||||
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:704
|
||||
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:726
|
||||
msgid "\"{0}\" attribut shall not have an \"optional\" attribute without the \"default\" attribute for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:748
|
||||
msgid "variable \"{0}\" has a default value calculated with \"{1}\" which has incompatible type"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:790
|
||||
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:812
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:817
|
||||
msgid "the variable \"{0}\" has an invalid attribute \"{1}\", \"when\" and \"when_not\" cannot set together"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:825
|
||||
msgid "\"when_not\" is not allowed in format version 1.0 for attribute \"{0}\" for variable \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:881
|
||||
msgid "cannot find variable \"{0}\" for the information \"{1}\" when calculating \"{2}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:886
|
||||
msgid "identifier not allowed for the information \"{0}\" when calculating \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:938
|
||||
msgid "\"when\" is not allowed in format version 1.0 for attribute \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:944
|
||||
#: src/rougail/convert/object_model.py:954
|
||||
msgid "the identifier has an invalid attribute \"{0}\", \"when\" and \"when_not\" cannot set together"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/object_model.py:980
|
||||
msgid "the variable \"{0}\" is not a follower, so cannot have index type for \"{1}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/path.py:211
|
||||
msgid "A variable or a family located in the \"{0}\" namespace shall not be used in the \"{1}\" namespace"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/convert/tiramisureflector.py:353
|
||||
msgid "internal error, {0} is not a dynamic variable"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/error.py:61 src/rougail/tiramisu.py:162
|
||||
#: src/rougail/user_datas.py:412 src/rougail/user_datas.py:415
|
||||
msgid "{0} in {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/structural_commandline/annotator.py:66
|
||||
msgid "alternative_name \"{0}\" conflict with \"--help\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/structural_commandline/annotator.py:71
|
||||
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 "Directories where structural files are placed"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/structural_directory/config.py:49
|
||||
msgid "Sort structural from differents directories"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/structural_directory/config.py:58
|
||||
msgid "Main namespace name"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/structural_directory/config.py:69
|
||||
msgid "Namespaces are isolated"
|
||||
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/tiramisu.py:83
|
||||
msgid "unknown boolean value \"{0}\""
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/tiramisu.py:335
|
||||
msgid "cannot calculating \"{0}\" attribute for variable \"{1}\" in {2} with parameters \"{3}\": {4}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:145
|
||||
msgid "cannot load variable path \"{0}\", the identifier \"{1}\" is not valid in {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:229
|
||||
msgid "the variable \"{0}\" contains secrets and should not be defined in {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:269
|
||||
msgid "loaded from {0}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:311
|
||||
msgid "cannot set the value \"{0}\" to the family {1}, it will be ignored when loading from {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:322 src/rougail/user_datas.py:339
|
||||
msgid "{0} loaded from {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:327
|
||||
msgid "variable or family \"{0}\" does not exist, it will be ignored when loading from {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:333
|
||||
msgid "\"{0}\" is the name of a dynamic family, it will be ignored when loading from {1}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:369
|
||||
msgid "variable {0} at index \"{1}\" is {2}, it will be ignored when loading from {3}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:380
|
||||
msgid "family {0} is {1}, {2} at index \"{3}\" will be ignored when loading from {4}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:393
|
||||
msgid "variable {0} is {1}, it will be ignored when loading from {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:401
|
||||
msgid "family {0} is {1}, {2} will be ignored when loading from {3}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:421
|
||||
msgid "the value \"{0}\" is an invalid {1} for {2} at index \"{3}\", {4}, it will be ignored when loading from {5}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/user_datas.py:435
|
||||
msgid "the value \"{0}\" is an invalid {1} for {2}, {3}, it will be ignored when loading from {4}"
|
||||
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:103
|
||||
msgid "error in jinja \"{0}\" for the variable \"{1}\": {2}"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:212
|
||||
msgid "mandatory"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:213
|
||||
msgid "hidden"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:214
|
||||
msgid "disabled"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:215
|
||||
msgid "unique"
|
||||
msgstr ""
|
||||
|
||||
#: src/rougail/utils.py:216
|
||||
msgid "auto modified"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -1,44 +1,18 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail"
|
||||
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"
|
||||
]
|
||||
version = "1.2.0a44"
|
||||
|
||||
[tool.commitizen]
|
||||
name = "cz_conventional_commits"
|
||||
tag_format = "$version"
|
||||
version_scheme = "semver"
|
||||
version_scheme = "pep440"
|
||||
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
|
||||
changelog_merge_prerelease = true
|
||||
|
||||
|
|
|
|||
52
rougail-base-pyproject.toml
Normal file
52
rougail-base-pyproject.toml
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail-base"
|
||||
version = "1.2.0a44"
|
||||
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.4",
|
||||
"tiramisu ~= 5.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"
|
||||
35
rougail-pyproject.toml
Normal file
35
rougail-pyproject.toml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[build-system]
|
||||
build-backend = "flit_core.buildapi"
|
||||
requires = ["flit_core >=3.8.0,<4"]
|
||||
|
||||
[project]
|
||||
name = "rougail"
|
||||
version = "1.2.0a44"
|
||||
authors = [{name = "Emmanuel Garette", email = "gnunux@gnunux.info"}]
|
||||
description = "A consistency handling system that was initially designed in the configuration management"
|
||||
classifiers = [
|
||||
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
|
||||
"Programming Language :: Python",
|
||||
"Operating System :: OS Independent",
|
||||
"Natural Language :: English",
|
||||
"Natural Language :: French",
|
||||
|
||||
]
|
||||
dependencies = [
|
||||
"ruamel.yaml ~= 0.18.6",
|
||||
"pydantic ~= 2.9.2",
|
||||
"rougail-base == 1.2.0a44",
|
||||
]
|
||||
|
||||
[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"
|
||||
|
|
@ -9,73 +9,28 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 tiramisu import Config
|
||||
from copy import copy
|
||||
|
||||
from .convert import RougailConvert
|
||||
from .config import RougailConfig
|
||||
from .update import RougailUpgrade
|
||||
from .object_model import CONVERT_OPTION
|
||||
from .__version__ import __version__
|
||||
|
||||
try:
|
||||
from .convert import Rougail
|
||||
from .config import RougailConfig
|
||||
|
||||
def tiramisu_display_name(kls) -> str:
|
||||
"""Replace the Tiramisu display_name function to display path + description"""
|
||||
doc = kls.impl_get_information("doc", None)
|
||||
comment = f" ({doc})" if doc and doc != kls.impl_getname() else ""
|
||||
return f"{kls.impl_getpath()}{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.parse_directories(path_prefix)
|
||||
|
||||
def get_config(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
|
||||
|
||||
|
||||
__ALL__ = ("Rougail", "RougailConfig", "RougailUpgrade")
|
||||
__all__ = ("Rougail", "RougailConfig", "__version__")
|
||||
except ModuleNotFoundError as err:
|
||||
__all__ = ("__version__",)
|
||||
|
|
|
|||
1
src/rougail/__version__.py
Normal file
1
src/rougail/__version__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__version__ = "1.2.0a44"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
"""Annotate dictionaries
|
||||
"""Annotate structural file
|
||||
|
||||
Created by:
|
||||
EOLE (http://eole.orion.education.fr)
|
||||
|
|
@ -9,24 +9,22 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 importlib.resources
|
||||
from os.path import isfile
|
||||
from ..utils import load_modules
|
||||
|
|
@ -39,16 +37,23 @@ def get_level(module):
|
|||
return module.level
|
||||
|
||||
|
||||
def get_annotators(annotators, module_name):
|
||||
annotators[module_name] = []
|
||||
def get_annotators(annotators, module_name, file_name=None):
|
||||
if file_name is None:
|
||||
_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():
|
||||
path = str(pathobj)
|
||||
if not path.endswith(".py") or path.endswith("__.py"):
|
||||
continue
|
||||
module = load_modules(path)
|
||||
if file_name is not None and not path.endswith(full_file_name):
|
||||
continue
|
||||
module = load_modules(module_name, path)
|
||||
if "Annotator" not in dir(module):
|
||||
continue
|
||||
annotators[module_name].append(module.Annotator)
|
||||
annotators[_module_name].append(module.Annotator)
|
||||
|
||||
|
||||
class SpaceAnnotator: # pylint: disable=R0903
|
||||
|
|
@ -62,21 +67,48 @@ class SpaceAnnotator: # pylint: disable=R0903
|
|||
if ANNOTATORS is None:
|
||||
ANNOTATORS = {}
|
||||
get_annotators(ANNOTATORS, "rougail.annotator")
|
||||
for extra_annotator in objectspace.rougailconfig["extra_annotators"]:
|
||||
for extra_annotator in objectspace.extra_annotators:
|
||||
if extra_annotator in ANNOTATORS:
|
||||
continue
|
||||
get_annotators(ANNOTATORS, extra_annotator)
|
||||
for structural in objectspace.structurals:
|
||||
try:
|
||||
get_annotators(
|
||||
ANNOTATORS, f"rougail.structural_{structural}", "annotator"
|
||||
)
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
for user_data in objectspace.user_datas:
|
||||
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:
|
||||
pass
|
||||
annotators = ANNOTATORS["rougail.annotator"].copy()
|
||||
for extra_annotator in objectspace.rougailconfig["extra_annotators"]:
|
||||
for extra_annotator in objectspace.extra_annotators:
|
||||
annotators.extend(ANNOTATORS[extra_annotator])
|
||||
for structural in objectspace.structurals:
|
||||
annotators.extend(ANNOTATORS[f"rougail.structural_{structural}.annotator"])
|
||||
for user_data in objectspace.user_datas:
|
||||
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)
|
||||
functions = {}
|
||||
functions_files = objectspace.rougailconfig["functions_file"]
|
||||
if not isinstance(functions_files, list):
|
||||
functions_files = [functions_files]
|
||||
functions_files = objectspace.functions_files
|
||||
for functions_file in functions_files:
|
||||
if isfile(functions_file):
|
||||
loaded_modules = load_modules(functions_file)
|
||||
loaded_modules = load_modules("function_file", functions_file)
|
||||
for function in dir(loaded_modules):
|
||||
if function.startswith("_"):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -9,30 +9,27 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 Optional
|
||||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.utils import get_realpath
|
||||
from rougail.annotator.variable import Walk
|
||||
from rougail.object_model import VariableCalculation
|
||||
from rougail.convert.object_model import VariableCalculation
|
||||
|
||||
|
||||
class Mode: # pylint: disable=R0903
|
||||
|
|
@ -65,14 +62,21 @@ class Annotator(Walk):
|
|||
self.objectspace = objectspace
|
||||
if not self.objectspace.paths:
|
||||
return
|
||||
self.modes = {
|
||||
name: Mode(idx)
|
||||
for idx, name in enumerate(self.objectspace.rougailconfig["modes_level"])
|
||||
}
|
||||
self.check_leadership()
|
||||
self.remove_empty_families()
|
||||
self.family_names()
|
||||
self.change_modes()
|
||||
self.family_description()
|
||||
if self.objectspace.modes_level:
|
||||
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()
|
||||
else:
|
||||
for family in self.get_families():
|
||||
self.valid_mode(family)
|
||||
for variable in self.get_variables():
|
||||
self.valid_mode(variable)
|
||||
self.convert_help()
|
||||
|
||||
def check_leadership(self) -> None:
|
||||
|
|
@ -93,7 +97,10 @@ class Annotator(Walk):
|
|||
if isinstance(family, self.objectspace.family) and not self._has_variable(
|
||||
family.path
|
||||
):
|
||||
if "." in family.path:
|
||||
if (
|
||||
self.objectspace.paths.default_namespace is None
|
||||
or "." in family.path
|
||||
):
|
||||
removed_families.append(family.path)
|
||||
removed_families.reverse()
|
||||
for family in removed_families:
|
||||
|
|
@ -111,28 +118,45 @@ class Annotator(Walk):
|
|||
return True
|
||||
return False
|
||||
|
||||
def family_names(self) -> None:
|
||||
"""Set doc, path, ... to family"""
|
||||
def family_description(self) -> None:
|
||||
for family in self.get_families():
|
||||
if not family.description:
|
||||
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)
|
||||
self.objectspace.informations.add(family.path, "ymlfiles", family.xmlfiles)
|
||||
|
||||
def change_modes(self):
|
||||
"""change the mode of variables"""
|
||||
modes_level = self.objectspace.rougailconfig["modes_level"]
|
||||
default_variable_mode = self.objectspace.rougailconfig["default_variable_mode"]
|
||||
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}"
|
||||
)
|
||||
'default variable mode "{0}" is not a valid mode, valid modes are {1}'
|
||||
).format(default_variable_mode, modes_level)
|
||||
raise DictConsistencyError(msg, 72, None)
|
||||
default_family_mode = self.objectspace.rougailconfig["default_family_mode"]
|
||||
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}"
|
||||
)
|
||||
'default family mode "{0}" is not a valid mode, valid modes are {1}'
|
||||
).format(default_family_mode, modes_level)
|
||||
raise DictConsistencyError(msg, 73, None)
|
||||
families = list(self.get_families())
|
||||
for family in families:
|
||||
|
|
@ -141,17 +165,34 @@ class Annotator(Walk):
|
|||
families.reverse()
|
||||
for family in families:
|
||||
self._change_family_mode(family)
|
||||
if self.objectspace.paths.default_namespace is None:
|
||||
for variable_path in self.objectspace.parents["."]:
|
||||
variable = self.objectspace.paths[variable_path]
|
||||
if (
|
||||
variable.type == "symlink"
|
||||
or variable_path in self.objectspace.families
|
||||
):
|
||||
continue
|
||||
self._set_default_mode_variable(
|
||||
variable,
|
||||
self.default_variable_mode,
|
||||
check_level=False,
|
||||
)
|
||||
|
||||
def valid_mode(
|
||||
self,
|
||||
obj,
|
||||
) -> None:
|
||||
modes_level = self.objectspace.rougailconfig["modes_level"]
|
||||
modes_level = self.objectspace.modes_level
|
||||
if self._has_mode(obj) and obj.mode not in modes_level:
|
||||
msg = _(
|
||||
f'mode "{obj.mode}" for "{obj.name}" is not a valid mode, '
|
||||
f"valid modes are {modes_level}"
|
||||
)
|
||||
if modes_level:
|
||||
msg = _(
|
||||
'mode "{0}" for "{1}" is not a valid mode, valid modes are {2}'
|
||||
).format(obj.mode, obj.name, modes_level)
|
||||
else:
|
||||
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(
|
||||
|
|
@ -194,11 +235,12 @@ class Annotator(Walk):
|
|||
self,
|
||||
variable: "self.objectspace.variable",
|
||||
family_mode: Optional[str],
|
||||
check_level: bool = True,
|
||||
) -> None:
|
||||
# auto_save variable is set to 'basic' mode
|
||||
# if its mode is not defined by the user
|
||||
if not self._has_mode(variable) and variable.auto_save is True:
|
||||
variable.mode = self.objectspace.rougailconfig["modes_level"][0]
|
||||
variable.mode = self.objectspace.modes_level[0]
|
||||
# mandatory variable without value is a basic variable
|
||||
elif (
|
||||
not self._has_mode(variable)
|
||||
|
|
@ -206,12 +248,15 @@ class Annotator(Walk):
|
|||
and variable.default is None
|
||||
and variable.path not in self.objectspace.default_multi
|
||||
):
|
||||
variable_mode = self.objectspace.rougailconfig["modes_level"][0]
|
||||
if family_mode and self.modes[variable_mode] < self.modes[family_mode]:
|
||||
variable_mode = self.objectspace.modes_level[0]
|
||||
if (
|
||||
check_level
|
||||
and family_mode
|
||||
and self.modes[variable_mode] < self.modes[family_mode]
|
||||
):
|
||||
msg = _(
|
||||
f'the variable "{variable.name}" is mandatory so in "{variable_mode}" mode '
|
||||
f'but family has the higher family mode "{family_mode}"'
|
||||
)
|
||||
'the variable "{0}" is mandatory so in "{1}" mode but family has the higher family mode "{2}"'
|
||||
).format(variable.name, variable_mode, family_mode)
|
||||
raise DictConsistencyError(msg, 36, variable.xmlfiles)
|
||||
|
||||
variable.mode = variable_mode
|
||||
|
|
@ -231,20 +276,15 @@ class Annotator(Walk):
|
|||
leader: "self.objectspace.variable",
|
||||
follower: "self.objectspace.variable",
|
||||
) -> None:
|
||||
if follower.auto_save is True:
|
||||
msg = _(f'leader/followers "{follower.name}" could not be auto_save')
|
||||
raise DictConsistencyError(msg, 29, follower.xmlfiles)
|
||||
if leader == follower:
|
||||
# it's a leader
|
||||
if not leader.mode:
|
||||
self._set_auto_mode(
|
||||
leader, self.objectspace.rougailconfig["default_variable_mode"]
|
||||
)
|
||||
self._set_auto_mode(leader, self.default_variable_mode)
|
||||
return
|
||||
if self._has_mode(follower):
|
||||
follower_mode = follower.mode
|
||||
else:
|
||||
follower_mode = self.objectspace.rougailconfig["default_variable_mode"]
|
||||
follower_mode = self.default_variable_mode
|
||||
if self.modes[leader.mode] > self.modes[follower_mode]:
|
||||
if self._has_mode(follower) and not self._has_mode(leader):
|
||||
# if follower has mode but not the leader
|
||||
|
|
@ -253,9 +293,8 @@ class Annotator(Walk):
|
|||
# leader's mode is minimum level
|
||||
if self._has_mode(follower):
|
||||
msg = _(
|
||||
f'the follower "{follower.name}" is in "{follower_mode}" mode '
|
||||
f'but leader have the higher mode "{leader.mode}"'
|
||||
)
|
||||
'the follower "{0}" is in "{1}" mode but leader have the higher mode "{2}"'
|
||||
).format(follower.name, follower_mode, leader.mode)
|
||||
raise DictConsistencyError(msg, 63, follower.xmlfiles)
|
||||
self._set_auto_mode(follower, leader.mode)
|
||||
|
||||
|
|
@ -266,8 +305,8 @@ class Annotator(Walk):
|
|||
if family.mode:
|
||||
family_mode = family.mode
|
||||
else:
|
||||
family_mode = self.objectspace.rougailconfig["default_family_mode"]
|
||||
min_variable_mode = self.objectspace.rougailconfig["modes_level"][-1]
|
||||
family_mode = self.default_family_mode
|
||||
min_variable_mode = self.objectspace.modes_level[-1]
|
||||
# change variable mode, but not if variables are not in a family
|
||||
is_leadership = family.type == "leadership"
|
||||
if family.path in self.objectspace.parents:
|
||||
|
|
@ -277,9 +316,7 @@ class Annotator(Walk):
|
|||
continue
|
||||
if variable_path in self.objectspace.families:
|
||||
if not variable.mode:
|
||||
variable.mode = self.objectspace.rougailconfig[
|
||||
"default_family_mode"
|
||||
]
|
||||
variable.mode = self.default_family_mode
|
||||
else:
|
||||
self._change_variable_mode(variable, family_mode, is_leadership)
|
||||
if self.modes[min_variable_mode] > self.modes[variable.mode]:
|
||||
|
|
@ -288,8 +325,9 @@ class Annotator(Walk):
|
|||
# set the lower variable mode to family
|
||||
self._set_auto_mode(family, min_variable_mode)
|
||||
if self.modes[family.mode] < self.modes[min_variable_mode]:
|
||||
msg = _(f'the family "{family.name}" is in "{family.mode}" mode but variables and '
|
||||
f'families inside have the higher modes "{min_variable_mode}"')
|
||||
msg = _(
|
||||
'the family "{0}" is in "{1}" mode but variables and families inside have the higher modes "{2}"'
|
||||
).format(family.name, family.mode, min_variable_mode)
|
||||
raise DictConsistencyError(msg, 62, family.xmlfiles)
|
||||
|
||||
def _change_variable_mode(
|
||||
|
|
@ -301,34 +339,18 @@ class Annotator(Walk):
|
|||
if variable.mode:
|
||||
variable_mode = variable.mode
|
||||
else:
|
||||
variable_mode = self.objectspace.rougailconfig["default_variable_mode"]
|
||||
variable_mode = self.default_variable_mode
|
||||
# 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 self._has_mode(variable):
|
||||
msg = _(
|
||||
f'the variable "{variable.name}" is in "{variable_mode}" mode '
|
||||
f'but family has the higher family mode "{family_mode}"'
|
||||
)
|
||||
'the variable "{0}" is in "{1}" mode but family has the higher family mode "{2}"'
|
||||
).format(variable.path, variable_mode, family_mode)
|
||||
raise DictConsistencyError(msg, 61, variable.xmlfiles)
|
||||
self._set_auto_mode(variable, family_mode)
|
||||
if not variable.mode:
|
||||
variable.mode = variable_mode
|
||||
|
||||
def dynamic_families(self):
|
||||
"""link dynamic families to object"""
|
||||
for family in self.get_families():
|
||||
if family.type != "dynamic":
|
||||
continue
|
||||
for variable in self.objectspace.parents[family.path]:
|
||||
if (
|
||||
isinstance(variable, self.objectspace.family)
|
||||
and not variable.leadership
|
||||
):
|
||||
msg = _(
|
||||
f'dynamic family "{family.name}" cannot contains another family'
|
||||
)
|
||||
raise DictConsistencyError(msg, 22, family.xmlfiles)
|
||||
|
||||
def convert_help(self):
|
||||
"""Convert variable help"""
|
||||
for family in self.get_families():
|
||||
|
|
|
|||
|
|
@ -9,29 +9,29 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
from typing import Union, List
|
||||
from tiramisu.setting import PROPERTIES_MAKE_SENSE
|
||||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.annotator.variable import Walk
|
||||
from rougail.object_model import Calculation
|
||||
from rougail.convert.object_model import Calculation
|
||||
from rougail.utils import NAME_REGEXP
|
||||
|
||||
|
||||
PROPERTIES = (
|
||||
|
|
@ -112,37 +112,66 @@ class Annotator(Walk):
|
|||
self._convert_property(variable)
|
||||
if variable.hidden:
|
||||
if variable.hidden is True:
|
||||
self.frozen[variable.path] = True
|
||||
elif self.frozen.get(variable.path) is not True:
|
||||
self.frozen.setdefault(variable.path, []).append(variable.hidden)
|
||||
if variable.path in self.frozen:
|
||||
frozen = self.frozen[variable.path]
|
||||
self.frozen[path] = True
|
||||
elif self.frozen.get(path) is not True:
|
||||
self.frozen.setdefault(path, []).append(variable.hidden)
|
||||
if path in self.frozen:
|
||||
frozen = self.frozen[path]
|
||||
if frozen is True:
|
||||
value = True
|
||||
else:
|
||||
value = []
|
||||
for calculation in frozen:
|
||||
calculation_object = calculation.__class__
|
||||
calculation_dict = calculation.model_dump().copy()
|
||||
calculation_dict["attribute_name"] = "frozen"
|
||||
calculation_dict["path"] = variable.path
|
||||
value.append(calculation_object(**calculation_dict))
|
||||
calculation_copy = calculation.model_copy()
|
||||
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
|
||||
self.objectspace.properties.add(path, "force_default_on_freeze", True)
|
||||
if variable.mandatory and variable.multi:
|
||||
if not variable.empty and self.objectspace.multis.get(variable.path, False):
|
||||
# a multi could not have "None" has value
|
||||
# to permit it, just add mandatory="False"
|
||||
# to permit it, just add empty="false"
|
||||
self.objectspace.properties.add(path, "notempty", True)
|
||||
if variable.unique:
|
||||
self.objectspace.properties.add(path, "unique", True)
|
||||
if variable.unique is False:
|
||||
self.objectspace.properties.add(path, "notunique", True)
|
||||
if variable.auto_save:
|
||||
self.objectspace.properties.add(variable.path, "force_store_value", True)
|
||||
self.objectspace.properties.add(path, "force_store_value", True)
|
||||
if variable.tags:
|
||||
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 _convert_property(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -9,29 +9,27 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 rougail.annotator.variable import Walk
|
||||
|
||||
from rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.object_model import Calculation
|
||||
from rougail.convert.object_model import Calculation
|
||||
|
||||
|
||||
class Annotator(Walk): # pylint: disable=R0903
|
||||
|
|
@ -49,12 +47,15 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
self.objectspace = objectspace
|
||||
self.convert_value()
|
||||
self.valid_choices()
|
||||
self.valid_regexp()
|
||||
|
||||
def convert_value(self) -> None:
|
||||
"""convert value"""
|
||||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
if variable.version != "1.0" and variable.type == "port":
|
||||
self._convert_port(variable)
|
||||
self._convert_value(variable)
|
||||
|
||||
def _convert_value(
|
||||
|
|
@ -75,29 +76,37 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
raise DictConsistencyError(msg, 68, variable.xmlfiles)
|
||||
if variable.path in self.objectspace.followers and multi != "submulti":
|
||||
msg = _(
|
||||
f'the follower "{variable.name}" without multi attribute can only have one value'
|
||||
)
|
||||
'the follower "{0}" is not multi, so cannot have a list has default value'
|
||||
).format(variable.path)
|
||||
raise DictConsistencyError(msg, 87, variable.xmlfiles)
|
||||
if not variable.default:
|
||||
variable.default = None
|
||||
else:
|
||||
if variable.path not in self.objectspace.leaders:
|
||||
if multi == "submulti":
|
||||
self.objectspace.default_multi[
|
||||
variable.path
|
||||
] = variable.default
|
||||
self.objectspace.default_multi[variable.path] = variable.default
|
||||
variable.default = None
|
||||
else:
|
||||
self.objectspace.default_multi[variable.path] = variable.default[
|
||||
0
|
||||
]
|
||||
self.objectspace.default_multi[variable.path] = (
|
||||
variable.default[0]
|
||||
)
|
||||
elif variable.multi:
|
||||
msg = _(f'the variable "{variable.name}" is multi but has a non list default value')
|
||||
msg = _(
|
||||
'the variable "{0}" is multi but has a non list default value'
|
||||
).format(variable.path)
|
||||
raise DictConsistencyError(msg, 12, variable.xmlfiles)
|
||||
elif variable.path in self.objectspace.followers:
|
||||
self.objectspace.default_multi[variable.path] = variable.default
|
||||
variable.default = None
|
||||
|
||||
def _convert_port(self, variable) -> None:
|
||||
if variable.multi is False and isinstance(variable.default, int):
|
||||
variable.default = str(variable.default)
|
||||
elif variable.multi is True and isinstance(variable.default, list):
|
||||
for idx, value in enumerate(variable.default):
|
||||
if isinstance(value, int):
|
||||
variable.default[idx] = str(value)
|
||||
|
||||
def valid_choices(self) -> None:
|
||||
"""A variable with type "Choice" that is not mandatory must has "nil" value"""
|
||||
for variable in self.get_variables():
|
||||
|
|
@ -106,9 +115,11 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
if isinstance(variable.choices, Calculation):
|
||||
continue
|
||||
if variable.choices is None:
|
||||
msg = f'the variable "{variable.path}" is a "choice" variable but don\'t have any choice'
|
||||
msg = _(
|
||||
'the variable "{0}" is a "choice" variable but don\'t have any choice'
|
||||
).format(variable.path)
|
||||
raise DictConsistencyError(msg, 19, variable.xmlfiles)
|
||||
if not variable.mandatory:
|
||||
if not variable.mandatory and not variable.multi:
|
||||
self.add_choice_nil(variable)
|
||||
|
||||
def add_choice_nil(self, variable) -> None:
|
||||
|
|
@ -117,3 +128,13 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
if choice is None:
|
||||
return
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -9,29 +9,36 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 rougail.i18n import _
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.object_model import Calculation
|
||||
from tiramisu.error import display_list
|
||||
from rougail.i18n import _
|
||||
from rougail.utils import calc_multi_for_type_variable
|
||||
from rougail.error import DictConsistencyError
|
||||
from rougail.convert.object_model import (
|
||||
Calculation,
|
||||
VariableCalculation,
|
||||
VariableParam,
|
||||
IndexCalculation,
|
||||
JinjaCalculation,
|
||||
)
|
||||
from rougail.tiramisu import display_xmlfiles, RENAME_TYPE
|
||||
|
||||
from warnings import warn
|
||||
|
||||
|
||||
class Walk:
|
||||
|
|
@ -65,18 +72,42 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
if not objectspace.paths:
|
||||
return
|
||||
self.objectspace = objectspace
|
||||
self.forbidden_name = [
|
||||
"services",
|
||||
self.objectspace.rougailconfig["variable_namespace"],
|
||||
]
|
||||
for extra in self.objectspace.rougailconfig["extra_dictionaries"]:
|
||||
self.forbidden_name.append(extra)
|
||||
# default type inference from a default value with :term:`basic types`
|
||||
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
|
||||
self.basic_types = {
|
||||
str: "string",
|
||||
int: "integer",
|
||||
bool: "boolean",
|
||||
float: "float",
|
||||
}
|
||||
self.verify_secret_managers()
|
||||
self.verify_choices()
|
||||
self.convert_variable()
|
||||
self.convert_test()
|
||||
self.convert_examples()
|
||||
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)
|
||||
|
||||
def convert_variable(self):
|
||||
"""convert variable"""
|
||||
|
|
@ -85,33 +116,168 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
continue
|
||||
if variable.version != "1.0":
|
||||
self._convert_variable_inference(variable)
|
||||
if variable.multi is None:
|
||||
variable.multi = False
|
||||
if variable.type is None:
|
||||
variable.type = "string"
|
||||
self._convert_variable_multi(variable)
|
||||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
if variable.type in RENAME_TYPE:
|
||||
warning = f'the variable "{ variable.path }" has a depreciated type "{variable.type}", please use "{RENAME_TYPE[variable.type]}" instead in {display_xmlfiles(variable.xmlfiles)}'
|
||||
warn(
|
||||
warning,
|
||||
DeprecationWarning,
|
||||
)
|
||||
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(
|
||||
variable.path, "ymlfiles", variable.xmlfiles
|
||||
)
|
||||
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)
|
||||
)
|
||||
if calculated_variable is not None:
|
||||
self._default_variable_copy_informations(
|
||||
variable, calculated_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(
|
||||
path=variable.path,
|
||||
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)
|
||||
|
||||
def _convert_variable_inference(
|
||||
self,
|
||||
variable,
|
||||
self,
|
||||
variable,
|
||||
) -> None:
|
||||
# variable has no type
|
||||
if variable.type is None:
|
||||
# choice type inference from the `choices` attribute
|
||||
if variable.choices is not None:
|
||||
variable.type = "choice"
|
||||
elif variable.default not in [None, []]:
|
||||
if isinstance(variable.default, list):
|
||||
tested_value = variable.default[0]
|
||||
else:
|
||||
tested_value = variable.default
|
||||
variable.type = self.basic_types.get(type(tested_value), None)
|
||||
# variable has no multi attribute
|
||||
if variable.multi is None:
|
||||
if variable.path in self.objectspace.leaders:
|
||||
variable.multi = True
|
||||
if variable.type is not None:
|
||||
return
|
||||
# choice type inference from the `choices` attribute
|
||||
if variable.choices is not None:
|
||||
variable.type = "choice"
|
||||
elif variable.regexp is not None:
|
||||
variable.type = "regexp"
|
||||
elif variable.default not in [None, []]:
|
||||
if isinstance(variable.default, list):
|
||||
tested_value = variable.default[0]
|
||||
else:
|
||||
variable.multi = isinstance(variable.default, list)
|
||||
tested_value = variable.default
|
||||
variable.type = self.basic_types.get(type(tested_value), None)
|
||||
|
||||
def _convert_variable_multi(
|
||||
self,
|
||||
variable,
|
||||
) -> None:
|
||||
# variable has no multi attribute
|
||||
if variable.multi is not None:
|
||||
return
|
||||
if variable.path in self.objectspace.leaders:
|
||||
variable.multi = self.objectspace.multis[variable.path] = True
|
||||
elif variable.version != "1.0" and isinstance(
|
||||
variable.default, VariableCalculation
|
||||
):
|
||||
calculated_variable_path, calculated_variable, identifier = (
|
||||
variable.default.get_variable(self.objectspace)
|
||||
)
|
||||
if calculated_variable is not None:
|
||||
if calculated_variable.multi is None:
|
||||
if (
|
||||
isinstance(calculated_variable.default, VariableCalculation)
|
||||
and variable.path == calculated_variable.default.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)
|
||||
variable.multi = calc_multi_for_type_variable(
|
||||
variable,
|
||||
calculated_variable_path,
|
||||
calculated_variable,
|
||||
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:
|
||||
variable.multi = isinstance(variable.default, list)
|
||||
|
||||
def _default_variable_copy_informations(
|
||||
self,
|
||||
variable,
|
||||
calculated_variable,
|
||||
) -> None:
|
||||
# copy type and params
|
||||
variable.type = calculated_variable.type
|
||||
if variable.params is None and calculated_variable.params is not None:
|
||||
variable.params = calculated_variable.params
|
||||
if variable.type == "choice" and variable.choices is None:
|
||||
variable.choices = calculated_variable.choices
|
||||
if variable.type == "regexp" and variable.regexp is None:
|
||||
variable.regexp = calculated_variable.regexp
|
||||
|
||||
def _convert_variable(
|
||||
self,
|
||||
|
|
@ -120,6 +286,10 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
# variable without description: description is the name
|
||||
if not variable.description:
|
||||
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 not variable.multi:
|
||||
self.objectspace.multis[variable.path] = True
|
||||
|
|
@ -128,29 +298,42 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
elif variable.multi:
|
||||
self.objectspace.multis[variable.path] = True
|
||||
if variable.path in self.objectspace.leaders:
|
||||
if not self.objectspace.multis.get(variable.path, False):
|
||||
msg = _(f'the variable "{variable.path}" in a leadership must be multi')
|
||||
raise DictConsistencyError(msg, 32, variable.xmlfiles)
|
||||
family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
|
||||
if variable.hidden:
|
||||
family.hidden = variable.hidden
|
||||
elif family.hidden:
|
||||
variable.hidden = family.hidden
|
||||
# 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 choice attribut but has not the "choice" type')
|
||||
raise DictConsistencyError(msg, 11, variable.xmlfiles)
|
||||
if variable.regexp is not None and variable.type != "regexp":
|
||||
msg = _(
|
||||
'the variable "{0}" has regexp attribut but has not the "regexp" type'
|
||||
).format(variable.path)
|
||||
raise DictConsistencyError(msg, 37, variable.xmlfiles)
|
||||
if variable.mandatory is None:
|
||||
variable.mandatory = True
|
||||
|
||||
def convert_test(self):
|
||||
"""Convert variable tests value"""
|
||||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
if variable.test is None:
|
||||
# with we want remove test, we set "" has test value
|
||||
continue
|
||||
self.objectspace.informations.add(
|
||||
variable.path, "test", tuple(variable.test)
|
||||
)
|
||||
|
||||
def convert_examples(self):
|
||||
"""Convert variable tests value"""
|
||||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
if variable.examples is None:
|
||||
continue
|
||||
self.objectspace.informations.add(
|
||||
variable.path, "examples", tuple(variable.examples)
|
||||
)
|
||||
|
||||
def convert_help(self):
|
||||
"""Convert variable help"""
|
||||
for variable in self.get_variables():
|
||||
|
|
@ -161,8 +344,20 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
|
||||
def verify_choices(self):
|
||||
for variable in self.get_variables():
|
||||
if variable.default is None or variable.type != 'choice':
|
||||
if variable.type is None and variable.choices:
|
||||
# choice type inference from the `choices` attribute
|
||||
variable.type = "choice"
|
||||
if variable.choices is not None and variable.type != "choice":
|
||||
msg = _(
|
||||
'the variable "{0}" has choices attribut but has not the "choice" type'
|
||||
).format(variable.path)
|
||||
raise DictConsistencyError(msg, 11, variable.xmlfiles)
|
||||
if variable.type != "choice":
|
||||
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):
|
||||
continue
|
||||
choices = variable.choices
|
||||
|
|
@ -181,5 +376,11 @@ class Annotator(Walk): # pylint: disable=R0903
|
|||
if isinstance(value, Calculation):
|
||||
continue
|
||||
if value not in choices:
|
||||
msg = _(f'the variable "{variable.path}" has an unvalid default value "{value}" should be in {display_list(choices, separator="or", add_quote=True)}')
|
||||
msg = _(
|
||||
'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)
|
||||
|
|
|
|||
|
|
@ -1,79 +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-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 os.path import abspath, dirname, join
|
||||
|
||||
ROUGAILROOT = "/srv/rougail"
|
||||
DTDDIR = join(dirname(abspath(__file__)), "data")
|
||||
|
||||
|
||||
RougailConfig = {
|
||||
"default_dictionary_format_version": None,
|
||||
"dictionaries_dir": [join(ROUGAILROOT, "dictionaries")],
|
||||
"extra_dictionaries": {},
|
||||
"services_dir": [join(ROUGAILROOT, "services")],
|
||||
"patches_dir": join(ROUGAILROOT, "patches"),
|
||||
"templates_dir": join(ROUGAILROOT, "templates"),
|
||||
"destinations_dir": join(ROUGAILROOT, "destinations"),
|
||||
"tmp_dir": join(ROUGAILROOT, "tmp"),
|
||||
"functions_file": join(ROUGAILROOT, "functions.py"),
|
||||
"system_service_directory": "/usr/lib/systemd/system",
|
||||
"systemd_service_destination_directory": "/usr/local/lib",
|
||||
"systemd_service_directory": "/systemd",
|
||||
"systemd_service_file": "rougail.conf",
|
||||
"systemd_service_ip_file": "rougail_ip.conf",
|
||||
"systemd_tmpfile_factory_dir": "/usr/local/lib",
|
||||
"systemd_tmpfile_directory": "/tmpfiles.d",
|
||||
"systemd_tmpfile_file": "0rougail.conf",
|
||||
"systemd_tmpfile_delete_before_create": False,
|
||||
"variable_namespace": "rougail",
|
||||
"variable_namespace_description": "Rougail",
|
||||
"auto_freeze_variable": "server_deployed",
|
||||
"internal_functions": [],
|
||||
"multi_functions": [],
|
||||
"extra_annotators": [],
|
||||
"modes_level": ["basic", "standard", "advanced"],
|
||||
"default_family_mode": "basic",
|
||||
"default_variable_mode": "standard",
|
||||
"default_files_engine": "jinja",
|
||||
"default_files_mode": 644,
|
||||
"default_files_owner": "root",
|
||||
"default_files_group": "root",
|
||||
"default_files_included": "no",
|
||||
"default_overrides_engine": "jinja",
|
||||
"default_service_names_engine": "none",
|
||||
"default_certificate_domain": "rougail.server_name",
|
||||
"base_option_name": "baseoption",
|
||||
"export_with_import": True,
|
||||
"force_convert_dyn_option_description": False,
|
||||
"suffix": "",
|
||||
"tiramisu_cache": None,
|
||||
"custom_types": {},
|
||||
}
|
||||
585
src/rougail/config/__init__.py
Normal file
585
src/rougail/config/__init__.py
Normal file
|
|
@ -0,0 +1,585 @@
|
|||
"""
|
||||
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-2025
|
||||
|
||||
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 ruamel.yaml import YAML
|
||||
from ..utils import _, load_modules
|
||||
from ..tiramisu import normalize_family
|
||||
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):
|
||||
rougailconfig = _RougailConfig(
|
||||
self.backward_compatibility,
|
||||
self.add_extra_options,
|
||||
)
|
||||
if self.root:
|
||||
rougailconfig.generate_config()
|
||||
rougailconfig.config.value.importation(self.config.value.exportation())
|
||||
rougailconfig.config.property.importation(
|
||||
self.config.property.exportation()
|
||||
)
|
||||
rougailconfig.config.property.read_only()
|
||||
rougailconfig.extra_vars = self.extra_vars.copy()
|
||||
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):
|
||||
root, extra_vars = _rougail_config(
|
||||
self.backward_compatibility, self.add_extra_options
|
||||
)
|
||||
self.root = root
|
||||
self.config = Config(
|
||||
self.root,
|
||||
)
|
||||
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()
|
||||
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():
|
||||
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)
|
||||
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 self.root is None:
|
||||
self.generate_config()
|
||||
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 __contains__(
|
||||
self,
|
||||
key,
|
||||
) -> None:
|
||||
try:
|
||||
self.__getitem__(key)
|
||||
except AttributeError:
|
||||
return False
|
||||
return True
|
||||
|
||||
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 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))
|
||||
|
||||
|
||||
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_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_datas = []
|
||||
self.output = None
|
||||
self.add_extra_options = self.add_extra_options
|
||||
self.tiramisu_cache = False
|
||||
self.load_unexist_redefine = False
|
||||
|
||||
|
||||
def _rougail_config(
|
||||
backward_compatibility: bool = True,
|
||||
add_extra_options: bool = True,
|
||||
) -> "OptionDescription":
|
||||
rougail_options = f"""default_structural_format_version:
|
||||
description: {_('Structure format version by default, if not specified in structure file')}
|
||||
alternative_name: v
|
||||
choices:
|
||||
- '1.0'
|
||||
- '1.1'
|
||||
mandatory: false
|
||||
|
||||
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")}
|
||||
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 %}}
|
||||
disabled:
|
||||
jinja: |
|
||||
{{% if not modes_level %}}
|
||||
No mode
|
||||
{{% endif %}}
|
||||
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:
|
||||
jinja: |
|
||||
{{% if modes_level %}}
|
||||
{{% if modes_level | length == 1 %}}
|
||||
{{{{ modes_level[0] }}}}
|
||||
{{% else %}}
|
||||
{{{{ modes_level[1] }}}}
|
||||
{{% endif %}}
|
||||
{{% endif %}}
|
||||
disabled:
|
||||
jinja: |
|
||||
{{% if not modes_level %}}
|
||||
No mode
|
||||
{{% endif %}}
|
||||
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
|
||||
|
||||
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:
|
||||
|
||||
pattern:
|
||||
description: {_("The secret pattern to build item name in Bitwarden")}
|
||||
help: {_("The pattern is in Jinja format")}
|
||||
default: "{{{{ project }}}} - {{{{ environment }}}} - {{{{ service }}}} - {{{{ user }}}}"
|
||||
|
||||
"""
|
||||
processes = {
|
||||
"structural": [],
|
||||
"user data": [],
|
||||
"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 = _(process_name)
|
||||
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 += """ commandline: false
|
||||
multi: true
|
||||
default:
|
||||
- directory
|
||||
"""
|
||||
hidden_outputs = [
|
||||
process["name"]
|
||||
for process in processes["output"]
|
||||
if 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 is not propertyerror and _.output == 'NAME' %}
|
||||
Cannot load structural for NAME output
|
||||
{% endif %}
|
||||
""".replace(
|
||||
"NAME", hidden_output
|
||||
)
|
||||
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
|
||||
)
|
||||
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, params in get_convert_option_types():
|
||||
rougail_process += f"""
|
||||
{typ}:
|
||||
"""
|
||||
for key, key_type, multi, value in params:
|
||||
rougail_process += f"""
|
||||
{key}:
|
||||
type: {key_type}
|
||||
multi: {multi}
|
||||
mandatory: false
|
||||
default: {value}
|
||||
"""
|
||||
# print(rougail_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),
|
||||
)
|
||||
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.config.{obj["name"]}',
|
||||
"",
|
||||
"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()
|
||||
File diff suppressed because it is too large
Load diff
68
src/rougail/convert/__init__.py
Normal file
68
src/rougail/convert/__init__.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
"""Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 Optional
|
||||
from tiramisu import Config
|
||||
from warnings import warn
|
||||
|
||||
from .convert import RougailConvert
|
||||
from ..config import RougailConfig
|
||||
from ..user_datas import UserDatas
|
||||
from ..tiramisu import tiramisu_display_name
|
||||
|
||||
|
||||
class Rougail(UserDatas):
|
||||
"""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 get_root_option(self):
|
||||
tiram_obj = self.converted.save()
|
||||
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()
|
||||
1172
src/rougail/convert/convert.py
Normal file
1172
src/rougail/convert/convert.py
Normal file
File diff suppressed because it is too large
Load diff
1097
src/rougail/convert/object_model.py
Normal file
1097
src/rougail/convert/object_model.py
Normal file
File diff suppressed because it is too large
Load diff
242
src/rougail/convert/path.py
Normal file
242
src/rougail/convert/path.py
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
"""
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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,
|
||||
path: str,
|
||||
data: Any,
|
||||
is_dynamic: bool,
|
||||
dynamic: str,
|
||||
*,
|
||||
force: bool = False,
|
||||
) -> None:
|
||||
self._data[path] = data
|
||||
if not force and is_dynamic:
|
||||
self._dynamics[path] = 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
|
||||
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 = _(
|
||||
'A variable or a family located in the "{0}" namespace shall not be used in the "{1}" namespace'
|
||||
).format(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()
|
||||
568
src/rougail/convert/tiramisureflector.py
Normal file
568
src/rougail/convert/tiramisureflector.py
Normal file
|
|
@ -0,0 +1,568 @@
|
|||
"""loader
|
||||
flattened XML specific
|
||||
|
||||
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-2025
|
||||
|
||||
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 Optional, Union
|
||||
from json import dumps
|
||||
from os.path import isfile, basename
|
||||
|
||||
from ..i18n import _
|
||||
from ..error import DictConsistencyError, VariableCalculationDependencyError
|
||||
from ..tiramisu import normalize_family, CONVERT_OPTION
|
||||
from .object_model import Calculation
|
||||
|
||||
|
||||
class BaseElt: # pylint: disable=R0903
|
||||
"""Base element"""
|
||||
|
||||
path = "."
|
||||
type = "family"
|
||||
|
||||
|
||||
def sorted_func_name(func_name):
|
||||
s_func_name = func_name.split("/")
|
||||
s_func_name.reverse()
|
||||
return "/".join(s_func_name)
|
||||
|
||||
|
||||
class TiramisuReflector:
|
||||
"""Convert object to tiramisu representation"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
objectspace,
|
||||
funcs_paths,
|
||||
):
|
||||
self.informations_idx = -1
|
||||
self.reflector_objects = {}
|
||||
self.text = {
|
||||
"header": [],
|
||||
"option": [],
|
||||
}
|
||||
self.objectspace = objectspace
|
||||
if self.objectspace.export_with_import:
|
||||
if self.objectspace.internal_functions:
|
||||
for func in self.objectspace.internal_functions:
|
||||
self.text["header"].append(f"func[func] = func")
|
||||
self.text["header"].extend(
|
||||
[
|
||||
"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",
|
||||
]
|
||||
)
|
||||
if funcs_paths:
|
||||
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
||||
if not isfile(funcs_path):
|
||||
continue
|
||||
self.text["header"].append(f"load_functions('{funcs_path}')")
|
||||
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:
|
||||
self.text["header"].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")')
|
||||
self.make_tiramisu_objects()
|
||||
for key, value in self.objectspace.jinja.items():
|
||||
self.add_jinja_to_function(key, value)
|
||||
|
||||
def add_jinja_to_function(
|
||||
self,
|
||||
variable_name: str,
|
||||
jinja: str,
|
||||
) -> None:
|
||||
jinja_text = dumps(jinja, ensure_ascii=False)
|
||||
self.text["header"].append(f"dict_env['{variable_name}'] = {jinja_text}")
|
||||
|
||||
def make_tiramisu_objects(self) -> None:
|
||||
"""make tiramisu objects"""
|
||||
baseelt = BaseElt()
|
||||
self.objectspace.reflector_names[baseelt.path] = (
|
||||
f"option_0{self.objectspace.suffix}"
|
||||
)
|
||||
basefamily = Family(
|
||||
baseelt,
|
||||
self,
|
||||
)
|
||||
for elt in self.objectspace.paths.get():
|
||||
if elt.path in self.objectspace.families:
|
||||
Family(
|
||||
elt,
|
||||
self,
|
||||
)
|
||||
else:
|
||||
Variable(
|
||||
elt,
|
||||
self,
|
||||
)
|
||||
baseelt.name = normalize_family(self.objectspace.base_option_name)
|
||||
baseelt.description = self.objectspace.base_option_name
|
||||
self.reflector_objects[baseelt.path].get(
|
||||
[], baseelt.description
|
||||
) # pylint: disable=E1101
|
||||
|
||||
def set_name(
|
||||
self,
|
||||
elt,
|
||||
):
|
||||
"""Set name"""
|
||||
if elt.path not in self.objectspace.reflector_names:
|
||||
self.objectspace.set_name(elt, "optiondescription_")
|
||||
return self.objectspace.reflector_names[elt.path]
|
||||
|
||||
def get_information_name(self):
|
||||
self.informations_idx += 1
|
||||
return f"information_{self.informations_idx}"
|
||||
|
||||
def get_text(self):
|
||||
"""Get text"""
|
||||
return "\n".join(self.text["header"] + self.text["option"])
|
||||
|
||||
|
||||
class Common:
|
||||
"""Common function for variable and family"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
self.objectspace = tiramisu.objectspace
|
||||
self.elt = elt
|
||||
self.option_name = None
|
||||
self.tiramisu = tiramisu
|
||||
tiramisu.reflector_objects[elt.path] = self
|
||||
self.object_type = None
|
||||
self.informations = []
|
||||
|
||||
def get(self, calls, parent_name):
|
||||
"""Get tiramisu's object"""
|
||||
if self.elt.path in calls:
|
||||
msg = f'"{self.elt.path}" will make an infinite loop'
|
||||
raise DictConsistencyError(msg, 80, self.elt.xmlfiles)
|
||||
self_calls = calls.copy()
|
||||
self_calls.append(self.elt.path)
|
||||
self.calls = self_calls
|
||||
if self.option_name is None:
|
||||
self.option_name = self.objectspace.reflector_names[self.elt.path]
|
||||
self.populate_attrib()
|
||||
if self.informations:
|
||||
for information in self.informations:
|
||||
self.tiramisu.text["option"].append(
|
||||
f"{information}.set_option({self.option_name})"
|
||||
)
|
||||
return self.option_name
|
||||
|
||||
def populate_attrib(self):
|
||||
"""Populate attributes"""
|
||||
keys = {"name": self.convert_str(self.elt.name)}
|
||||
if hasattr(self.elt, "description") and self.elt.description:
|
||||
keys["doc"] = self.convert_str(self.elt.description)
|
||||
self._populate_attrib(keys)
|
||||
if self.elt.path in self.objectspace.properties:
|
||||
keys["properties"] = self.properties_to_string(
|
||||
self.objectspace.properties[self.elt.path]
|
||||
)
|
||||
self.populate_informations(keys)
|
||||
attrib = ", ".join([f"{key}={value}" for key, value in keys.items()])
|
||||
self.tiramisu.text["option"].append(
|
||||
f"{self.option_name} = {self.object_type}({attrib})"
|
||||
)
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: dict,
|
||||
) -> None: # pragma: no cover
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
def convert_str(value):
|
||||
"""convert string"""
|
||||
if value is None:
|
||||
return "None"
|
||||
return dumps(value, ensure_ascii=False)
|
||||
|
||||
def properties_to_string(
|
||||
self,
|
||||
values: list,
|
||||
) -> None:
|
||||
"""Change properties to string"""
|
||||
properties = []
|
||||
calc_properties = []
|
||||
for property_, value in values.items():
|
||||
if not isinstance(value, list):
|
||||
value = [value]
|
||||
for val in value:
|
||||
ret = self.calculation_property(val)
|
||||
if isinstance(ret, bool):
|
||||
if ret:
|
||||
properties.append(self.convert_str(property_))
|
||||
elif ret is not None:
|
||||
calc_properties.append(ret)
|
||||
if properties or calc_properties:
|
||||
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(
|
||||
self,
|
||||
prop,
|
||||
calculation,
|
||||
) -> str:
|
||||
"""Populate properties"""
|
||||
option_name = self.tiramisu.reflector_objects[child.source.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
kwargs = (
|
||||
f"'condition': ParamOption({option_name}, notraisepropertyerror=True), "
|
||||
f"'expected': {self.populate_param(child.expected)}"
|
||||
)
|
||||
if child.inverse:
|
||||
kwargs += ", 'reverse_condition': ParamValue(True)"
|
||||
return (
|
||||
f"Calculation(func['calc_value'], Params(ParamValue('{child.name}'), "
|
||||
f"kwargs={{{kwargs}}}), func['calc_value_property_help'])"
|
||||
)
|
||||
|
||||
def populate_informations(self, keys):
|
||||
"""Populate Tiramisu's informations"""
|
||||
informations = self.objectspace.informations.get(self.elt.path)
|
||||
if not informations:
|
||||
return
|
||||
keys["informations"] = informations
|
||||
|
||||
def populate_param(
|
||||
self,
|
||||
param,
|
||||
):
|
||||
"""Populate variable parameters"""
|
||||
if not isinstance(param, dict):
|
||||
param = {
|
||||
"type": "any",
|
||||
"value": param,
|
||||
}
|
||||
if param["type"] == "value":
|
||||
return f"ParamValue({param['value']})"
|
||||
if param["type"] == "information":
|
||||
return self.build_information_param(param)
|
||||
if param["type"] == "identifier":
|
||||
if "identifier" in param and param["identifier"] != None:
|
||||
return f"ParamIdentifier(identifier_index={param['identifier']})"
|
||||
return "ParamIdentifier()"
|
||||
if param["type"] == "index":
|
||||
return "ParamIndex()"
|
||||
if param["type"] == "variable":
|
||||
return self.build_variable_param(param)
|
||||
if param["type"] == "any":
|
||||
if isinstance(param["value"], str):
|
||||
value = self.convert_str(param["value"])
|
||||
else:
|
||||
value = str(param["value"])
|
||||
return "ParamValue(" + value + ")"
|
||||
raise Exception("pfff")
|
||||
|
||||
def build_information_param(self, param: dict) -> str:
|
||||
# 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,
|
||||
param: dict,
|
||||
) -> str:
|
||||
"""build variable parameters"""
|
||||
variable = param["variable"]
|
||||
whole = param.get("whole", False)
|
||||
if variable.path == self.elt.path:
|
||||
return f"ParamSelfOption(whole={whole})"
|
||||
if whole:
|
||||
msg = f'variable param "{variable.path}" has whole attribute but it\'s not allowed for external variable'
|
||||
raise DictConsistencyError(msg, 34, self.elt.xmlfiles)
|
||||
option_name = self.tiramisu.reflector_objects[variable.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
params = [f"{option_name}"]
|
||||
identifier = param.get("identifier")
|
||||
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"
|
||||
identifiers = []
|
||||
for ident in identifier:
|
||||
if isinstance(ident, str):
|
||||
ident = self.convert_str(ident)
|
||||
identifiers.append(str(ident))
|
||||
params.append("[" + ", ".join(identifiers) + "]")
|
||||
if param.get("optional", False):
|
||||
params.append("optional=True")
|
||||
else:
|
||||
param_type = "ParamOption"
|
||||
if not param.get("propertyerror", True):
|
||||
params.append("notraisepropertyerror=True")
|
||||
return f'{param_type}({", ".join(params)})'
|
||||
|
||||
def calculation_value(
|
||||
self,
|
||||
function,
|
||||
) -> str:
|
||||
"""Generate calculated value"""
|
||||
child = function.to_function(self.objectspace)
|
||||
if isinstance(child, str):
|
||||
return self.convert_str(child)
|
||||
elif not isinstance(child, dict):
|
||||
return child
|
||||
new_args = []
|
||||
kwargs = []
|
||||
if "params" in child:
|
||||
for key, value in child["params"].items():
|
||||
if key is None:
|
||||
for val in value:
|
||||
new_args.append(self.populate_param(val))
|
||||
else:
|
||||
kwargs.append(f"'{key}': " + self.populate_param(value))
|
||||
ret = (
|
||||
f"Calculation(func['{child['function']}'], Params(("
|
||||
+ ", ".join(new_args)
|
||||
+ ")"
|
||||
)
|
||||
if kwargs:
|
||||
ret += ", kwargs={" + ", ".join(kwargs) + "}"
|
||||
ret += ")"
|
||||
if "warnings_only" in child:
|
||||
ret += f", warnings_only={child['warnings_only']}"
|
||||
if "help" in child:
|
||||
ret += f", help_function=func['{child['help']}']"
|
||||
ret = ret + ")"
|
||||
return ret
|
||||
|
||||
def populate_calculation(
|
||||
self,
|
||||
datas: Union[Calculation, str, list],
|
||||
return_a_tuple: bool = False,
|
||||
) -> str:
|
||||
if isinstance(datas, Calculation):
|
||||
datas = self.calculation_value(datas)
|
||||
elif isinstance(datas, str):
|
||||
datas = self.convert_str(datas)
|
||||
if not isinstance(datas, list):
|
||||
return datas
|
||||
params = []
|
||||
for idx, data in enumerate(datas):
|
||||
if isinstance(data, Calculation):
|
||||
try:
|
||||
params.append(self.calculation_value(data))
|
||||
except VariableCalculationDependencyError:
|
||||
continue
|
||||
elif isinstance(data, str):
|
||||
params.append(self.convert_str(data))
|
||||
elif isinstance(data, dict):
|
||||
params.append(data)
|
||||
else:
|
||||
params.append(str(data))
|
||||
if return_a_tuple:
|
||||
ret = "("
|
||||
else:
|
||||
ret = "["
|
||||
ret += ", ".join(params)
|
||||
if return_a_tuple:
|
||||
if len(params) <= 1:
|
||||
ret += ","
|
||||
ret += ")"
|
||||
else:
|
||||
ret += "]"
|
||||
return ret
|
||||
|
||||
|
||||
class Variable(Common):
|
||||
"""Manage variable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
super().__init__(elt, tiramisu)
|
||||
if elt.type in self.tiramisu.objectspace.custom_types:
|
||||
self.object_type = self.tiramisu.objectspace.custom_types[elt.type].__name__
|
||||
else:
|
||||
self.object_type = CONVERT_OPTION[elt.type]["opttype"]
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: dict,
|
||||
):
|
||||
if self.elt.type == "symlink":
|
||||
keys["opt"] = self.tiramisu.reflector_objects[self.elt.opt.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
return
|
||||
if self.elt.type == "choice":
|
||||
try:
|
||||
keys["values"] = self.populate_calculation(
|
||||
self.elt.choices, return_a_tuple=True
|
||||
)
|
||||
if keys["values"] == "(,)":
|
||||
keys["values"] = tuple()
|
||||
except VariableCalculationDependencyError:
|
||||
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()
|
||||
_type = 'value'
|
||||
{self.object_type}._regexp = re_compile(r"{self.elt.regexp}")
|
||||
"""
|
||||
)
|
||||
if self.elt.path in self.objectspace.multis:
|
||||
keys["multi"] = self.objectspace.multis[self.elt.path]
|
||||
if hasattr(self.elt, "default") and self.elt.default is not None:
|
||||
try:
|
||||
keys["default"] = self.populate_calculation(self.elt.default)
|
||||
except VariableCalculationDependencyError:
|
||||
pass
|
||||
if self.elt.path in self.objectspace.default_multi:
|
||||
try:
|
||||
keys["default_multi"] = self.populate_calculation(
|
||||
self.objectspace.default_multi[self.elt.path]
|
||||
)
|
||||
except VariableCalculationDependencyError:
|
||||
pass
|
||||
if self.elt.validators:
|
||||
keys["validators"] = self.populate_calculation(self.elt.validators)
|
||||
if self.elt.warnings:
|
||||
keys["warnings_only"] = True
|
||||
for key, value in (
|
||||
CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items()
|
||||
):
|
||||
if isinstance(value, str):
|
||||
value = self.convert_str(value)
|
||||
keys[key] = value
|
||||
if self.elt.params:
|
||||
for param in self.elt.params:
|
||||
value = param.value
|
||||
if isinstance(value, str):
|
||||
value = self.convert_str(value)
|
||||
keys[param.key] = value
|
||||
|
||||
|
||||
class Family(Common):
|
||||
"""Manage family"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
super().__init__(elt, tiramisu)
|
||||
if self.elt.type == "dynamic":
|
||||
self.tiramisu.objectspace.has_dyn_option = True
|
||||
self.object_type = "ConvertDynOptionDescription"
|
||||
elif self.elt.type == "leadership":
|
||||
self.object_type = "Leadership"
|
||||
else:
|
||||
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 = []
|
||||
|
||||
def add(self, child):
|
||||
"""Add a child"""
|
||||
self.children.append(child)
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: list,
|
||||
) -> None:
|
||||
if self.group_type:
|
||||
keys["group_type"] = self.group_type
|
||||
if self.elt.type == "dynamic":
|
||||
try:
|
||||
keys["identifiers"] = self.populate_calculation(self.elt.dynamic)
|
||||
except VariableCalculationDependencyError:
|
||||
keys["identifiers"] = []
|
||||
children = []
|
||||
for path in self.objectspace.parents[self.elt.path]:
|
||||
children.append(self.objectspace.paths[path])
|
||||
keys["children"] = (
|
||||
"["
|
||||
+ ", ".join(
|
||||
[
|
||||
self.tiramisu.reflector_objects[child.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
for child in children
|
||||
]
|
||||
)
|
||||
+ "]"
|
||||
)
|
||||
|
|
@ -9,32 +9,24 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 .i18n import _
|
||||
|
||||
|
||||
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] + '"'
|
||||
from .tiramisu import display_xmlfiles
|
||||
|
||||
|
||||
class ConfigError(Exception):
|
||||
|
|
@ -66,16 +58,29 @@ class DictConsistencyError(Exception):
|
|||
|
||||
def __init__(self, msg, errno, xmlfiles):
|
||||
if xmlfiles:
|
||||
msg = _(f"{msg} in {display_xmlfiles(xmlfiles)}")
|
||||
msg = _("{0} in {1}").format(msg, display_xmlfiles(xmlfiles))
|
||||
super().__init__(msg)
|
||||
self.errno = errno
|
||||
|
||||
|
||||
class UpgradeError(Exception):
|
||||
"""Error during XML upgrade"""
|
||||
|
||||
## ---- generic exceptions ----
|
||||
|
||||
|
||||
class NotFoundError(Exception):
|
||||
"not found error"
|
||||
pass
|
||||
|
||||
|
||||
class ExtensionError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class RougailWarning(UserWarning):
|
||||
pass
|
||||
|
||||
|
||||
## ---- specific exceptions ----
|
||||
|
||||
|
||||
class VariableCalculationDependencyError(Exception):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -8,53 +8,25 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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 gettext
|
||||
import os
|
||||
import sys
|
||||
import locale
|
||||
|
||||
# Application Name
|
||||
APP_NAME = "rougail"
|
||||
from gettext import translation
|
||||
from pathlib import Path
|
||||
|
||||
# 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 = translation("rougail", str(Path(__file__).parent / "locale"), fallback=True)
|
||||
|
||||
_ = t.gettext
|
||||
|
|
|
|||
BIN
src/rougail/locale/fr/LC_MESSAGES/rougail.mo
Normal file
BIN
src/rougail/locale/fr/LC_MESSAGES/rougail.mo
Normal file
Binary file not shown.
|
|
@ -1,532 +0,0 @@
|
|||
"""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 .utils import get_jinja_variable_to_param, get_realpath
|
||||
from .error import DictConsistencyError
|
||||
|
||||
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"),
|
||||
"number": dict(opttype="IntOption", func=int),
|
||||
"float": dict(opttype="FloatOption", func=float),
|
||||
"boolean": dict(opttype="BoolOption", func=convert_boolean),
|
||||
"secret": dict(opttype="PasswordOption"),
|
||||
"mail": dict(opttype="EmailOption"),
|
||||
"unix_filename": dict(opttype="FilenameOption"),
|
||||
"date": dict(opttype="DateOption"),
|
||||
"unix_user": dict(opttype="UsernameOption"),
|
||||
"ip": dict(opttype="IPOption", initkwargs={"allow_reserved": True}),
|
||||
"cidr": dict(opttype="IPOption", initkwargs={"cidr": True}),
|
||||
"netmask": dict(opttype="NetmaskOption"),
|
||||
"network": dict(opttype="NetworkOption"),
|
||||
"network_cidr": dict(opttype="NetworkOption", initkwargs={"cidr": True}),
|
||||
"broadcast": dict(opttype="BroadcastOption"),
|
||||
"netbios": dict(
|
||||
opttype="DomainnameOption",
|
||||
initkwargs={"type": "netbios", "warnings_only": True},
|
||||
),
|
||||
"domainname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "domainname", "allow_ip": False}
|
||||
),
|
||||
"hostname": dict(
|
||||
opttype="DomainnameOption", initkwargs={"type": "hostname", "allow_ip": False}
|
||||
),
|
||||
"web_address": dict(
|
||||
opttype="URLOption", initkwargs={"allow_ip": False, "allow_without_dot": True}
|
||||
),
|
||||
"port": dict(opttype="PortOption", initkwargs={"allow_private": True}),
|
||||
"mac": dict(opttype="MACOption"),
|
||||
"unix_permissions": dict(
|
||||
opttype="PermissionsOption", initkwargs={"warnings_only": True}, func=int
|
||||
),
|
||||
"choice": dict(opttype="ChoiceOption"),
|
||||
#
|
||||
"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: BASETYPE
|
||||
|
||||
|
||||
class VariableParam(Param):
|
||||
type: str
|
||||
variable: str
|
||||
propertyerror: bool = True
|
||||
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
|
||||
namespace: 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":
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
param["variable"], self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
||||
)
|
||||
if not variable:
|
||||
if not param.get("optional"):
|
||||
raise Exception(f"cannot find {param['variable']}")
|
||||
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"]:
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
param["variable"], self.path_prefix, self.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", "disabled", "default", "validators", "choices", "dynamic"
|
||||
]
|
||||
jinja: StrictStr
|
||||
params: Optional[List[Param]] = None
|
||||
return_type: BASETYPE = 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,
|
||||
},
|
||||
}
|
||||
if add_help:
|
||||
default["help"] = function + "_help"
|
||||
if self.params:
|
||||
default["params"] |= self.get_params(objectspace)
|
||||
if params:
|
||||
default["params"] |= params
|
||||
for sub_variable, suffix, true_path in get_jinja_variable_to_param(
|
||||
self.path,
|
||||
self.jinja,
|
||||
objectspace,
|
||||
variable.xmlfiles,
|
||||
objectspace.functions,
|
||||
self.path_prefix,
|
||||
self.version,
|
||||
self.namespace,
|
||||
):
|
||||
if sub_variable.path in objectspace.variables:
|
||||
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]},
|
||||
)
|
||||
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):
|
||||
attribute_name: Literal[
|
||||
"frozen", "hidden", "mandatory", "disabled", "default", "choices", "dynamic"
|
||||
]
|
||||
variable: StrictStr
|
||||
propertyerror: bool = True
|
||||
allow_none: bool = False
|
||||
|
||||
def to_function(
|
||||
self,
|
||||
objectspace,
|
||||
) -> dict:
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
self.variable, self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
||||
)
|
||||
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)
|
||||
if not isinstance(variable, objectspace.variable):
|
||||
# FIXME remove the pfff
|
||||
raise Exception("pfff it's a family")
|
||||
param = {
|
||||
"type": "variable",
|
||||
"variable": variable,
|
||||
"propertyerror": self.propertyerror,
|
||||
}
|
||||
if suffix:
|
||||
param["suffix"] = suffix
|
||||
params = {None: [param]}
|
||||
function = "calc_value"
|
||||
help_function = None
|
||||
if self.attribute_name in PROPERTY_ATTRIBUTE:
|
||||
function = "variable_to_property"
|
||||
help_function = "variable_to_property"
|
||||
if variable.type != "boolean":
|
||||
raise Exception("only boolean!")
|
||||
params[None].insert(0, self.attribute_name)
|
||||
if self.allow_none:
|
||||
params["allow_none"] = True
|
||||
# current variable is a multi
|
||||
if self.attribute_name in PROPERTY_ATTRIBUTE:
|
||||
needs_multi = False
|
||||
elif self.attribute_name != "default":
|
||||
needs_multi = True
|
||||
else:
|
||||
needs_multi = self.path in objectspace.multis
|
||||
calc_variable_is_multi = variable.path in objectspace.multis or (variable.path in objectspace.paths._dynamics and (suffix is None or suffix[-1] is None) and objectspace.paths._dynamics[variable.path] != objectspace.paths._dynamics.get(self.path))
|
||||
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:
|
||||
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)
|
||||
ret = {
|
||||
"function": function,
|
||||
"params": params,
|
||||
}
|
||||
if help_function:
|
||||
ret["help"] = help_function
|
||||
return ret
|
||||
|
||||
|
||||
class InformationCalculation(Calculation):
|
||||
attribute_name: Literal["default", "choice", "dynamic"]
|
||||
information: StrictStr
|
||||
variable: Optional[StrictStr]
|
||||
|
||||
def to_function(
|
||||
self,
|
||||
objectspace,
|
||||
) -> dict:
|
||||
param = {
|
||||
"type": "information",
|
||||
"information": self.information,
|
||||
}
|
||||
if self.variable:
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
self.variable, self.path_prefix, self.path, self.version, self.namespace, self.xmlfiles
|
||||
)
|
||||
if variable is None or suffix is not None:
|
||||
raise Exception("pfff")
|
||||
param["variable"] = variable
|
||||
return {
|
||||
"function": "calc_value",
|
||||
"params": {None: [param]},
|
||||
}
|
||||
|
||||
|
||||
class SuffixCalculation(Calculation):
|
||||
attribute_name: Literal["default", "choice", "dynamic"]
|
||||
suffix: Optional[int] = None
|
||||
|
||||
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: [suffix]},
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
}
|
||||
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]
|
||||
xmlfiles: List[str] = []
|
||||
|
||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||
|
||||
|
||||
class Dynamic(Family):
|
||||
variable: str=None
|
||||
# None only for format 1.0
|
||||
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
|
||||
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
|
||||
auto_save: bool = False
|
||||
mode: Optional[str] = None
|
||||
test: Optional[list] = None
|
||||
path: str
|
||||
namespace: str
|
||||
version: str
|
||||
xmlfiles: List[str] = []
|
||||
|
||||
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True)
|
||||
|
||||
|
||||
#class Choice(Variable):
|
||||
# type: Literal["choice"] = "choice"
|
||||
# choices: Union[List[BASETYPE_CALC], Calculation]
|
||||
|
||||
|
||||
class SymLink(BaseModel):
|
||||
name: str
|
||||
type: Literal["symlink"] = "symlink"
|
||||
opt: Variable
|
||||
xmlfiles: List[str] = []
|
||||
path: str
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
"""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,
|
||||
# )
|
||||
22
src/rougail/structural_commandline/__init__.py
Normal file
22
src/rougail/structural_commandline/__init__.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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")
|
||||
88
src/rougail/structural_commandline/annotator.py
Normal file
88
src/rougail/structural_commandline/annotator.py
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
"""Annotate to add specify attribute for tiramisu-cmdline
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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 rougail.annotator.variable import Walk
|
||||
from rougail.utils import _
|
||||
from rougail.error import DictConsistencyError
|
||||
|
||||
|
||||
class Annotator(Walk):
|
||||
"""Annotate value"""
|
||||
|
||||
level = 80
|
||||
|
||||
def __init__(self, objectspace, *args) -> None:
|
||||
if not objectspace.paths:
|
||||
return
|
||||
self.alternative_names = {}
|
||||
self.objectspace = objectspace
|
||||
not_for_commandlines = []
|
||||
for family in self.get_families():
|
||||
if family.commandline:
|
||||
continue
|
||||
self.not_for_commandline(family)
|
||||
not_for_commandlines.append(family.path + ".")
|
||||
for variable in self.get_variables():
|
||||
if variable.type == "symlink":
|
||||
continue
|
||||
variable_path = variable.path
|
||||
for family_path in not_for_commandlines:
|
||||
if variable_path.startswith(family_path):
|
||||
break
|
||||
else:
|
||||
if not variable.commandline:
|
||||
self.not_for_commandline(variable)
|
||||
else:
|
||||
self.manage_alternative_name(variable)
|
||||
|
||||
def not_for_commandline(self, variable) -> None:
|
||||
self.objectspace.properties.add(variable.path, "not_for_commandline", True)
|
||||
|
||||
def manage_alternative_name(self, variable) -> None:
|
||||
if not variable.alternative_name:
|
||||
return
|
||||
alternative_name = variable.alternative_name
|
||||
variable_path = variable.path
|
||||
all_letters = ""
|
||||
for letter in alternative_name:
|
||||
all_letters += letter
|
||||
if all_letters == "h":
|
||||
msg = _('alternative_name "{0}" conflict with "--help"').format(
|
||||
alternative_name
|
||||
)
|
||||
raise DictConsistencyError(msg, 202, variable.xmlfiles)
|
||||
if all_letters in self.alternative_names:
|
||||
msg = _('conflict alternative_name "{0}": "{1}" and "{2}"').format(
|
||||
alternative_name, variable_path, self.alternative_names[all_letters]
|
||||
)
|
||||
raise DictConsistencyError(msg, 202, variable.xmlfiles)
|
||||
|
||||
self.alternative_names[alternative_name] = variable_path
|
||||
if "." not in variable_path:
|
||||
path = alternative_name
|
||||
else:
|
||||
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,
|
||||
)
|
||||
43
src/rougail/structural_commandline/config.py
Normal file
43
src/rougail/structural_commandline/config.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""
|
||||
Config file for Rougail-structural_commandline
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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/>.
|
||||
"""
|
||||
|
||||
|
||||
def get_rougail_config(
|
||||
*,
|
||||
backward_compatibility=True,
|
||||
) -> dict:
|
||||
options = """
|
||||
structural_commandline:
|
||||
description: Configuration rougail-structural_commandline
|
||||
commandline: false
|
||||
|
||||
add_extra_options:
|
||||
description: Add extra options to tiramisu-cmdline-parser
|
||||
default: true
|
||||
"""
|
||||
return {
|
||||
"name": "cmdline",
|
||||
"process": "structural",
|
||||
"options": options,
|
||||
"level": 20,
|
||||
}
|
||||
|
||||
|
||||
__all__ = "get_rougail_config"
|
||||
30
src/rougail/structural_commandline/object_model.py
Normal file
30
src/rougail/structural_commandline/object_model.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""Annotate to add specify attribute for tiramisu-cmdline
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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 Optional
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Variable(BaseModel):
|
||||
alternative_name: Optional[str] = None
|
||||
commandline: bool = True
|
||||
|
||||
|
||||
class Family(BaseModel):
|
||||
commandline: bool = True
|
||||
158
src/rougail/structural_directory/__init__.py
Normal file
158
src/rougail/structural_directory/__init__.py
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 ..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
|
||||
self.sort_structural_files_all = rougailconfig["sort_structural_files_all"]
|
||||
if rougailconfig["main_namespace"]:
|
||||
self.convert.paths = Paths(
|
||||
rougailconfig["main_namespace"],
|
||||
rougailconfig["isolated_namespace"],
|
||||
)
|
||||
self.load_with_extra(
|
||||
rougailconfig["extra_namespaces"],
|
||||
rougailconfig["main_namespace"],
|
||||
rougailconfig["main_structural_directories"],
|
||||
)
|
||||
else:
|
||||
self.convert.namespace = None
|
||||
namespace_path = ""
|
||||
if namespace_path in self.convert.parents:
|
||||
raise Exception("pfff")
|
||||
for filename in self.get_sorted_filename(
|
||||
rougailconfig["main_structural_directories"]
|
||||
):
|
||||
self.parse_variable_file(
|
||||
filename,
|
||||
namespace_path,
|
||||
)
|
||||
|
||||
def load_with_extra(
|
||||
self,
|
||||
extra_structures: dict,
|
||||
main_namespace: Optional[str] = None,
|
||||
main_structures: Optional[List[str]] = None,
|
||||
) -> None:
|
||||
self.convert.has_namespace = True
|
||||
if main_namespace:
|
||||
directory_dict = chain(
|
||||
(
|
||||
(
|
||||
main_namespace,
|
||||
main_structures,
|
||||
),
|
||||
),
|
||||
extra_structures.items(),
|
||||
)
|
||||
else:
|
||||
directory_dict = extra_structures.items()
|
||||
for namespace, extra_dirs in directory_dict:
|
||||
# if namespace is None:
|
||||
# self.convert.namespace = namespace
|
||||
# else:
|
||||
self.convert.namespace = normalize_family(namespace)
|
||||
namespace_path = self.convert.namespace
|
||||
if namespace_path in self.convert.parents:
|
||||
raise Exception("pfff")
|
||||
for idx, filename in enumerate(self.get_sorted_filename(extra_dirs)):
|
||||
if not idx:
|
||||
# create only for the first file
|
||||
self.convert.create_namespace(namespace, namespace_path)
|
||||
self.parse_variable_file(
|
||||
filename,
|
||||
namespace_path,
|
||||
)
|
||||
|
||||
def get_sorted_filename(
|
||||
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:
|
||||
for filename in sorted(filenames):
|
||||
yield filenames[filename]
|
||||
if self.sort_structural_files_all:
|
||||
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,
|
||||
path: str,
|
||||
) -> None:
|
||||
"""Parse file"""
|
||||
with open(filename, encoding="utf8") as file_fh:
|
||||
objects = self.yaml.load(file_fh)
|
||||
version = self.convert.validate_file_version(
|
||||
objects,
|
||||
filename,
|
||||
)
|
||||
if objects is None:
|
||||
return
|
||||
self.convert.parse_root_file(
|
||||
filename,
|
||||
path,
|
||||
version,
|
||||
objects,
|
||||
)
|
||||
|
||||
|
||||
__all__ = ("Walker",)
|
||||
111
src/rougail/structural_directory/config.py
Normal file
111
src/rougail/structural_directory/config.py
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2024-2025
|
||||
|
||||
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_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 %}}
|
||||
|
||||
main_namespace:
|
||||
description: {_("Main namespace name")}
|
||||
default: {main_namespace_default}
|
||||
alternative_name: s
|
||||
mandatory: false
|
||||
disabled:
|
||||
jinja: >-
|
||||
{{{{ 'directory' not in _.step.structural }}}}
|
||||
return_type: boolean
|
||||
description: directory is not in _.step.structural
|
||||
|
||||
isolated_namespace:
|
||||
description: {_("Namespaces are isolated")}
|
||||
default: true
|
||||
disabled:
|
||||
jinja: >-
|
||||
{{{{ 'directory' not in _.step.structural or not _.main_namespace }}}}
|
||||
return_type: boolean
|
||||
description: directory is not in _.step.structural or main_namespace is not set
|
||||
|
||||
extra_namespaces:
|
||||
description: {_("Extra namespaces")}
|
||||
type: leadership
|
||||
disabled:
|
||||
jinja: >-
|
||||
{{{{ 'directory' 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
|
||||
types:
|
||||
- directory
|
||||
multi: true
|
||||
"""
|
||||
return {
|
||||
"name": "directory",
|
||||
"process": "structural",
|
||||
"options": options,
|
||||
"level": 5,
|
||||
}
|
||||
|
||||
|
||||
__all__ = "get_rougail_config"
|
||||
|
|
@ -9,129 +9,455 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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/>.
|
||||
"""
|
||||
try:
|
||||
from tiramisu5 import DynOptionDescription, calc_value
|
||||
except ModuleNotFoundError:
|
||||
from tiramisu import DynOptionDescription, calc_value
|
||||
|
||||
from typing import Any
|
||||
|
||||
from importlib.machinery import SourceFileLoader as _SourceFileLoader
|
||||
from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec
|
||||
from importlib.util import (
|
||||
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.sandbox import SandboxedEnvironment
|
||||
from rougail import CONVERT_OPTION
|
||||
from tiramisu.error import ValueWarning
|
||||
from .utils import normalize_family
|
||||
from re import findall
|
||||
from tiramisu import (
|
||||
DynOptionDescription,
|
||||
calc_value,
|
||||
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 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))
|
||||
|
||||
|
||||
CONVERT_OPTION = {
|
||||
"string": dict(opttype="StrOption", example="example"),
|
||||
"number": dict(opttype="IntOption", func=int, example=42),
|
||||
"integer": 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", func=str,
|
||||
),
|
||||
"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"),
|
||||
}
|
||||
RENAME_TYPE = {"number": "integer"}
|
||||
|
||||
|
||||
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)))
|
||||
|
||||
|
||||
errors.raise_carry_out_calculation_error = raise_carry_out_calculation_error
|
||||
|
||||
|
||||
global func
|
||||
func = {'calc_value': calc_value}
|
||||
dict_env = {}
|
||||
ENV = SandboxedEnvironment(loader=DictLoader(dict_env), undefined=StrictUndefined)
|
||||
ENV.filters = func
|
||||
ENV.compile_templates('jinja_caches', zip=None)
|
||||
func = ENV.filters
|
||||
ENV.compile_templates("jinja_caches", zip=None)
|
||||
|
||||
|
||||
def load_functions(path):
|
||||
class JinjaError:
|
||||
__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
|
||||
loader = _SourceFileLoader('func', path)
|
||||
if dict_func is None:
|
||||
dict_func = func
|
||||
loader = _SourceFileLoader("func", path)
|
||||
spec = _spec_from_loader(loader.name, loader)
|
||||
func_ = _module_from_spec(spec)
|
||||
loader.exec_module(func_)
|
||||
for function in dir(func_):
|
||||
if function.startswith('_'):
|
||||
if function.startswith("_"):
|
||||
continue
|
||||
func[function] = getattr(func_, function)
|
||||
dict_func[function] = getattr(func_, function)
|
||||
|
||||
|
||||
def jinja_to_function(__internal_jinja, __internal_type, __internal_multi, **kwargs):
|
||||
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 tiramisu_display_name(
|
||||
kls,
|
||||
subconfig,
|
||||
with_quote: bool = False,
|
||||
) -> str:
|
||||
"""Replace the Tiramisu display_name function to display path + description"""
|
||||
config_bag = subconfig.config_bag
|
||||
context = config_bag.context
|
||||
values = context.get_values()
|
||||
context_subconfig = context.get_root(config_bag)
|
||||
doc = values.get_information(subconfig, "doc", None)
|
||||
comment = doc if doc and doc != kls.impl_getname() else ""
|
||||
if "{{ identifier }}" in comment and subconfig.identifiers:
|
||||
comment = comment.replace("{{ identifier }}", str(subconfig.identifiers[-1]))
|
||||
path_in_description = values.get_information(
|
||||
context_subconfig, "path_in_description", True
|
||||
)
|
||||
if path_in_description or not comment:
|
||||
comment = f" ({comment})" if comment else ""
|
||||
if path_in_description is False:
|
||||
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]))
|
||||
)
|
||||
else:
|
||||
path = comment
|
||||
comment = ""
|
||||
if with_quote:
|
||||
return f'"{path}"{comment}'
|
||||
return f"{path}{comment}"
|
||||
|
||||
|
||||
def rougail_calc_value(*args, __default_value=None, __internal_multi=False, **kwargs):
|
||||
values = calc_value(*args, **kwargs)
|
||||
if values is None and __internal_multi:
|
||||
values = []
|
||||
if __default_value is not None and values in [None, []]:
|
||||
return __default_value
|
||||
return values
|
||||
|
||||
|
||||
def kw_to_string(kw, root=None):
|
||||
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
|
||||
kw = {}
|
||||
for key, value in kwargs.items():
|
||||
if '.' in key:
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
value = JinjaError(value)
|
||||
if "." in key:
|
||||
c_kw = kw
|
||||
path, var = key.rsplit('.', 1)
|
||||
for subkey in path.split('.'):
|
||||
path, var = key.rsplit(".", 1)
|
||||
if isinstance(value, CancelParam):
|
||||
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[var] = value
|
||||
if not isinstance(value, CancelParam):
|
||||
c_kw[var] = value
|
||||
else:
|
||||
if key in kw:
|
||||
raise ConfigError(
|
||||
f'internal error, multi key for "{key}" in jinja_to_function'
|
||||
)
|
||||
kw[key] = value
|
||||
values = ENV.get_template(__internal_jinja).render(kw, **func).strip()
|
||||
convert = CONVERT_OPTION[__internal_type].get('func', str)
|
||||
try:
|
||||
values = ENV.get_template(__internal_jinja).render(kw, **func).strip()
|
||||
except Exception as err:
|
||||
kw_str = ", ".join(kw_to_string(kw))
|
||||
raise ConfigError(
|
||||
_(
|
||||
'cannot calculating "{0}" attribute for variable "{1}" in {2} with parameters "{3}": {4}'
|
||||
).format(
|
||||
__internal_attribute,
|
||||
__internal_variable,
|
||||
display_xmlfiles(__internal_files),
|
||||
kw_str,
|
||||
err,
|
||||
)
|
||||
) from err
|
||||
convert = CONVERT_OPTION[__internal_type].get("func", str)
|
||||
if __internal_multi:
|
||||
return [convert(val) for val in values.split()]
|
||||
values = convert(values)
|
||||
return values if values != '' and values != 'None' else None
|
||||
values = [
|
||||
convert(val.strip()) for val in values.split("\n") if val.strip() != ""
|
||||
]
|
||||
if not values and __default_value is not None:
|
||||
return __default_value
|
||||
return values
|
||||
try:
|
||||
values = convert(values)
|
||||
except Exception as err:
|
||||
raise ConfigError(
|
||||
f'cannot converting "{__internal_attribute}" attribute for variable "{__internal_variable}" in {display_xmlfiles(__internal_files)}: {err}'
|
||||
) from err
|
||||
values = values if values != "" and values != "None" else None
|
||||
if values is None and __default_value is not None:
|
||||
return __default_value
|
||||
return values
|
||||
|
||||
|
||||
def variable_to_property(prop, value):
|
||||
return prop if value else None
|
||||
def variable_to_property(*, prop, value=undefined, when, inverse, **kwargs):
|
||||
if value is undefined:
|
||||
return None
|
||||
if isinstance(value, PropertiesOptionError):
|
||||
raise value from value
|
||||
if inverse:
|
||||
is_match = value != when
|
||||
else:
|
||||
is_match = value == when
|
||||
return prop if is_match else None
|
||||
|
||||
|
||||
def jinja_to_property(prop, **kwargs):
|
||||
value = func['jinja_to_function'](**kwargs)
|
||||
return func['variable_to_property'](prop, value is not None)
|
||||
@function_waiting_for_error
|
||||
def jinja_to_property(prop, description, when, inverse, **kwargs):
|
||||
value = func["jinja_to_function"](**kwargs)
|
||||
if kwargs["__internal_type"] == "string":
|
||||
value = value is not None
|
||||
return func["variable_to_property"](
|
||||
prop=prop, value=value, when=when, inverse=inverse
|
||||
)
|
||||
|
||||
|
||||
def jinja_to_property_help(prop, **kwargs):
|
||||
value = func['jinja_to_function'](**kwargs)
|
||||
return (prop, f'\"{prop}\" ({value})')
|
||||
@function_waiting_for_error
|
||||
def jinja_to_property_help(prop, description, **kwargs):
|
||||
if kwargs["__internal_type"] == "string":
|
||||
description = func["jinja_to_function"](**kwargs)
|
||||
return (prop, f'"{prop}" ({description})')
|
||||
|
||||
|
||||
def valid_with_jinja(warnings_only=False, **kwargs):
|
||||
@function_waiting_for_error
|
||||
def valid_with_jinja(warnings_only=False, description=None, **kwargs):
|
||||
global ValueWarning
|
||||
value = func['jinja_to_function'](**kwargs)
|
||||
value = func["jinja_to_function"](**kwargs)
|
||||
if value:
|
||||
if warnings_only:
|
||||
raise ValueWarning(value)
|
||||
else:
|
||||
raise ValueError(value)
|
||||
if description is None:
|
||||
description = value
|
||||
if warnings_only:
|
||||
raise ValueWarning(description)
|
||||
else:
|
||||
raise ValueError(description)
|
||||
|
||||
|
||||
func['jinja_to_function'] = jinja_to_function
|
||||
func['jinja_to_property'] = jinja_to_property
|
||||
func['jinja_to_property_help'] = jinja_to_property_help
|
||||
func['variable_to_property'] = variable_to_property
|
||||
func['valid_with_jinja'] = valid_with_jinja
|
||||
func["calc_value"] = rougail_calc_value
|
||||
func["jinja_to_function"] = jinja_to_function
|
||||
func["jinja_to_property"] = jinja_to_property
|
||||
func["jinja_to_property_help"] = jinja_to_property_help
|
||||
func["variable_to_property"] = variable_to_property
|
||||
func["valid_with_jinja"] = valid_with_jinja
|
||||
func["normalize_family"] = normalize_family
|
||||
|
||||
|
||||
class ConvertDynOptionDescription(DynOptionDescription):
|
||||
"""Suffix could be an integer, we should convert it in str
|
||||
Suffix could also contain invalid character, so we should "normalize" it
|
||||
"""Identifier could be an integer, we should convert it in str
|
||||
Identifier could also contain invalid character, so we should "normalize" it
|
||||
"""
|
||||
|
||||
def convert_suffix_to_path(self, suffix):
|
||||
if suffix is None:
|
||||
return suffix
|
||||
if not isinstance(suffix, str):
|
||||
suffix = str(suffix)
|
||||
return normalize_family(suffix)
|
||||
@staticmethod
|
||||
def convert_identifier_to_path(identifier):
|
||||
if identifier is None:
|
||||
return identifier
|
||||
if not isinstance(identifier, str):
|
||||
identifier = str(identifier)
|
||||
return normalize_family(identifier)
|
||||
|
||||
def impl_getname(
|
||||
self,
|
||||
suffix=None,
|
||||
identifier=None,
|
||||
) -> str:
|
||||
"""get name"""
|
||||
name = super().impl_getname(None)
|
||||
if suffix is None:
|
||||
if identifier is None:
|
||||
return name
|
||||
path_suffix = self.convert_suffix_to_path(suffix)
|
||||
if "{{ suffix }}" in name:
|
||||
return name.replace("{{ suffix }}", path_suffix)
|
||||
return name + path_suffix
|
||||
path_identifier = self.convert_identifier_to_path(identifier)
|
||||
if "{{ identifier }}" in name:
|
||||
return name.replace("{{ identifier }}", path_identifier)
|
||||
return name + path_identifier
|
||||
|
||||
def impl_get_display_name(
|
||||
self,
|
||||
subconfig,
|
||||
with_quote: bool = False,
|
||||
) -> str:
|
||||
display = super().impl_get_display_name(subconfig, with_quote=with_quote)
|
||||
if "{{ identifier }}" in display:
|
||||
return display.replace(
|
||||
"{{ identifier }}",
|
||||
self.convert_identifier_to_path(
|
||||
self.get_identifiers(subconfig, from_display_name=True)[-1]
|
||||
),
|
||||
)
|
||||
return display
|
||||
|
||||
def name_could_conflict(self, dynchild, child):
|
||||
return (
|
||||
get_identifier_from_dynamic_family(
|
||||
dynchild.impl_getname(), child.impl_getname()
|
||||
)
|
||||
is not None
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,510 +0,0 @@
|
|||
"""loader
|
||||
flattened XML specific
|
||||
|
||||
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 typing import Optional, Union
|
||||
from json import dumps
|
||||
from os.path import isfile, basename
|
||||
|
||||
from .i18n import _
|
||||
from .error import DictConsistencyError
|
||||
from .utils import normalize_family
|
||||
from .object_model import Calculation, CONVERT_OPTION
|
||||
|
||||
|
||||
class BaseElt: # pylint: disable=R0903
|
||||
"""Base element"""
|
||||
|
||||
path = "."
|
||||
type = "family"
|
||||
|
||||
|
||||
def sorted_func_name(func_name):
|
||||
s_func_name = func_name.split("/")
|
||||
s_func_name.reverse()
|
||||
return "/".join(s_func_name)
|
||||
|
||||
|
||||
class TiramisuReflector:
|
||||
"""Convert object to tiramisu representation"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
objectspace,
|
||||
funcs_paths,
|
||||
):
|
||||
self.informations_idx = -1
|
||||
self.rougailconfig = objectspace.rougailconfig
|
||||
self.reflector_objects = {}
|
||||
self.text = {
|
||||
"header": [],
|
||||
"option": [],
|
||||
}
|
||||
if self.rougailconfig["export_with_import"]:
|
||||
if self.rougailconfig["internal_functions"]:
|
||||
for func in self.rougailconfig["internal_functions"]:
|
||||
self.text["header"].append(f"func[func] = func")
|
||||
self.text["header"].extend(
|
||||
[
|
||||
"from tiramisu import *",
|
||||
"from tiramisu.setting import ALLOWED_LEADER_PROPERTIES",
|
||||
]
|
||||
)
|
||||
if funcs_paths:
|
||||
if self.rougailconfig["export_with_import"]:
|
||||
self.text["header"].extend(
|
||||
["from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription"]
|
||||
)
|
||||
for funcs_path in sorted(funcs_paths, key=sorted_func_name):
|
||||
if not isfile(funcs_path):
|
||||
continue
|
||||
self.text["header"].append(f"load_functions('{funcs_path}')")
|
||||
if self.rougailconfig["export_with_import"]:
|
||||
for mode in self.rougailconfig["modes_level"]:
|
||||
self.text["header"].append(f'ALLOWED_LEADER_PROPERTIES.add("{mode}")')
|
||||
self.objectspace = objectspace
|
||||
self.make_tiramisu_objects()
|
||||
for key, value in self.objectspace.jinja.items():
|
||||
self.add_jinja_to_function(key, value)
|
||||
|
||||
def add_jinja_to_function(
|
||||
self,
|
||||
variable_name: str,
|
||||
jinja: str,
|
||||
) -> None:
|
||||
jinja_text = dumps(jinja, ensure_ascii=False)
|
||||
self.text["header"].append(f"dict_env['{variable_name}'] = {jinja_text}")
|
||||
|
||||
def make_tiramisu_objects(self) -> None:
|
||||
"""make tiramisu objects"""
|
||||
baseelt = BaseElt()
|
||||
self.objectspace.reflector_names[
|
||||
baseelt.path
|
||||
] = f'option_0{self.rougailconfig["suffix"]}'
|
||||
basefamily = Family(
|
||||
baseelt,
|
||||
self,
|
||||
)
|
||||
# FIXMEif not self.objectspace.paths.has_path_prefix():
|
||||
if 1:
|
||||
# for elt in self.reorder_family(self.objectspace.space):
|
||||
for elt in self.objectspace.paths.get():
|
||||
if elt.path in self.objectspace.families:
|
||||
Family(
|
||||
elt,
|
||||
self,
|
||||
)
|
||||
else:
|
||||
Variable(
|
||||
elt,
|
||||
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.rougailconfig["base_option_name"])
|
||||
baseelt.description = self.rougailconfig["base_option_name"]
|
||||
self.reflector_objects[baseelt.path].get(
|
||||
[], baseelt.description
|
||||
) # pylint: disable=E1101
|
||||
|
||||
def set_name(
|
||||
self,
|
||||
elt,
|
||||
):
|
||||
"""Set name"""
|
||||
if elt.path not in self.objectspace.reflector_names:
|
||||
self.objectspace.set_name(elt, "optiondescription_")
|
||||
return self.objectspace.reflector_names[elt.path]
|
||||
|
||||
def get_information_name(self):
|
||||
self.informations_idx += 1
|
||||
return f"information_{self.informations_idx}"
|
||||
|
||||
def get_text(self):
|
||||
"""Get text"""
|
||||
return "\n".join(self.text["header"] + self.text["option"])
|
||||
|
||||
|
||||
class Common:
|
||||
"""Common function for variable and family"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
self.objectspace = tiramisu.objectspace
|
||||
self.elt = elt
|
||||
self.option_name = None
|
||||
self.tiramisu = tiramisu
|
||||
tiramisu.reflector_objects[elt.path] = self
|
||||
self.object_type = None
|
||||
self.informations = []
|
||||
|
||||
def get(self, calls, parent_name):
|
||||
"""Get tiramisu's object"""
|
||||
if self.elt.path in calls:
|
||||
msg = f'"{self.elt.path}" will make an infinite loop'
|
||||
raise DictConsistencyError(msg, 80, self.elt.xmlfiles)
|
||||
self_calls = calls.copy()
|
||||
self_calls.append(self.elt.path)
|
||||
self.calls = self_calls
|
||||
if self.option_name is None:
|
||||
self.option_name = self.objectspace.reflector_names[self.elt.path]
|
||||
self.populate_attrib()
|
||||
if self.informations:
|
||||
for information in self.informations:
|
||||
self.tiramisu.text['option'].append(f'{information}.set_option({self.option_name})')
|
||||
return self.option_name
|
||||
|
||||
def populate_attrib(self):
|
||||
"""Populate attributes"""
|
||||
keys = {"name": self.convert_str(self.elt.name)}
|
||||
if hasattr(self.elt, "description") and self.elt.description:
|
||||
keys["doc"] = self.convert_str(self.elt.description)
|
||||
self._populate_attrib(keys)
|
||||
if self.elt.path in self.objectspace.properties:
|
||||
keys["properties"] = self.properties_to_string(
|
||||
self.objectspace.properties[self.elt.path]
|
||||
)
|
||||
self.populate_informations(keys)
|
||||
attrib = ", ".join([f"{key}={value}" for key, value in keys.items()])
|
||||
self.tiramisu.text["option"].append(
|
||||
f"{self.option_name} = {self.object_type}({attrib})"
|
||||
)
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: dict,
|
||||
) -> None: # pragma: no cover
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
def convert_str(value):
|
||||
"""convert string"""
|
||||
if value is None:
|
||||
return "None"
|
||||
return dumps(value, ensure_ascii=False)
|
||||
|
||||
def properties_to_string(
|
||||
self,
|
||||
values: list,
|
||||
) -> None:
|
||||
"""Change properties to string"""
|
||||
properties = []
|
||||
calc_properties = []
|
||||
for property_, value in values.items():
|
||||
if value is True:
|
||||
properties.append(self.convert_str(property_))
|
||||
elif isinstance(value, list):
|
||||
for val in value:
|
||||
calc_properties.append(self.calculation_value(val))
|
||||
else:
|
||||
calc_properties.append(self.calculation_value(value))
|
||||
return "frozenset({" + ", ".join(sorted(properties) + calc_properties) + "})"
|
||||
|
||||
def calc_properties(
|
||||
self,
|
||||
prop,
|
||||
calculation,
|
||||
) -> str:
|
||||
"""Populate properties"""
|
||||
option_name = self.tiramisu.reflector_objects[child.source.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
kwargs = (
|
||||
f"'condition': ParamOption({option_name}, notraisepropertyerror=True), "
|
||||
f"'expected': {self.populate_param(child.expected)}"
|
||||
)
|
||||
if child.inverse:
|
||||
kwargs += ", 'reverse_condition': ParamValue(True)"
|
||||
return (
|
||||
f"Calculation(func['calc_value'], Params(ParamValue('{child.name}'), "
|
||||
f"kwargs={{{kwargs}}}), func['calc_value_property_help'])"
|
||||
)
|
||||
|
||||
def populate_informations(self, keys):
|
||||
"""Populate Tiramisu's informations"""
|
||||
informations = self.objectspace.informations.get(self.elt.path)
|
||||
if not informations:
|
||||
return
|
||||
keys['informations'] = informations
|
||||
|
||||
def populate_param(
|
||||
self,
|
||||
param,
|
||||
):
|
||||
"""Populate variable parameters"""
|
||||
if not isinstance(param, dict):
|
||||
if isinstance(param, str):
|
||||
value = self.convert_str(param)
|
||||
else:
|
||||
value = param
|
||||
return f"ParamValue({value})"
|
||||
if param["type"] == "information":
|
||||
if self.elt.multi:
|
||||
default = []
|
||||
else:
|
||||
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":
|
||||
return "ParamIndex()"
|
||||
if param["type"] == "variable":
|
||||
return self.build_option_param(
|
||||
param["variable"],
|
||||
param.get("propertyerror", True),
|
||||
param.get("suffix"),
|
||||
param.get("dynamic"),
|
||||
)
|
||||
if param["type"] == "any":
|
||||
if isinstance(param["value"], str):
|
||||
value = self.convert_str(param["value"])
|
||||
else:
|
||||
value = str(param["value"])
|
||||
return "ParamValue(" + value + ")"
|
||||
raise Exception("pfff")
|
||||
|
||||
def build_option_param(
|
||||
self,
|
||||
param,
|
||||
propertyerror,
|
||||
suffix: Optional[str],
|
||||
dynamic,
|
||||
) -> str:
|
||||
"""build variable parameters"""
|
||||
if param.path == self.elt.path:
|
||||
return "ParamSelfOption(whole=False)"
|
||||
option_name = self.tiramisu.reflector_objects[param.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
params = [f"{option_name}"]
|
||||
if suffix is not None:
|
||||
param_type = "ParamDynOption"
|
||||
params.append(str(suffix))
|
||||
else:
|
||||
param_type = "ParamOption"
|
||||
if not propertyerror:
|
||||
params.append("notraisepropertyerror=True")
|
||||
return f'{param_type}({", ".join(params)})'
|
||||
|
||||
def calculation_value(
|
||||
self,
|
||||
function,
|
||||
) -> str:
|
||||
"""Generate calculated value"""
|
||||
child = function.to_function(self.objectspace)
|
||||
new_args = []
|
||||
kwargs = []
|
||||
if "params" in child:
|
||||
for key, value in child["params"].items():
|
||||
if not key:
|
||||
for val in value:
|
||||
new_args.append(self.populate_param(val))
|
||||
else:
|
||||
kwargs.append(f"'{key}': " + self.populate_param(value))
|
||||
ret = (
|
||||
f"Calculation(func['{child['function']}'], Params(("
|
||||
+ ", ".join(new_args)
|
||||
+ ")"
|
||||
)
|
||||
if kwargs:
|
||||
ret += ", kwargs={" + ", ".join(kwargs) + "}"
|
||||
ret += ")"
|
||||
if hasattr(child, "warnings_only"):
|
||||
print("HU????")
|
||||
ret += f", warnings_only={child.warnings_only}"
|
||||
if "help" in child:
|
||||
ret += f", help_function=func['{child['help']}']"
|
||||
ret = ret + ")"
|
||||
return ret
|
||||
|
||||
def populate_calculation(self,
|
||||
datas: Union[Calculation, str, list],
|
||||
return_a_tuple: bool=False,
|
||||
) -> str:
|
||||
if isinstance(datas, str):
|
||||
return self.convert_str(datas)
|
||||
if isinstance(datas, Calculation):
|
||||
return self.calculation_value(datas)
|
||||
if not isinstance(datas, list):
|
||||
return datas
|
||||
params = []
|
||||
for idx, data in enumerate(datas):
|
||||
if isinstance(data, Calculation):
|
||||
params.append(self.calculation_value(data))
|
||||
elif isinstance(data, str):
|
||||
params.append(self.convert_str(data))
|
||||
else:
|
||||
params.append(str(data))
|
||||
if return_a_tuple:
|
||||
ret = '('
|
||||
else:
|
||||
ret = '['
|
||||
ret += ", ".join(params)
|
||||
if return_a_tuple:
|
||||
if len(params) <= 1:
|
||||
ret += ","
|
||||
ret += ")"
|
||||
else:
|
||||
ret += "]"
|
||||
return ret
|
||||
|
||||
|
||||
class Variable(Common):
|
||||
"""Manage variable"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
super().__init__(elt, tiramisu)
|
||||
if elt.type in self.tiramisu.objectspace.rougailconfig['custom_types']:
|
||||
self.object_type = self.tiramisu.objectspace.rougailconfig['custom_types'][elt.type].__name__
|
||||
else:
|
||||
self.object_type = CONVERT_OPTION[elt.type]["opttype"]
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: dict,
|
||||
):
|
||||
if self.elt.type == "symlink":
|
||||
keys["opt"] = self.tiramisu.reflector_objects[self.elt.opt.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
if self.elt.type == "choice":
|
||||
keys["values"] = self.populate_calculation(self.elt.choices, return_a_tuple=True)
|
||||
if self.elt.path in self.objectspace.multis:
|
||||
keys["multi"] = self.objectspace.multis[self.elt.path]
|
||||
if not hasattr(self.elt, "default"):
|
||||
print('FIXME CA EXISTE!!!')
|
||||
if hasattr(self.elt, "default") and self.elt.default is not None:
|
||||
keys["default"] = self.populate_calculation(self.elt.default)
|
||||
if self.elt.path in self.objectspace.default_multi:
|
||||
keys["default_multi"] = self.populate_calculation(self.objectspace.default_multi[self.elt.path])
|
||||
if self.elt.validators:
|
||||
keys["validators"] = self.populate_calculation(self.elt.validators)
|
||||
for key, value in CONVERT_OPTION.get(self.elt.type, {}).get("initkwargs", {}).items():
|
||||
if isinstance(value, str):
|
||||
value = self.convert_str(value)
|
||||
keys[key] = value
|
||||
if self.elt.params:
|
||||
for param in self.elt.params:
|
||||
value = param.value
|
||||
if isinstance(value, str):
|
||||
value = self.convert_str(value)
|
||||
keys[param.key] = value
|
||||
|
||||
|
||||
class Family(Common):
|
||||
"""Manage family"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
elt,
|
||||
tiramisu,
|
||||
):
|
||||
super().__init__(elt, tiramisu)
|
||||
if self.elt.type == "dynamic":
|
||||
self.tiramisu.objectspace.has_dyn_option = True
|
||||
self.object_type = "ConvertDynOptionDescription"
|
||||
elif self.elt.type == "leadership":
|
||||
self.object_type = "Leadership"
|
||||
else:
|
||||
self.object_type = "OptionDescription"
|
||||
self.children = []
|
||||
|
||||
def add(self, child):
|
||||
"""Add a child"""
|
||||
self.children.append(child)
|
||||
|
||||
def _populate_attrib(
|
||||
self,
|
||||
keys: list,
|
||||
) -> None:
|
||||
if self.elt.type == "dynamic":
|
||||
keys["suffixes"] = self.populate_calculation(self.elt.dynamic)
|
||||
children = []
|
||||
for path in self.objectspace.parents[self.elt.path]:
|
||||
children.append(self.objectspace.paths[path])
|
||||
keys["children"] = (
|
||||
"["
|
||||
+ ", ".join(
|
||||
[
|
||||
self.tiramisu.reflector_objects[child.path].get(
|
||||
self.calls, self.elt.path
|
||||
)
|
||||
for child in children
|
||||
]
|
||||
)
|
||||
+ "]"
|
||||
)
|
||||
File diff suppressed because it is too large
Load diff
485
src/rougail/user_datas.py
Normal file
485
src/rougail/user_datas.py
Normal file
|
|
@ -0,0 +1,485 @@
|
|||
"""
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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, 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 UserDatas:
|
||||
def __init__(self, config) -> None:
|
||||
self.config = config
|
||||
|
||||
def user_datas(
|
||||
self,
|
||||
user_datas: List[dict],
|
||||
*,
|
||||
invalid_user_datas_error: bool = False,
|
||||
unknown_user_datas_error: bool = False,
|
||||
):
|
||||
self.values = {}
|
||||
self.errors = []
|
||||
self.warnings = []
|
||||
if invalid_user_datas_error:
|
||||
self.invalids = self.errors
|
||||
else:
|
||||
self.invalids = self.warnings
|
||||
if unknown_user_datas_error:
|
||||
self.unknowns = self.errors
|
||||
else:
|
||||
self.unknowns = self.warnings
|
||||
self.show_secrets = False
|
||||
self._populate_values(user_datas)
|
||||
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_datas):
|
||||
for datas in user_datas:
|
||||
options = datas.get("options", {})
|
||||
source = datas["source"]
|
||||
for name, data in datas.get("values", {}).items():
|
||||
self.values[name] = {
|
||||
"source": source,
|
||||
"values": data,
|
||||
"options": options.copy(),
|
||||
}
|
||||
self.errors.extend(datas.get("errors", []))
|
||||
self.warnings.extend(datas.get("warnings", []))
|
||||
|
||||
def _get_variable(self, config):
|
||||
for subconfig in config:
|
||||
if subconfig.isoptiondescription():
|
||||
yield from self._get_variable(subconfig)
|
||||
else:
|
||||
yield 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)
|
||||
|
||||
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):
|
||||
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_type = self.config.option(dynamic_variable).information.get(
|
||||
"type"
|
||||
)
|
||||
dyn_options_values = (
|
||||
self.config.option(dynamic_variable).get().impl_getdefault()
|
||||
)
|
||||
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": []}
|
||||
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]["values"]:
|
||||
self.values[dynamic_variable]["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]["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]["values"] = value
|
||||
self.values[path]["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
|
||||
options = self.values[values_path].get("options", {})
|
||||
if (
|
||||
options.get("allow_secrets_variables", True) is False
|
||||
and option.type() == "password"
|
||||
):
|
||||
self.errors.append(
|
||||
_(
|
||||
'the variable "{0}" contains secrets and should not be defined in {1}'
|
||||
).format(path, self.values[values_path]["source"])
|
||||
)
|
||||
self.values.pop(path)
|
||||
continue
|
||||
value = self.convert_value(
|
||||
path, option, options, self.values[values_path]["values"]
|
||||
)
|
||||
index = option.index()
|
||||
if index is not None:
|
||||
if isinstance(value, tuple):
|
||||
self.values[values_path]["values"] = []
|
||||
# for i in range(len(option.parent().leader().value.get())):
|
||||
for i in range(option.value.len()):
|
||||
self.values[values_path]["values"].append(value)
|
||||
value = self.values[values_path]["values"]
|
||||
if not isinstance(value, list) or index >= len(value):
|
||||
continue
|
||||
value = value[index]
|
||||
option_without_index = self.config.option(path)
|
||||
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)
|
||||
try:
|
||||
self.set_value(option, value, options)
|
||||
# option.value.set(value)
|
||||
value_is_set = True
|
||||
except Exception as err:
|
||||
if path != option.path():
|
||||
self.values[option.path()] = self.values.pop(values_path)
|
||||
else:
|
||||
if "source" in self.values[values_path]:
|
||||
option_without_index.information.set(
|
||||
"loaded_from",
|
||||
_("loaded from {0}").format(
|
||||
self.values[values_path]["source"]
|
||||
),
|
||||
)
|
||||
# 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
|
||||
self.values[values_path]["values"][index] = undefined
|
||||
for tmp_value in self.values[values_path]["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":
|
||||
return "*" * 10
|
||||
return value
|
||||
|
||||
def _populate_error_warnings(self):
|
||||
# we don't find variable, apply value just to get error or warning messages
|
||||
for path, options in self.values.items():
|
||||
if "{{ identifier }}" in path:
|
||||
continue
|
||||
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:
|
||||
self.invalids.append(
|
||||
_(
|
||||
'cannot set the value "{0}" to the family {1}, it will be ignored when loading from {2}'
|
||||
).format(
|
||||
self._display_value(option, value),
|
||||
option.description(with_quote=True),
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
continue
|
||||
except PropertiesOptionError as err:
|
||||
self.unknowns.append(
|
||||
_("{0} loaded from {1}").format(err, options["source"])
|
||||
)
|
||||
except AttributeOptionError as err:
|
||||
if err.code == "option-not-found":
|
||||
self.unknowns.append(
|
||||
_(
|
||||
'variable or family "{0}" does not exist, it will be ignored when loading from {1}'
|
||||
).format(err.path, options["source"])
|
||||
)
|
||||
elif err.code == "option-dynamic":
|
||||
self.invalids.append(
|
||||
_(
|
||||
'"{0}" is the name of a dynamic family, it will be ignored when loading from {1}'
|
||||
).format(option.description(with_quote=True), options["source"])
|
||||
)
|
||||
else:
|
||||
self.invalids.append(
|
||||
_("{0} loaded from {1}").format(err, options["source"])
|
||||
)
|
||||
continue
|
||||
value = self.convert_value(
|
||||
path, option, self.values[path].get("options", {}), value
|
||||
)
|
||||
if option.isfollower():
|
||||
indexes = range(len(value))
|
||||
values = value
|
||||
else:
|
||||
indexes = [None]
|
||||
for index in indexes:
|
||||
try:
|
||||
if option.isfollower():
|
||||
value = values[index]
|
||||
if value is undefined or isinstance(value, CancelParam):
|
||||
continue
|
||||
self.config.option(path, index).value.set(value)
|
||||
else:
|
||||
self.set_value(option, value, options.get("options", {}))
|
||||
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
|
||||
display_name = option.description(with_quote=True)
|
||||
if index is not None:
|
||||
if path == err_path:
|
||||
self.unknowns.append(
|
||||
_(
|
||||
'variable {0} at index "{1}" is {2}, it will be ignored when loading from {3}'
|
||||
).format(
|
||||
display_name,
|
||||
index,
|
||||
properties,
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.unknowns.append(
|
||||
_(
|
||||
'family {0} is {1}, {2} at index "{3}" will be ignored when loading from {4}'
|
||||
).format(
|
||||
err._name,
|
||||
properties,
|
||||
display_name,
|
||||
index,
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
if path == err_path:
|
||||
self.unknowns.append(
|
||||
_(
|
||||
"variable {0} is {1}, it will be ignored when loading from {2}"
|
||||
).format(
|
||||
display_name, properties, options["source"]
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.unknowns.append(
|
||||
_(
|
||||
"family {0} is {1}, {2} will be ignored when loading from {3}"
|
||||
).format(
|
||||
err._name,
|
||||
properties,
|
||||
display_name,
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
self.unknowns.append(
|
||||
_("{0} in {1}").format(err, options["source"])
|
||||
)
|
||||
except LeadershipError as err:
|
||||
self.unknowns.append(_("{0} in {1}").format(err, options["source"]))
|
||||
except ValueError as err:
|
||||
err.prefix = ""
|
||||
if index is not None:
|
||||
type_ = option.type(translation=True)
|
||||
self.invalids.append(
|
||||
_(
|
||||
'the value "{0}" is an invalid {1} for {2} at index "{3}", {4}, it will be ignored when loading from {5}'
|
||||
).format(
|
||||
self._display_value(option, value),
|
||||
type_,
|
||||
option.description(with_quote=True),
|
||||
index,
|
||||
err,
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
else:
|
||||
type_ = option.type(translation=True)
|
||||
self.invalids.append(
|
||||
_(
|
||||
'the value "{0}" is an invalid {1} for {2}, {3}, it will be ignored when loading from {4}'
|
||||
).format(
|
||||
self._display_value(option, value),
|
||||
type_,
|
||||
option.description(with_quote=True),
|
||||
err,
|
||||
options["source"],
|
||||
)
|
||||
)
|
||||
except AttributeOptionError as err:
|
||||
if err.code == "option-dynamic":
|
||||
continue
|
||||
raise err from err
|
||||
|
||||
def set_value(self, option, value, options):
|
||||
is_secret_manager = options.get("secret_manager", False)
|
||||
if is_secret_manager and isinstance(value, tuple):
|
||||
# it's a function
|
||||
value = value[0](
|
||||
*value[1:], option=option, warnings=self.warnings, errors=self.errors
|
||||
)
|
||||
option.value.set(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
|
||||
|
|
@ -9,27 +9,25 @@ Cadoles (http://www.cadoles.com)
|
|||
Copyright (C) 2019-2021
|
||||
|
||||
Silique (https://www.silique.fr)
|
||||
Copyright (C) 2022-2024
|
||||
Copyright (C) 2022-2025
|
||||
|
||||
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 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 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 Lesser General Public License for more
|
||||
details.
|
||||
|
||||
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
|
||||
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, Union
|
||||
from unicodedata import normalize, combining
|
||||
import re
|
||||
from itertools import chain
|
||||
|
||||
from importlib.machinery import SourceFileLoader
|
||||
from importlib.util import spec_from_loader, module_from_spec
|
||||
|
|
@ -37,13 +35,17 @@ from importlib.util import spec_from_loader, module_from_spec
|
|||
from jinja2 import DictLoader, TemplateSyntaxError
|
||||
from jinja2.sandbox import SandboxedEnvironment
|
||||
from jinja2.parser import Parser
|
||||
from jinja2.nodes import Getattr
|
||||
from jinja2.nodes import Name, Getattr
|
||||
|
||||
from tiramisu.config import get_common_path
|
||||
|
||||
from .i18n import _
|
||||
from .error import DictConsistencyError
|
||||
|
||||
NAME_REGEXP = re.compile(r"^[a-z0-9_]*$")
|
||||
|
||||
PROPERTY_ATTRIBUTE = ["frozen", "hidden", "disabled", "mandatory"]
|
||||
|
||||
|
||||
def valid_variable_family_name(
|
||||
name: str,
|
||||
|
|
@ -52,38 +54,24 @@ def valid_variable_family_name(
|
|||
match = NAME_REGEXP.search(name)
|
||||
if not match:
|
||||
msg = _(
|
||||
f'invalid variable or family name "{name}" must only contains '
|
||||
"lowercase ascii character, number or _"
|
||||
)
|
||||
'invalid variable or family name "{0}" must only contains lowercase ascii character, number or _'
|
||||
).format(name)
|
||||
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.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(eosfunc_file) -> List[str]:
|
||||
"""list all functions in eosfunc"""
|
||||
loader = SourceFileLoader("eosfunc", eosfunc_file)
|
||||
def load_modules(name, module) -> List[str]:
|
||||
"""list all functions in a module"""
|
||||
loader = SourceFileLoader(name, module)
|
||||
spec = spec_from_loader(loader.name, loader)
|
||||
eosfunc = module_from_spec(spec)
|
||||
loader.exec_module(eosfunc)
|
||||
return eosfunc
|
||||
|
||||
|
||||
def get_realpath(
|
||||
path: str,
|
||||
path_prefix: str,
|
||||
) -> str:
|
||||
if path_prefix:
|
||||
return f"{path_prefix}.{path}"
|
||||
return path
|
||||
# def get_realpath(
|
||||
# path: str,
|
||||
# ) -> str:
|
||||
# return path
|
||||
|
||||
|
||||
def get_jinja_variable_to_param(
|
||||
|
|
@ -92,7 +80,6 @@ def get_jinja_variable_to_param(
|
|||
objectspace,
|
||||
xmlfiles,
|
||||
functions,
|
||||
path_prefix,
|
||||
version,
|
||||
namespace,
|
||||
):
|
||||
|
|
@ -107,21 +94,127 @@ def get_jinja_variable_to_param(
|
|||
return g.node.name + "." + g.attr
|
||||
|
||||
variables = set()
|
||||
if objectspace.namespace is None:
|
||||
for n in parsed_content.find_all(Name):
|
||||
variables.add(n.name)
|
||||
for g in parsed_content.find_all(Getattr):
|
||||
variables.add(recurse_getattr(g))
|
||||
except TemplateSyntaxError as err:
|
||||
msg = _(f'error in jinja "{jinja_text}": {err}')
|
||||
raise Exception(msg) from err
|
||||
msg = _('error in jinja "{0}" for the variable "{1}": {2}').format(
|
||||
jinja_text, current_path, err
|
||||
)
|
||||
raise DictConsistencyError(msg, 39, xmlfiles) from err
|
||||
except AttributeError:
|
||||
pass
|
||||
variables = list(variables)
|
||||
variables.sort()
|
||||
variables.sort(reverse=True)
|
||||
founded_variables = {}
|
||||
unknown_variables = []
|
||||
for variable_path in variables:
|
||||
variable, suffix = objectspace.paths.get_with_dynamic(
|
||||
variable, identifier = objectspace.paths.get_with_dynamic(
|
||||
variable_path,
|
||||
path_prefix,
|
||||
current_path,
|
||||
version,
|
||||
namespace,
|
||||
xmlfiles,
|
||||
)
|
||||
if variable and variable.path in objectspace.variables:
|
||||
yield variable, suffix, variable_path
|
||||
founded_variables[variable_path] = (identifier, variable)
|
||||
else:
|
||||
sub_family = variable_path + "."
|
||||
for founded_variable in chain(founded_variables, unknown_variables):
|
||||
if founded_variable.startswith(sub_family):
|
||||
break
|
||||
else:
|
||||
unknown_variables.append(variable_path)
|
||||
|
||||
for variable_path in unknown_variables:
|
||||
for v in founded_variables:
|
||||
if get_common_path(v, variable_path) == v:
|
||||
break
|
||||
else:
|
||||
root_path = None
|
||||
vpath = variable_path
|
||||
while "." in vpath:
|
||||
vpath = vpath.rsplit(".", 1)[0]
|
||||
variable, identifier = objectspace.paths.get_with_dynamic(
|
||||
vpath,
|
||||
current_path,
|
||||
version,
|
||||
namespace,
|
||||
xmlfiles,
|
||||
)
|
||||
if variable and variable.path in objectspace.families:
|
||||
root_path = vpath
|
||||
break
|
||||
if root_path:
|
||||
yield {}, None, root_path
|
||||
for variable_path, data in founded_variables.items():
|
||||
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",
|
||||
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 :]
|
||||
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()
|
||||
|
|
|
|||
8
tests/default_option_params/structure/00-test.yml
Normal file
8
tests/default_option_params/structure/00-test.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
version: 1.1
|
||||
|
||||
file:
|
||||
type: unix_filename
|
||||
params:
|
||||
allow_relative: true
|
||||
default:
|
||||
test/unknown_file
|
||||
13
tests/dictionaries/00_0empty/tiramisu/base.py
Normal file
13
tests/dictionaries/00_0empty/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
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=[])
|
||||
9
tests/dictionaries/00_0empty/tiramisu/no_namespace.py
Normal file
9
tests/dictionaries/00_0empty/tiramisu/no_namespace.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||
14
tests/dictionaries/00_0no_variable/tiramisu/base.py
Normal file
14
tests/dictionaries/00_0no_variable/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
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")
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
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")
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
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")
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[], properties=frozenset({"advanced"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[])
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"rougail.version": null
|
||||
}
|
||||
15
tests/dictionaries/00_0version_underscore/tiramisu/base.py
Normal file
15
tests/dictionaries/00_0version_underscore/tiramisu/base.py
Normal 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('../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_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'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
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_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
||||
3
tests/dictionaries/00_1empty_variable/makedict/base.json
Normal file
3
tests/dictionaries/00_1empty_variable/makedict/base.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"rougail.empty": null
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"rougail.empty": null
|
||||
}
|
||||
15
tests/dictionaries/00_1empty_variable/tiramisu/base.py
Normal file
15
tests/dictionaries/00_1empty_variable/tiramisu/base.py
Normal 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('../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_2 = StrOption(name="empty", doc="empty", properties=frozenset({"basic", "mandatory"}), informations={'ymlfiles': ['../rougail-tests/structures/00_1empty_variable/rougail/00-base.yml'], 'type': 'string'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2], properties=frozenset({"basic"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
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_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1])
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"rougail.var1": "no",
|
||||
"rougail.var2": [
|
||||
"no"
|
||||
]
|
||||
}
|
||||
17
tests/dictionaries/00_2default_calculated/tiramisu/base.py
Normal file
17
tests/dictionaries/00_2default_calculated/tiramisu/base.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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 }}\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_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'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
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')
|
||||
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||
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_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_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_2])
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"rougail.var1": [
|
||||
"no",
|
||||
"yes",
|
||||
"maybe"
|
||||
],
|
||||
"rougail.var2": [
|
||||
"no",
|
||||
"yes",
|
||||
"maybe"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
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'] = "{% 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_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'})
|
||||
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, option_3], properties=frozenset({"standard"}), informations={'ymlfiles': ['']})
|
||||
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue