Compare commits

...

No commits in common. "6d34d05d034e23839778f2f2a7b6248594ba2f93" and "477b0a2da10f44e63092ce9904e85f9a522729dc" have entirely different histories.

302 changed files with 46621 additions and 306 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
*~
*#
*.pyc
*.mo
*.swp
build/

10
AUTHORS Normal file
View file

@ -0,0 +1,10 @@
Authors
--------
Emmanuel Garette <egarette@cadoles.com> lead developer
Gwenaël Rémond <gremond@cadoles.com> developer
Daniel Dehennin <daniel.dehennin@ac-dijon.fr> contributor
Philippe Caseiro <pcaseiro@cadoles.com> contributor
Gerald Schwartzmann <gschartzmann@cadoles.com> tiramisu's logo (made with The Gimp)

12
COPYING Normal file
View file

@ -0,0 +1,12 @@
Tiramisu is placed under the terms of the GNU LESSER GENERAL PUBLIC LICENSE V3 as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
See lgpl-3.0.txt for more informations.
The documentation is licenced under the terms of a Creative Commons
Attribution-ShareAlike 3.0 Unported License.
See ccbysa3.0.txt or
http://creativecommons.org/licenses/by-sa/3.0/deed.en_US for informations

230
ChangeLog Normal file
View file

@ -0,0 +1,230 @@
Mon Apr 1 11:47:30 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc16
* tiramisu is now async
* add postgresql storage
Mon Sep 2 14:10:40 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc15
* add parents method to MetaConfig
Wed Aug 28 15:50:30 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc14
* correction in metaconfig_prefix
* correction in validation with parent
Mon Aug 21 14:24:42 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc12
* prefix metaconfig_prefix with current name
Mon Aug 19 08:02:27 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc11
* Config could have multiple parents
* todict works with Metaconfig
* separate Cache from values and settings
Fri Jul 26 09:43:03 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc9 and rc10
* better todict support (especially for leadership
* can add display_name method to Config init to change the name a
option in errors
Mon Jun 5 14:49:27 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc7
* retrieve metaconfig/mixconfig/config by name in a metaconfig/mixconfig
* add new config with mixconfig type
Mon Apr 8 08:40:10 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc6
* import tiramisu-json in tiramisu repository
Fri Apr 5 20:57:05 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc4 and rc5
* change filename/directory name with Python Packaging Autority
recommendations
* do not change Config contexts properties when reload in MetaConfig
(fixes #7)
* add/remove config in mixconfig or metaconfig (fixes #6)
Sun Mar 24 20:24:34 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc3
* corrections in debug logger
* requirement can have callback
* version 3.0 rc2
* add cidr notation to domainnameoption if allow_ip is True (fixes #5)
* safer option.type() (ref #4)
Tue Mar 5 08:22:12 2018 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc2
* simplifying netmaskoption
* multiple option call (fixes #1)
* doesn't check follower requirement with an other follower or a leader if idx is None (fixes #3)
Mon Feb 25 10:12:35 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* version 3.0 rc1
Sat Sep 8 22:54:12 2019 +0200 Emmanuel Garette <egarette@cadoles.com>
* propose a new API to access to Tiramisu Option
This new API is totally incompatible with older's one
Sat Jul 8 15:57:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* better cache, only remove value/property from cache for value
modified and for all value affected by this modification
Sat May 20 16:27:09 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* add 'operator' to requirement
Wed May 17 22:11:55 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* add 'remove' to Multi
Sun Feb 12 10:30:13 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* error in external function should returns explicit error message
all errors will be ConfigError
Thu Jan 12 19:49:41 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* can mix inversed and non inversed requires
* validator's function can have 1 arg, 2 args or 3 args without
valid_params specify by user. First arg will receive the value, second
arg will receive all values (useful for multi) and the third one will
receive index (useful for multi).
This functionaly only works for now if user not specify valid_params.
Wed Jan 11 22:56:30 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* copy the context in carry_out_calculation
Thu Jan 10 11:55:02 2017 +0200 Gwenael Remond <gremond@cadoles.com>
* converts the doc informations into unicode
Mon Jan 9 20:12:02 2017 +0200 Emmanuel Garette <egarette@cadoles.com>
* make_dict has new fullpath option
Wed Nov 16 22:30:12 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* consistency "not_equal" works now with multi and submulti
* a multi or submulti could be "unique" (same value one time)
* consistency "not_equal" means "unique" too
Wed Oct 12 21:55:53 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* consistency is now check "not_equal" if one option has
PropertiesOptionError
* transitive in apply_requires should only by apply if properties are
same has testing action
Mon Oct 10 21:39:04 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* consistency with default value for all values now works
* warnings works now even if default value is None
Thu Sep 22 08:25:33 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* force_store_value is rebuild if needed
Mon Mar 7 16:10:30 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* force_store_value is now used directly when configuration is loaded
* add force_permissive to Values.is_default_owner
Sun Nov 29 23:01:28 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* requires could be apply to a slave and properties could be different
Mon Oct 12 17:05:28 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* domainname with only one character is now allowed
Thu Sep 17 21:23:34 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* check with option as parameter
Sun Jul 26 19:09:29 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* add global 'empty' property, this property raise mandatory
PropertiesOptionError if multi or master have empty value
Fri Jul 24 18:03:59 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* add duplicate option to Config, to generate new Config with same
value, properties, Option. Option are not duplicated.
Mon Apr 20 14:44:15 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* if option is multi, the properties disallow [None] for a multi but
[] too, with allow_empty_list to True, [None] is not allowed, but you
can have empty list (so [])
Sun Apr 19 09:14:21 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* valid Option is an unicode or a string if needed
* difference between option/optiondescription in PropertiesOptionError
message
* remove slave values when delete a master without value
* allow uppercase in resource name in URLOption
Sat Apr 18 22:42:53 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* refactor validation, build a fake context (with new Values and
Settings) to validate value with those object. Now value with
callback and consistency are correctly validate
* ability to disable warnings validation
* if ValueError and PropertieError together, should raise with
PropertieError
Sun Mar 8 12:02:17 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
* valid default/callback value in consistencies
Sun Dec 7 14:37:32 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* mandatory master/slave's consistency with default value as slave
* test uppercase character before valid domain name for better error
message
Mon Dec 1 22:58:13 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* propertyerror are transitive in consistency, now it's possible to set
non-transitive consistency
* support transitive in consistency with multiple option return
* can reset slave value in all case when deleting master value
* in_network's consistency now verify that IP is not network or
broadcast's IP + ip_netmask's consistency now verify that IP is not
broadcast's IP
Sun Oct 26 08:50:38 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* if option is frozen with force_default_on_freeze property, owner
must be 'default', check property when tried to change owner
* bad characters in DomainnameOption could be in warning level
* frozen with force_default_on_freeze can change owner
* add force_permissive to config __iter__
* add force_permissive to slave for a master or to master for a slave
* remove mandatory_warnings in config.py
* add force_permissive in mandatory_warnings
Sat Oct 25 22:48:08 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* cannot add unvalaible consistency for an option
* allow number as first letter of a domainname with netbios type
Fri Jun 20 16:27:55 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* add TIRAMISU_STORAGE for personalise default storage in
environnement
Thu Jun 19 23:20:29 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* add DynOptionDescription:
DynOptionDescription are OptionDescription that generate auto
OptionDescription with a callback function
Sun Apr 27 10:32:40 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* behavior change in ChoiceOption:
remove open_values, that no sens (we cannot validate type) if
you want something like open_values, please use a typed option and
add impl_(s|g)et_information to add proposed values and use it in your
code
* add dynamic ChoiceOption:
we can have dynamic ChoiceOption. Parameter values can be a function
and, as callback, we can add values_params
Fri Apr 25 22:57:08 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* add SubMulti:
a SubMulti is a multi in a multi variable
Sat Apr 12 11:37:27 2014 +0200 Emmanuel Garette <egarette@cadoles.com>
* behavior change in master/slave part of code:
if slave has a default value greater than master's one, it's raise
SlaveError, didn't try to reduce the slave's length
* tiramisu/config.py (in cfgimpl_get_home_by_path and getattr) and
tiramisu/value.py (in getitem): arity change, remove force_properties
* tiramisu/option.py: split into tiramisu/option directory
* tiramisu/option/masterslave.py: add special object MasterSlaves for
all code related to master/slaves options
* tiramisu/option/masterslave.py: check every time master and slaves
values (length, consistency, ...)
* change None to undefined when needed

304
LICENSE
View file

@ -1,304 +0,0 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
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.
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.
0. Additional Definitions.
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.
"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.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright © 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.
Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is 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. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
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.
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
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 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. Use with the GNU Affero General Public License.
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 Affero 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 special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU 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 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 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 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 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 General Public License for more details.
You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
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 GPL, see <http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <http://www.gnu.org/philosophy/why-not-lgpl.html>.

165
LICENSE.txt Normal file
View file

@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
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.
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.
0. Additional Definitions.
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.
"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.

8
MANIFEST.in Normal file
View file

@ -0,0 +1,8 @@
# Include the README
include *.rst
# Include the license file
include LICENSE.txt
# Include the data files
recursive-include tiramisu *.py *.mo

83
Makefile Normal file
View file

@ -0,0 +1,83 @@
#!/usr/bin/make
PACKAGE := tiramisu
ifeq ($(PACKAGE_DST),)
PACKAGE_DST := $(PACKAGE)
endif
INSTALL := install
INSTALL_DATA := install -m 644
INSTALL_PROGRAM := install -m 755
INSTALL_DIR := install -m 755 -d
TRADUC_DIR = tiramisu/locale
TRADUC_DEST = $(DESTDIR)/usr/share/locale
PYTHON_OPTS =
ifneq ($(DESTDIR),)
PYTHON_OPTS += --root $(DESTDIR)
endif
VERSION := `cat VERSION`
define gettext
if command -v pygettext >/dev/null 2>&1 ; then \
P="pygettext" ; \
else \
P="pygettext.py" ; \
fi ; \
$$P -p $(TRADUC_DIR)/ -o $(PACKAGE).pot `find $(PACKAGE)/ -name "*.py"`
endef
# Build translation files
define build_translation
if [ -d ${1} ]; then \
for f in `find ${1} -name "*.po"`; do \
msgfmt -o `dirname $$f`/`basename $$f ".po"`.mo $$f || true; \
done; \
fi
endef
# Install Traduction
define install_translation
if [ -d ${1} ]; then \
for file in `find ${1} -name "*.mo"`; do \
$(INSTALL_DIR) $(TRADUC_DEST)/`echo $$file | cut -d '/' -f 2` || true; \
$(INSTALL_DIR) $(TRADUC_DEST)/`echo $$file | cut -d '/' -f 2`/LC_MESSAGES || true; \
$(INSTALL_DATA) $$file $(TRADUC_DEST)/`echo $$file | cut -d '/' -f 2`/LC_MESSAGES/$(PACKAGE_DST).mo || true; \
done; \
fi
endef
all: build-lang
clean:
$(RM) -r build
$(RM) -r $(PACKAGE).egg-info/
$(RM) -r $(TRADUC_DIR)/*/*.mo
#test: clean
# py.test
# Build or update Portable Object Base Translation for gettext
build-pot:
$(call gettext)
build-lang:
$(call build_translation, $(TRADUC_DIR))
# install-lang:
# $(INSTALL_DIR) $(TRADUC_DEST)
# $(call install_translation, $(TRADUC_DIR))
install: # install-lang
python3 setup.py install --no-compile $(PYTHON_OPTS)
dist:
git archive --format=tar --prefix $(PACKAGE)-$(VERSION)/ HEAD | gzip -9 > $(PACKAGE)-$(VERSION).tar.gz
# List in .PHONY to force generation at each call
.PHONY: all clean build-pot build-lang install-lang install dist

View file

@ -1,3 +1,13 @@
# tiramisu
![Logo Tiramisu](logo.png "logo Tiramisu")
[Documentations](doc/README.md)
# LICENSES
See COPYING for the licences of the code and the documentation.
See AUTHORS for the details about the tiramisu's team.
Configuration management library written in python

77
ccbysa3.0.txt Normal file
View file

@ -0,0 +1,77 @@
Creative Commons (CC)
Attribution-ShareAlike 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
1. Definitions
"Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
"Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License.
"Creative Commons Compatible License" means a license that is listed at http://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License.
"Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
"License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
"Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
"Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
"Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
"You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
"Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
"Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
to Distribute and Publicly Perform Adaptations.
For the avoidance of doubt:
Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested.
You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
8. Miscellaneous
Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of the License.
Creative Commons may be contacted at http://creativecommons.org/.

64
doc/README.md Normal file
View file

@ -0,0 +1,64 @@
![Logo Tiramisu](../logo.png "logo Tiramisu")
# Python3 Tiramisu library user documentation
## The tasting of `Tiramisu` --- `user documentation`
Tiramisu:
- is a cool, refreshing Italian dessert,
- it is also an [options controller tool](http://en.wikipedia.org/wiki/Configuration_management#Overview)
It's a pretty small, local (that is, straight on the operating system) options handler and controller.
- [Getting started](gettingstarted.md)
- [The Config](config.md)
- [Browse the Config](browse.md)
- [Manage values](api_value.md)
.. toctree::
:maxdepth: 2
api_property
storage
application
quiz
glossary
External project:
.. toctree::
:maxdepth: 2
cmdline_parser
.. FIXME ca veut rien dire : "AssertionError: type <class 'tiramisu.autolib.Calculation'> invalide pour des propriétés pour protocols, doit être un frozenset"
.. FIXME changer le display_name !
.. FIXME voir si warnings_only dans validator !
.. FIXME submulti dans les leadership
.. FIXME exemple avec default_multi (et undefined)
.. FIXME config, metaconfig, ...
.. FIXME fonction de base
.. FIXME information
.. FIXME demoting_error_warning, warnings, ...
.. FIXME class _TiramisuOptionOptionDescription(CommonTiramisuOption):
.. FIXME class _TiramisuOptionOption(_TiramisuOptionOptionDescription):
.. FIXME class TiramisuOptionInformation(CommonTiramisuOption):
.. FIXME class TiramisuContextInformation(TiramisuConfig):
.. FIXME expire
.. FIXME custom display_name
.. FIXME assert await cfg.cache.get_expiration_time() == 5
.. FIXME await cfg.cache.set_expiration_time(1)
.. FIXME convert_suffix_to_path
Indices and full bunch of code
===============================
* `All files for which code is available <_modules/index.html>`_
* :ref:`genindex`
* :ref:`search`

439
doc/api_value.md Normal file
View file

@ -0,0 +1,439 @@
# Manage values
## Values with options
### Simple option
Begin by creating a Config. This Config will contains two options:
- first one is an option where the user will set an unix path
- second one is an option that calculate the disk usage of the previous unix path
Let's import needed object:
```python
from asyncio import run
from shutil import disk_usage
from os.path import isdir
from tiramisu import FilenameOption, FloatOption, OptionDescription, Config, \
Calculation, Params, ParamValue, ParamOption, ParamSelfOption
```
Create a function that verify the path exists in current system:
```python
def valid_is_dir(path):
# verify if path is a directory
if not isdir(path):
raise ValueError('this directory does not exist')
```
Use this function as a :doc:`validator` in a new option call `path`:
```python
filename = FilenameOption('path', 'Path', validators=[Calculation(valid_is_dir,
Params(ParamSelfOption()))])
```
Create a second function that calculate the disk usage:
```python
def calc_disk_usage(path, size='bytes'):
# do not calc if path is None
if path is None:
return None
if size == 'bytes':
div = 1
else:
# bytes to gigabytes
div = 1024 * 1024 * 1024
return disk_usage(path).free / div
```
Add a new option call `usage` that use this function with first argument the option `path` created before:
```python
usage = FloatOption('usage', 'Disk usage', Calculation(calc_disk_usage,
Params(ParamOption(filename))))
```
Finally add those options in option description and a Config:
```
disk = OptionDescription('disk', 'Verify disk usage', [filename, usage])
root = OptionDescription('root', 'root', [disk])
async def main():
config = await Config(root)
await config.property.read_write()
config = run(main())
```
#### Get and set a value
First of all, retrieve the values of both options:
```python
async def main():
print(await config.option('disk.path').value.get())
print(await config.option('disk.usage').value.get())
run(main())
```
returns:
```
None
None
```
Enter a value of the `path` option:
```python
async def main():
await config.option('disk.path').value.set('/')
print(await config.option('disk.path').value.get())
print(await config.option('disk.usage').value.get())
run(main())
```
returns:
```
/
668520882176.0
```
When you enter a value it is validated:
>>> try:
>>> config.option('disk.path').value.set('/unknown')
>>> except ValueError as err:
>>> print(err)
"/unknown" is an invalid file name for "Path", this directory does not exist
We can also set a :doc:`calculation` as value. For example, we want to launch previous function but with in_gb to True as second argument:
>>> calc = Calculation(calc_disk_usage, Params((ParamOption(filename),
... ParamValue('gigabytes'))))
>>> config.option('disk.usage').value.set(calc)
>>> config.option('disk.usage').value.get()
622.6080360412598
#### Is value is valid?
To check is a value is valid:
>>> config.option('disk.path').value.valid()
True
#### Display the default value
Even if the value is modify, you can display the default value with `default` method:
>>> config.option('disk.path').value.set('/')
>>> config.option('disk.usage').value.set(1.0)
>>> config.option('disk.usage').value.get()
1.0
>>> config.option('disk.usage').value.default()
668510105600.0
#### Return to the default value
If the value is modified, just `reset` it to retrieve the default value:
>>> config.option('disk.path').value.set('/')
>>> config.option('disk.path').value.get()
/
>>> config.option('disk.path').value.reset()
>>> config.option('disk.path').value.get()
None
#### The ownership of a value
Every option has an owner, that will indicate who changed the option's value last.
The default owner of every option is "default", and means that the value is the default one.
If you use a "reset" instruction to get back to the default value, the owner will get back
to "default" as well.
>>> config.option('disk.path').value.reset()
>>> config.option('disk.path').owner.isdefault()
True
>>> config.option('disk.path').owner.get()
default
>>> config.option('disk.path').value.set('/')
>>> config.option('disk.path').owner.isdefault()
False
>>> config.option('disk.path').owner.get()
user
All modified values have an owner. We can change at anytime this owner:
>>> config.option('disk.path').owner.set('itsme')
>>> config.option('disk.path').owner.get()
itsme
.. note::
This will work only if the current owner isn't "default".
This new user will be keep until anyone change the value:
>>> config.option('disk.path').value.set('/')
>>> config.option('disk.path').owner.get()
user
This username is in fact the `config` user, which is `user` by default:
>>> config.owner.get()
user
This owner will be the owner that all the options in the config will get when their value is changed.
This explains why earlier, the owner became "user" when changing the option's value.
We can change this owner:
>>> config.owner.set('itsme')
>>> config.option('disk.path').value.set('/')
>>> config.option('disk.path').owner.get()
itsme
### Get choices from a Choice option
In the previous example, it's difficult to change the second argument of the `calc_disk_usage`.
For ease the change, add a `ChoiceOption` and replace the `size_type` and `disk` option:
.. literalinclude:: ../src/api_value_choice.py
:lines: 26-31
:linenos:
We set the default value to `bytes`, if not, the default value will be None.
:download:`download the config <../src/api_value_choice.py>`
At any time, we can get all de choices avalaible for an option:
>>> config.option('disk.size_type').value.list()
('bytes', 'giga bytes')
### Value in multi option
.. FIXME undefined
For multi option, just modify a little bit the previous example.
The user can, now, set multiple path.
First of all, we have to modification in this option:
- add multi attribute to True
- the function use in validation valid a single value, so each value in the list must be validate separatly, for that we add whole attribute to False in `ParamSelfOption` object
.. literalinclude:: ../src/api_value_multi.py
:lines: 23-25
:linenos:
Secondly, the function calc_disk_usage must return a list:
.. literalinclude:: ../src/api_value_multi.py
:lines: 11-26
:linenos:
Finally `usage` option is also a multi:
.. literalinclude:: ../src/api_value_multi.py
:lines: 27-30
:linenos:
:download:`download the config <../src/api_value_multi.py>`
#### Get or set a multi value
Since the options are multi, the default value is a list:
>>> config.option('disk.path').value.get()
[]
>>> config.option('disk.usage').value.get()
[]
A multi option waiting for a list:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').value.get()
['/', '/tmp']
>>> config.option('disk.usage').value.get()
[668499898368.0, 8279277568.0]
#### The ownership of multi option
There is no difference in behavior between a simple option and a multi option:
>>> config.option('disk.path').value.reset()
>>> config.option('disk.path').owner.isdefault()
True
>>> config.option('disk.path').owner.get()
default
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').owner.get()
user
### Leadership
In previous example, we cannot define different `size_type` for each path. If you want do this, you need a leadership.
In this case, each time we add a path, we can change an associate `size_type`.
As each value of followers are isolate, the function `calc_disk_usage` will receive only one path and one size.
So let's change this function:
.. literalinclude:: ../src/api_value_leader.py
:lines: 12-18
:linenos:
Secondly the option `size_type` became a multi:
.. literalinclude:: ../src/api_value_leader.py
:lines: 24-25
:linenos:
Finally disk has to be a leadership:
.. literalinclude:: ../src/api_value_leader.py
:lines: 30
:linenos:
#### Get and set a leader
A leader is, in fact, a multi option:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').value.get()
['/', '/tmp']
There is two differences:
- we can get the leader length:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').value.len()
2
- we cannot reduce by assignation a leader:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> from tiramisu.error import LeadershipError
>>> try:
... config.option('disk.path').value.set(['/'])
... except LeadershipError as err:
... print(err)
cannot reduce length of the leader "Path"
We cannot reduce a leader because Tiramisu cannot determine which isolate follower we have to remove, this first one or the second one?
To reduce use the `pop` method:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').value.pop(1)
>>> config.option('disk.path').value.get()
['/']
#### Get and set a follower
As followers are isolate, we cannot get all the follower values:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> from tiramisu.error import APIError
>>> try:
... config.option('disk.size_type').value.get()
... except APIError as err:
... print(err)
index must be set with the follower option "Size type"
Index is mandatory:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.size_type', 0).value.get()
bytes
>>> config.option('disk.size_type', 1).value.get()
bytes
It's the same thing during the assignment:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.size_type', 0).value.set('giga bytes')
As the leader, follower has a length (in fact, this is the leader's length):
>>> config.option('disk.size_type').value.len()
2
#### The ownership of a leader and follower
There is no differences between a multi option and a leader option:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.path').owner.get()
user
For follower, it's different, always because followers are isolate:
>>> config.option('disk.size_type', 0).value.set('giga bytes')
>>> config.option('disk.size_type', 0).owner.isdefault()
False
>>> config.option('disk.size_type', 0).owner.get()
user
>>> config.option('disk.size_type', 1).owner.isdefault()
True
>>> config.option('disk.size_type', 1).owner.get()
default
## Values in option description
With an option description we can have directly a dict with all option's name and value:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.size_type', 0).value.set('giga bytes')
>>> config.option('disk').value.dict()
{'path': ['/', '/tmp'], 'size_type': ['giga bytes', 'bytes'], 'usage': [622.578239440918, 8279273472.0]}
An attribute fullpath permit to have fullpath of child option:
>>> config.option('disk').value.dict(fullpath=True)
{'disk.path': ['/', '/tmp'], 'disk.size_type': ['giga bytes', 'bytes'], 'disk.usage': [622.578239440918, 8279273472.0]}
## Values in config
###dict
With the `config` we can have directly a dict with all option's name and value:
>>> config.option('disk.path').value.set(['/', '/tmp'])
>>> config.option('disk.size_type', 0).value.set('giga bytes')
>>> config.value.dict()
{'disk.path': ['/', '/tmp'], 'disk.size_type': ['giga bytes', 'bytes'], 'disk.usage': [622.578239440918, 8279273472.0]}
If you don't wan't path but only the name:
>>> config.value.dict(flatten=True)
{'path': ['/', '/tmp'], 'size_type': ['giga bytes', 'bytes'], 'usage': [622.578239440918, 8279273472.0]}
### importation/exportation
In config, we can export full values:
>>> config.value.exportation()
[['disk.path', 'disk.size_type'], [None, [0]], [['/', '/tmp'], ['giga bytes']], ['user', ['user']]]
and reimport it later:
>>> export = config.value.exportation()
>>> config.value.importation(export)
.. note:: The exportation format is not stable and can be change later, please do not use importation otherwise than jointly with exportation.

350
doc/browse.md Normal file
View file

@ -0,0 +1,350 @@
# Browse the Config
## Getting the options
Create a simple Config:
```python
from asyncio import run
from tiramisu import Config
from tiramisu import StrOption, OptionDescription
# let's declare some options
var1 = StrOption('var1', 'first option')
# an option with a default value
var2 = StrOption('var2', 'second option', 'value')
# let's create a group of options
od1 = OptionDescription('od1', 'first OD', [var1, var2])
# let's create another group of options
rootod = OptionDescription('rootod', '', [od1])
async def main():
# let's create the config
cfg = await Config(rootod)
# the api is read only
await cfg.property.read_only()
# the read_write api is available
await cfg.property.read_write()
return cfg
cfg = run(main())
```
We retrieve by path an option named "var1" and then we retrieve its name and its docstring:
```python
async def main():
print(await cfg.option('od1.var1').option.name())
print(await cfg.option('od1.var1').option.doc())
run(main())
```
returns:
```
var1
first option
```
## Accessing the values of the options
Let's browse the configuration structure and option values.
You have getters as a "get" method on option objects:
1. getting all the options
```python
async def main():
print(await cfg.value.dict())
run(main())
```
returns:
```
{'var1': None, 'var2': 'value'}
```
2. getting the "od1" option description
```python
async def main():
print(await cfg.option('od1').value.dict())
run(main())
```
returns:
```
{'od1.var1': None, 'od1.var2': 'value'}
```
3. getting the var1 option's value
```python
async def main():
print(await cfg.option('od1.var1').value.get())
run(main())
```
returns:
```
None
```
4. getting the var2 option's default value
```python
async def main():
print(await cfg.option('od1.var2').value.get())
run(main())
```
returns:
```
value
```
5. trying to get a non existent option's value
```python
async def main():
try:
await cfg.option('od1.idontexist').value.get()
except AttributeError as err:
print(str(err))
run(main())
```
returns:
```
unknown option "idontexist" in optiondescription "first OD"
```
## Setting the value of an option
An important part of the setting's configuration consists of setting the
value's option.
You have setters as a "set" method on option objects.
And if you wanna come back to a default value, use the "reset()" method.
1. changing the "od1.var1" value
```python
async def main():
await cfg.option('od1.var1').value.set('éééé')
print(await cfg.option('od1.var1').value.get())
run(main())
```
returns:
```
éééé
```
2. carefull to the type of the value to be set
```python
async def main():
try:
await cfg.option('od1.var1').value.set(23454)
except ValueError as err:
print(str(err))
run(main())
```
returns:
```
"23454" is an invalid string for "first option"
```
3. let's come back to the default value
```python
async def main():
await cfg.option('od1.var2').value.reset()
print(await cfg.option('od1.var2').value.get())
run(main())
```
returns:
```
value
```
> **_Important_** If the config is "read only", setting an option's value isn't allowed, see [property](property.md).
Let's make the protocol of accessing a Config's option explicit
(because explicit is better than implicit):
1. If the option has not been declared, an "Error" is raised,
2. If an option is declared, but neither a value nor a default value has
been set, the returned value is "None",
3. If an option is declared and a default value has been set, but no value
has been set, the returned value is the default value of the option,
4. If an option is declared, and a value has been set, the returned value is
the value of the option.
But there are special exceptions. We will see later on that an option can be a
mandatory option. A mandatory option is an option that must have a value
defined.
Searching for an option
~~~~~~~~~~~~~~~~~~~~~~~~~~
In an application, knowing the path of an option is not always feasible.
That's why a tree of options can easily be searched with the "find()" method.
```python
from asyncio import run
from tiramisu import Config
from tiramisu import OptionDescription, StrOption
from tiramisu.setting import undefined
var1 = StrOption('var1', '')
var2 = StrOption('var2', '')
var3 = StrOption('var3', '')
od1 = OptionDescription('od1', '', [var1, var2, var3])
var4 = StrOption('var4', '')
var5 = StrOption('var5', '')
var6 = StrOption('var6', '')
var7 = StrOption('var1', '', 'value')
od2 = OptionDescription('od2', '', [var4, var5, var6, var7])
rootod = OptionDescription('rootod', '', [od1, od2])
```
Let's find an option by it's name
And let's find first an option by it's name
The search can be performed in a subtree
```python
async def main():
cfg = await Config(rootod)
print(await cfg.option.find(name='var1'))
run(main())
```
returns:
```
[<tiramisu.api.TiramisuOption object at 0x7f490a530f98>, <tiramisu.api.TiramisuOption object at 0x7f490a530748>]
```
If the option name is unique, the search can be stopped once one matched option has been found:
```python
async def main():
cfg = await Config(rootod)
print(await cfg.option.find(name='var1', first=True))
run(main())
```
returns:
```
<tiramisu.api.TiramisuOption object at 0x7ff27fc93c70>
```
Search object behaves like a cfg object, for example:
```python
async def main():
cfg = await Config(rootod)
option = await cfg.option.find(name='var1', first=True)
print(await option.option.name())
print(await option.option.doc())
run(main())
```
returns:
```
var1
var1
```
Search can be made with various criteria:
```python
async def main():
cfg = await Config(rootod)
await cfg.option.find(name='var3', value=undefined)
await cfg.option.find(name='var3', type=StrOption)
run(main())
```
The find method can be used in subconfigs:
```python
async def main():
cfg = await Config(rootod)
print(await cfg.option('od2').find('var1'))
run(main())
```
## The "dict" flattening utility
In a config or a subconfig, you can print a dict-like representation
In a "fullpath" or a "flatten" way
- get the "od1" option description:
```python
async def main():
cfg = await Config(rootod)
print(await cfg.option('od1').value.dict(fullpath=True))
run(main())
```
returns:
```
{'od1.var1': None, 'od1.var2': None, 'od1.var3': None}
```
```python
async def main():
cfg = await Config(rootod)
print(await cfg.option('od1').value.dict(fullpath=False))
run(main())
>>> print(cfg.option('od1').value.dict(fullpath=True))
```
returns:
```
{'var1': None, 'var2': None, 'var3': None}
```
> **_NOTE_** be carefull with this "flatten" parameter, because we can just loose some options if there are same name (some option can be overriden).

107
doc/config.md Normal file
View file

@ -0,0 +1,107 @@
# The Config
Tiramisu is made of almost three main classes/concepts :
- the "Option" stands for the option types
- the "OptionDescription" is the schema, the option's structure
- the "Config" which is the whole configuration entry point
![The Config](config.png "The Config")
## The handling of options
The handling of options is split into two parts: the description of
which options are available, what their possible values and defaults are
and how they are organized into a tree. A specific choice of options is
bundled into a configuration object which has a reference to its option
description (and therefore makes sure that the configuration values
adhere to the option description).
- [Instanciate an option](option.md)
- [Default Options](options.md)
- [The symbolic link option: SymLinkOption](symlinkoption.md)
- [Create it's own option](own_option.md)
## Option description are nested Options
The Option (in this case the "BoolOption"),
are organized into a tree into nested "OptionDescription" objects.
Every option has a name, as does every option group.
- [Generic container: OptionDescription](optiondescription.md)
- [Dynamic option description: DynOptionDescription](dynoptiondescription.md)
- [Leadership OptionDescription: Leadership](leadership.md)
## Config
Getting started with the tiramisu library (it loads and prints properly).
Let's perform a *Getting started* code review :
```python
from asyncio import run
from tiramisu import Config
from tiramisu import OptionDescription, BoolOption
# let's create a group of options named "optgroup"
descr = OptionDescription("optgroup", "", [
# ... with only one option inside
BoolOption("bool", "", default=False)
])
async def main():
# Then, we make a Config with the OptionDescription` we
cfg = await Config(descr)
# the global help about the config
cfg.help()
run(main())
```
returns:
```
Root config object that enables us to handle the configuration options
Settings:
forcepermissive Access to option without verifying permissive properties
unrestraint Access to option without property restriction
Commands:
cache Manage config cache
config Actions to Config
information Manage config informations
option Select an option
owner Global owner
permissive Manage config permissives
property Manage config properties
session Manage Config session
value Manage config value
```
Then let's print our "Option details.
```python
cfg.option.help()
```
returns:
```
Select an option
Call: Select an option by path
Commands:
dict Convert config and option to tiramisu format
find Find an or a list of options
list List options (by default list only option)
updates Updates value with tiramisu format
```
## Go futher with "Option" and "Config"
- [property](property.md)
- [validator](validator.md)

BIN
doc/config.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View file

@ -0,0 +1,57 @@
# Dynamic option description: DynOptionDescription
## Dynamic option description's description
Dynamic option description is an OptionDescription which multiplies according to the return of a function.
First of all, an option description is a name, a description, children and suffixes.
### name
The "name" is important to retrieve this dynamic option description.
### description
The "description" allows the user to understand where this dynamic option description will contains.
### children
List of children option.
> **_NOTE:_** the option has to be multi option or leadership but not option description.
### suffixes
Suffixes is a [calculation](calculation.md) that return the list of suffixes used to create dynamic option description.
Let's try:
```python
from tiramisu import StrOption, DynOptionDescription, Calculation
def return_suffixes():
return ['1', '2']
child1 = StrOption('first', 'First basic option ')
child2 = StrOption('second', 'Second basic option ')
DynOptionDescription('basic ',
'Basic options ',
[child1, child2],
Calculation(return_suffixes))
```
This example will construct:
- Basic options 1:
- First basic option 1
- Second basic option 1
- Basic options 2:
- First basic option 2
- Second basic option 2
## Dynamic option description's properties
See [property](property.md).

42
doc/gettingstarted.md Normal file
View file

@ -0,0 +1,42 @@
# Getting started
## What is options handling ?
Due to more and more available options required to set up an operating system,
compiler options or whatever, it became quite annoying to hand the necessary
options to where they are actually used and even more annoying to add new
options.
To circumvent these problems the configuration control was introduced.
## What is Tiramisu ?
Tiramisu is an options handler and an options controller, which aims at
producing flexible and fast options access. The main advantages are its access
rules and the fact that the whole consistency is preserved at any time.
There is of course type and structure validations, but also
validations towards the whole options. Furthermore, options can be reached and
changed according to the access rules from nearly everywhere.
### Installation
The best way is to use the python [pip](https://pip.pypa.io/en/stable/installing/) installer
And then type:
```bash
$ pip install tiramisu
```
### Advanced users
To obtain a copy of the sources, check it out from the repository using `git`.
We suggest using `git` if one wants to access to the current developments.
```bash
$ git clone https://framagit.org/tiramisu/tiramisu.git
```
This will get you a fresh checkout of the code repository in a local directory
named "tiramisu".

45
doc/leadership.md Normal file
View file

@ -0,0 +1,45 @@
# Leadership OptionDescription: Leadership
A leadership is a special "OptionDescription" that wait a leader and one or multiple followers.
Leader and follower are multi option. The difference is that the length is defined by the length of the option leader.
If the length of leader is 3, all followers have also length 3.
An other different is that the follower is isolate. That means that you can only change on value on a specified index in the list of it's values.
If a value is mark as modified in a specified index, that not affect the other values in other index.
## The leadership's description
A leadership is an "OptionDescription"
First of all, an option leadership is a name, a description and children.
### name
The "name" is important to retrieve this dynamic option description.
### description
The "description" allows the user to understand where this dynamic option description will contains.
### children
List of children option.
> **_NOTE:_** the option has to be multi or submulti option and not other option description.
Let's try:
```python
from tiramisu import StrOption, Leadership
users = StrOption('users', 'User', multi=True)
passwords = StrOption('passwords', 'Password', multi=True)
Leadership('users',
'User allow to connect',
[users, passwords])
```
## The leadership's properties
See [property](property.md).

134
doc/option.md Normal file
View file

@ -0,0 +1,134 @@
# Instanciate an option
## Option's description
First of all, an option is a name and a description.
### name
The "name" is important to retrieve this option.
### description
The "description" allows the user to understand where this option will be used for.
Let's try:
```python
from tiramisu import StrOption
StrOption('welcome',
'Welcome message to the user login')
```
## Option's default value
For each option, we can defined a default value. This value will be the value of this option until user customize it.
This default value is store directly in the option. So we can, at any moment we can go back to the default value.
```python
StrOption('welcome',
'Welcome message to the user login',
'Hey guys, welcome here!')
```
The default value can be a calculation.
```python
from tiramisu import Calculation
def get_value():
return 'Hey guys, welcome here'
StrOption('welcome',
'Welcome message to the user login',
Calculation(get_value))
```
## Option with multiple value
### multi
There are cases where it can be interesting to have a list of values rather than just one.
The "multi" attribut is here for that.
In this case, the default value has to be a list:
```python
StrOption('shopping_list',
'The shopping list',
['1 kilogram of carrots', 'leeks', '1 kilogram of potatos'],
multi=True)
```
The option could be a list of list, which is could submulti:
```python
from tiramisu import submulti
StrOption('shopping_list',
'The shopping list',
[['1 kilogram of carrots', 'leeks', '1 kilogram of potatos'], ['milk', 'eggs']],
multi=submulti)
```
The default value can be a calculation. For a multi, the function have to return a list or have to be in a list:
```python
def get_values():
return ['1 kilogram of carrots', 'leeks', '1 kilogram of potatos']
StrOption('shopping_list',
'The shopping list',
Calculation(get_values),
multi=True)
```
```python
def get_a_value():
return 'leeks'
StrOption('shopping_list',
'The shopping list',
['1 kilogram of carrots', Calculation(get_a_value), '1 kilogram of potatos'],
multi=True)
```
### default_multi
A second default value is available for multi option, "default_multi". This value is used when we add new value without specified a value.
This "default_multi" must not be a list in multi purpose. For submulti, it has to be a list:
```python
StrOption('shopping_list',
'The shopping list',
['1 kilogram of carrots', 'leeks', '1 kilogram of potatos'],
default_multi='some vegetables',
multi=True)
StrOption('shopping_list',
'The shopping list',
[['1 kilogram of carrots', 'leeks', '1 kilogram of potatos'], ['milk', 'eggs']],
default_multi=['some', 'vegetables'],
multi=submulti)
```
The default_multi value can be a calculation:
```python
def get_a_value():
return 'some vegetables'
StrOption('shopping_list',
'The shopping list',
['1 kilogram of carrots', 'leeks', '1 kilogram of potatos'],
default_multi=Calculation(get_a_value),
multi=True)
```
## Other option's parameters
There are two other parameters.
We will see them later:
- [Property](property.md)
- [Validator](validator.md)

35
doc/optiondescription.md Normal file
View file

@ -0,0 +1,35 @@
# Generic container: OptionDescription
## Option description's description
First of all, an option description is a name, a description and children.
### name
The "name" is important to retrieve this option description.
### description
The "description" allows the user to understand where this option description will contains.
### children
List of children option.
> **_NOTE:_** the option can be an option or an other option description
Let's try:
```python
from tiramisu import StrOption, OptionDescription
child1 = StrOption('first', 'First basic option')
child2 = StrOption('second', 'Second basic option')
OptionDescription('basic',
'Basic options',
[child1, child2])
```
## Option description's properties
See [property](property.md).

485
doc/options.md Normal file
View file

@ -0,0 +1,485 @@
# Default Options
Basic options
## Textual option: StrOption
Option that accept any textual data in Tiramisu:
```python
from tiramisu import StrOption
StrOption('str', 'str', 'value')
StrOption('str', 'str', '1')
```
Other type generate an error:
```python
try:
StrOption('str', 'str', 1)
except ValueError as err:
print(err)
```
returns:
```
"1" is an invalid string for "str"
```
## Integers option: IntOption
Option that accept any integers number in Tiramisu:
```python
from tiramisu import IntOption
IntOption('int', 'int', 1)
```
### min_number and max_number
This option can also verify minimal and maximal number:
```python
IntOption('int', 'int', 10, min_number=10, max_number=15)
```
```python
try:
IntOption('int', 'int', 16, max_number=15)
except ValueError as err:
print(err)
```
returns:
```
"16" is an invalid integer for "int", value must be less than "15"
```
> **_NOTE:_** If "warnings_only" parameter it set to True, it will only emit a warning.
## Floating point number option: FloatOption
Option that accept any floating point number in Tiramisu:
```python
from tiramisu import FloatOption
FloatOption('float', 'float', 10.1)
```
## Boolean option: BoolOption
Boolean values are the two constant objects False and True:
```python
from tiramisu import BoolOption
BoolOption('bool', 'bool', True)
BoolOption('bool', 'bool', False)
```
## Choice option: ChoiceOption
Option that only accepts a list of possible choices.
For example, we just want allowed 1 or 'see later':
```python
from tiramisu import ChoiceOption
ChoiceOption('choice', 'choice', (1, 'see later'), 1)
ChoiceOption('choice', 'choice', (1, 'see later'), 'see later')
```
Any other value isn't allowed:
```python
try:
ChoiceOption('choice', 'choice', (1, 'see later'), "i don't know")
except ValueError as err:
print(err)
```
returns:
```
"i don't know" is an invalid choice for "choice", only "1" and "see later" are allowed
```
# Network options
## IPv4 address option: IPOption
An Internet Protocol address (IP address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.
This option only support version 4 of the Internet Protocol.
```python
from tiramisu import IPOption
IPOption('ip', 'ip', '192.168.0.24')
```
### private_only
By default IP could be a private or a public address. It's possible to restrict to only private IPv4 address with "private_only" attributs:
```python
try:
IPOption('ip', 'ip', '1.1.1.1', private_only=True)
except ValueError as err:
print(err)
```
returns:
```
"1.1.1.1" is an invalid IP for "ip", must be private IP
```
> **_NOTE:_** If "warnings_only" parameter it set to True, it will only emit a warning.
### allow_reserved
By default, IETF reserved are not allowed. The "allow_reserved" can be used to allow this address:
```python
try:
IPOption('ip', 'ip', '255.255.255.255')
except ValueError as err:
print(err)
```
returns:
```
"255.255.255.255" is an invalid IP for "ip", mustn't be reserved IP
```
But this doesn't raises:
```python
IPOption('ip', 'ip', '255.255.255.255', allow_reserved=True)
```
> **_NOTE:_** If "warnings_only" parameter it set to True, it will only emit a warning.
### cidr
Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and IP routing.
CIDR notation, in which an address or routing prefix is written with a suffix indicating the number of bits of the prefix, such as 192.168.0.1/24.
```python
IPOption('ip', 'ip', '192.168.0.1/24', cidr=True)
try:
IPOption('ip', 'ip', '192.168.0.0/24', cidr=True)
except ValueError as err:
print(err)
```
returns:
```
"192.168.0.0/24" is an invalid IP for "ip", it's in fact a network address
```
## Port option: PortOption
A port is a network communication endpoint.
A port is a string object:
```python
from tiramisu import PortOption
PortOption('port', 'port', '80')
```
### allow_range
A range is a list of port where we specified first port and last port number. The separator is ":":
```python
PortOption('port', 'port', '2000', allow_range=True)
PortOption('port', 'port', '2000:3000', allow_range=True)
```
### allow_zero
By default, port 0 is not allowed, if you want allow it, use the parameter "allow_zero":
```python
try:
PortOption('port', 'port', '0')
except ValueError as err:
print(err)
```
returns:
```python
"0" is an invalid port for "port", must be between 1 and 49151
```
But this doesn't raises:
```python
PortOption('port', 'port', '0', allow_zero=True)
```
> **_NOTE:_** This option affect the minimal and maximal port number, if "warnings_only" parameter it set to True, it will only emit a warning.
### allow_wellknown
The well-known ports (also known as system ports) are those from 1 through 1023. This parameter is set to True by default:
```python
PortOption('port', 'port', '80')
```
```python
try:
PortOption('port', 'port', '80', allow_wellknown=False)
except ValueError as err:
print(err)
```
returns:
```
"80" is an invalid port for "port", must be between 1024 and 49151
```
> **_NOTE:_** This option affect the minimal and maximal port number, if "warnings_only" parameter it set to True, it will only emit a warning.
### allow_registred
The registered ports are those from 1024 through 49151. This parameter is set to True by default:
```python
PortOption('port', 'port', '1300')
```
```python
try:
PortOption('port', 'port', '1300', allow_registred=False)
except ValueError as err:
print(err)
```
returns:
```
"1300" is an invalid port for "port", must be between 1 and 1023
```
> **_NOTE:_** This option affect the minimal and maximal port number, if "warnings_only" parameter it set to True, it will only emit a warning.
### allow_protocol
```python
PortOption('port', 'port', '1300', allow_protocol="True")
PortOption('port', 'port', 'tcp:1300', allow_protocol="True")
PortOption('port', 'port', 'udp:1300', allow_protocol="True")
```
### allow_private
The dynamic or private ports are those from 49152 through 65535. One common use for this range is for ephemeral ports. This parameter is set to False by default:
```python
try:
PortOption('port', 'port', '64000')
except ValueError as err:
print(err)
```
returns:
```
"64000" is an invalid port for "port", must be between 1 and 49151
```
```python
PortOption('port', 'port', '64000', allow_private=True)
```
> **_NOTE:_** This option affect the minimal and maximal port number, if "warnings_only" parameter it set to True, it will only emit a warning.
## Subnetwork option: NetworkOption
IP networks may be divided into subnetworks:
```python
from tiramisu import NetworkOption
NetworkOption('net', 'net', '192.168.0.0')
```
### cidr
Classless Inter-Domain Routing (CIDR) is a method for allocating IP addresses and IP routing.
CIDR notation, in which an address or routing prefix is written with a suffix indicating the number of bits of the prefix, such as 192.168.0.0/24:
```python
NetworkOption('net', 'net', '192.168.0.0/24', cidr=True)
```
## Subnetwork mask option: NetmaskOption
For IPv4, a network may also be characterized by its subnet mask or netmask. This option allow you to enter a netmask:
```python
from tiramisu import NetmaskOption
NetmaskOption('mask', 'mask', '255.255.255.0')
```
## Broadcast option: BroadcastOption
The last address within a network broadcast transmission to all hosts on the link. This option allow you to enter a broadcast:
```python
from tiramisu import BroadcastOption
BroadcastOption('bcast', 'bcast', '192.168.0.254')
```
# Internet options
## Domain name option: DomainnameOption
Domain names are used in various networking contexts and for application-specific naming and addressing purposes.
The DomainnameOption allow different type of domain name:
```python
from tiramisu import DomainnameOption
DomainnameOption('domain', 'domain', 'foo.example.net')
DomainnameOption('domain', 'domain', 'foo', type='hostname')
```
### type
There is three type for a domain name:
- "domainname" (default): lowercase, number, "-" and "." characters are allowed, this must have at least one "."
- "hostname": lowercase, number and "-" characters are allowed, the maximum length is 63 characters
- "netbios": lowercase, number and "-" characters are allowed, the maximum length is 15 characters
> **_NOTE:_** If "warnings_only" parameter it set to True, it will raise if length is incorrect by only emit a warning character is not correct.
### allow_ip
If the option can contain a domain name or an IP, you can set the "allow_ip" to True, (False by default):
```python
DomainnameOption('domain', 'domain', 'foo.example.net', allow_ip=True)
DomainnameOption('domain', 'domain', '192.168.0.1', allow_ip=True)
```
In this case, IP is validate has IPOption would do.
### allow_cidr_network
If the option can contain a CIDR network, you can set "allow_cidr_network" to True, (False by default):
```python
DomainnameOption('domain', 'domain', 'foo.example.net', allow_cidr_network=True)
DomainnameOption('domain', 'domain', '192.168.0.0/24', allow_cidr_network=True)
```
### allow_without_dot
A domain name with domainname's type must have a dot. If "allow_without_dot" is True (False by default), we can set a domainname or an hostname:
```python
DomainnameOption('domain', 'domain', 'foo.example.net', allow_without_dot=True)
DomainnameOption('domain', 'domain', 'foo', allow_without_dot=True)
```
### allow_startswith_dot
A domain name with domainname's type mustn't start by a dot. .example.net is not a valid domain. In some case it could be interesting to allow domain name starts by a dot (for ACL in Squid, no proxy option in Firefox, ...):
```python
DomainnameOption('domain', 'domain', 'example.net', allow_startswith_dot=True)
DomainnameOption('domain', 'domain', '.example.net', allow_startswith_dot=True)
```
## MAC address option: MACOption
Validate MAC address:
```python
from tiramisu import MACOption
MACOption('mac', 'mac', '01:10:20:20:10:30')
```
## Uniform Resource Locator option: UrlOption
An Uniform Resource Locator is, in fact, a string starting with http:// or https://, a DomainnameOption, optionaly ':' and a PortOption, and finally filename:
```python
from tiramisu import URLOption
URLOption('url', 'url', 'http://foo.example.fr/index.php')
URLOption('url', 'url', 'https://foo.example.fr:4200/index.php?login=foo&pass=bar')
```
For parameters, see PortOption and DomainnameOption.
## Email address option: EmailOption
Electronic mail (email or e-mail) is a method of exchanging messages ("mail") between people using electronic devices. Here an example:
```python
from tiramisu import EmailOption
EmailOption('mail', 'mail', 'foo@example.net')
```
# Unix options
## Unix username: UsernameOption
An unix username option is a 32 characters maximum length with lowercase ASCII characters, number, '_' or '-'. The username have to start with lowercase ASCII characters or "_":
```python
from tiramisu import UsernameOption
UsernameOption('user', 'user', 'my_user')
```
## Unix groupname: GroupnameOption
Same condition for unix group name:
```python
from tiramisu import GroupnameOption
GroupnameOption('group', 'group', 'my_group')
```
## Password option: PasswordOption
Simple string with no other restriction:
```python
from tiramisu import PasswordOption
PasswordOption('pass', 'pass', 'oP$¨1jiJie')
```
## Unix filename option: FilenameOption
For this option, only lowercase and uppercas ASCII character, "-", ".", "_", "~", and "/" are allowed:
```python
from tiramisu import FilenameOption
FilenameOption('file', 'file', '/etc/tiramisu/tiramisu.conf')
```
# Date option
## Date option: DateOption
Date option waits for a date with format YYYY-MM-DD:
```python
from tiramisu import DateOption
DateOption('date', 'date', '2019-10-30')
```

183
doc/own_option.md Normal file
View file

@ -0,0 +1,183 @@
# Create it's own option
## Generic regexp option: "RegexpOption"
Use "RegexpOption" to create custom option is very simple.
You just have to create an object that inherits from "RegexpOption" and that has the following class attributes:
- \_\_slots\_\_: with new data members (the values should always be "tuple()")
- \_type = with a name
- \_display_name: with the display name (for example in error message)
- \_regexp: with a compiled regexp
Here an example to an option that only accept string with on lowercase ASCII vowel characters:
```python
import re
from tiramisu import RegexpOption
class VowelOption(RegexpOption):
__slots__ = tuple()
_type = 'vowel'
_display_name = "string with vowel"
_regexp = re.compile(r"^[aeiouy]*$")
```
Let's try our object:
```python
VowelOption('vowel', 'Vowel', 'aae')
```
```python
try:
VowelOption('vowel', 'Vowel', 'oooups')
except ValueError as err:
print(err)
```
returns:
```python
"oooups" is an invalid string with vowel for "Vowel"
```
## Create a custom option
An option always inherits from "Option" object. This object has the following class attributes:
- \_\_slots\_\_: a tuple with new data members (by default you should set "tuple()")
- \_type = with a name
- \_display_name: with the display name (for example in error message)
Here an example to an lipogram option:
```python
from tiramisu import Option
from tiramisu.error import ValueWarning
import warnings
class LipogramOption(Option):
__slots__ = tuple()
_type = 'lipogram'
_display_name = 'lipogram'
#
# First of all we want to add a custom parameter to ask the minimum length (min_len) of the value:
def __init__(self,
*args,
min_len=100,
**kwargs):
# store extra parameters
extra = {'_min_len': min_len}
super().__init__(*args,
extra=extra,
**kwargs)
#
# We have a first validation method.
# In this method, we verify that the value is a string and that there is no "e" on it:
# Even if user set warnings_only attribute, this method will raise.
def validate(self,
value):
# first, valid that the value is a string
if not isinstance(value, str):
raise ValueError('invalid string')
# and verify that there is any 'e' in the sentense
if 'e' in value:
raise ValueError('Perec wrote a book without any "e", you could not do it in a simple sentence?')
#
# Finally we add a method to valid the value length.
# If "warnings_only" is set to True, a warning will be emit:
def second_level_validation(self,
value,
warnings_only):
# retrive parameter in extra
min_len = self.impl_get_extra('_min_len')
# verify the sentense length
if len(value) < min_len:
# raise message, in this case, warning and error message are different
if warnings_only:
msg = f'it would be better to have at least {min_len} characters in the sentence'
else:
msg = f'you must have at least {min_len} characters in the sentence'
raise ValueError(msg)
```
Let's test it:
1. the character "e" is in the value:
```python
try:
LipogramOption('lipo',
'Lipogram',
'I just want to add a quality string that has no bad characters')
except ValueError as err:
print(err)
```
returns:
```
"I just want to add a quality string that has no bad characters" is an invalid lipogram for "Lipogram", Perec wrote a book without any "e", you could not do it in a simple sentence?
```
2. the character "e" is in the value and warnings_only is set to True:
```python
try:
LipogramOption('lipo',
'Lipogram',
'I just want to add a quality string that has no bad characters',
warnings_only=True)
except ValueError as err:
print(err)
```
```
"I just want to add a quality string that has no bad characters" is an invalid lipogram for "Lipogram", Perec wrote a book without any "e", you could not do it in a simple sentence?
```
3. the value is too short
```python
try:
LipogramOption('lipo',
'Lipogram',
'I just want to add a quality string that has no bad symbols')
except ValueError as err:
print(err)
```
returns:
```
"I just want to add a quality string that has no bad symbols" is an invalid lipogram for "Lipogram", you must have at least 100 characters in the sentence
```
4. the value is too short and warnings_only is set to True:
```python
warnings.simplefilter('always', ValueWarning)
with warnings.catch_warnings(record=True) as warn:
LipogramOption('lipo',
'Lipogram',
'I just want to add a quality string that has no bad symbols',
warnings_only=True)
if warn:
print(warn[0].message)
```
returns:
```
attention, "I just want to add a quality string that has no bad symbols" could be an invalid lipogram for "Lipogram", it would be better to have at least 100 characters in the sentence
```
5. set minimum length to 50 characters, the value is valid:
```python
LipogramOption('lipo',
'Lipogram',
'I just want to add a quality string that has no bad symbols',
min_len=50)
```

109
doc/property.md Normal file
View file

@ -0,0 +1,109 @@
# Property
## What are properties ?
The properties are a central element of Tiramisu.
Properties change the behavior of an option or make it unavailable.
## Read only and read write
Config can be in two defaut mode:
### read_only
You can get all variables in a "Config" that not disabled.
Off course, as the Config is read only, you cannot set any value to any option.
Only value with :doc`calculation` can change value.
You cannot access to mandatory variable without values. Verify that all values is set before change mode.
### read_write
You can get all options not disabled and not hidden. You can also set all variables not frozen.
## Common properties
### hidden
Option with this property can only get value in read only mode.
This property is used for option that user cannot modifify it's value (for example if it's value is calculated).
### disabled
We never can access to option with this property.
### frozen
Options with this property cannot be modified.
## Special option properties
### mandatory
You should set value for option with this properties. In read only mode we cannot access to this option if no value is set.
### empty or notempty
Only used for multi option that are not a follower.
Mandatory for a multi means that you cannot add None as a value. But value [] is allowed. This is not permit with "empty" property.
A multi option has automaticly "empty" property. If you don't want allow empty option, just add "notempty" property when you create the option.
### unique or notunique
Only used for multi option that are not a follower.
Raise ValueError if a value is set twice or more in a multi Option.
A multi option has automaticly "unique" property. If you want allow duplication in option, just add "notunique" property when you create the option.
### permissive
Option with 'permissive' cannot raise PropertiesOptionError for properties set in permissive.
Config with 'permissive', whole option in this config cannot raise PropertiesOptionError for properties set in permissive.
## Special Config properties
### cache
Enable cache settings and values.
### expire
Enable settings and values in cache expire after "expiration_time" (by default 5 seconds).
### everything_frozen
Whole options in config are frozen (even if option have not frozen property).
### force_default_on_freeze
Whole options frozen in config will lost his value and use default values.
### force_metaconfig_on_freeze
Whole options frozen in config will lost his value and get MetaConfig values.
### force_store_value
All options with this properties will be mark has modified.
### validator
Launch validator set by user in option (this property has no effect for option validation and second level validation).
### warnings
Display warnings during validation.
### demoting_error_warning
All value's errors are convert to warning (ValueErrorWarning).
## Own properties
There are no specific instructions for creating a property. Just add a string as property create a new property.

13
doc/symlinkoption.md Normal file
View file

@ -0,0 +1,13 @@
# The symbolic link option: SymLinkOption
A "SymLinkOption" is an option that actually points to another option.
Each time we will access to a properties of this options, we will have in return the value of other option.
Creation a "SymLinkOption" is easy:
```python
from tiramisu import StrOption, SymLinkOption
st = StrOption('str', 'str')
sym = SymLinkOption('sym', st)
```

494
doc/validator.md Normal file
View file

@ -0,0 +1,494 @@
# Validator
## What are validator ?
Validator is a functionnality that allow you to call a function to determine if an option is valid.
To define validator we have to use [calculation](calculation.md) object.
The function have to raise a "ValueError" object if the value is not valid. It could emit a warning when raises a "ValueWarning".
## Validator with options
Here an example, where we want to ask a new password to an user. This password should not be weak. The password will be asked twice and must match.
First of all, import necessary object:
```python
from asyncio import run
import warnings
from re import match
from tiramisu import StrOption, IntOption, OptionDescription, Config, \
Calculation, Params, ParamOption, ParamSelfOption, ParamValue
from tiramisu.error import ValueWarning
```
Create a first function to valid that the password is not weak:
```python
def is_password_conform(password):
# password must containe at least a number, a lowercase letter, an uppercase letter and a symbol
if not match(r'(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)', password):
raise ValueError('please choose a stronger password, try a mix of letters, numbers and symbols')
```
Secondly create a function to valid password length. The password must be longer than the value of "min_len" and should be longer than the value of "recommand_len".
In first case, function raise "ValueError", this value is incorrect.
In second case, function raise "ValueWarning", the value is valid but discouraged:
```python
def password_correct_len(min_len, recommand_len, password):
# password must have at least min_len characters
if len(password) < min_len:
raise ValueError(f'use {min_len} characters or more for your password')
# password should have at least recommand_len characters
if len(password) < recommand_len:
raise ValueWarning(f'it would be better to use more than {recommand_len} characters for your password')
```
Thirdly create a function that verify that the login name is not a part of password (password "foo2aZ$" if not valid for user "foo"):
```python
def user_not_in_password(login, password):
if login in password:
raise ValueError('the login must not be part of the password')
```
Now we can creation an option to ask user login:
```python
login = StrOption('login', 'Login', properties=('mandatory',))
```
Create a calculation to launch "is_password_conform". This function will be use in a new option and must validate this new option. So we use the object "ParamSelfOption" has parameter to retrieve the value of current option:
```python
calc1 = Calculation(is_password_conform,
Params(ParamSelfOption()))
```
Create a second calculation to launch "password_correct_len" function. We want set 8 as "min_len" value and 12 as "recommand_len" value:
```python
calc2 = Calculation(password_correct_len,
Params((ParamValue(8),
ParamValue(12),
ParamSelfOption())))
```
Create a third calculation to launch "user_not_in_password" function. For this function, we use keyword argument. This function normaly raise "ValueError" but in this case we want demoting this error as a simple warning. So we add "warnings_only" parameter:
```python
calc3 = Calculation(user_not_in_password,
Params(kwargs={'login': ParamOption(login),
'password': ParamSelfOption()}),
warnings_only=True)
```
So now we can create first password option that use those calculations:
```python
password1 = StrOption('password1',
'Password',
properties=('mandatory',),
validators=[calc1, calc2, calc3])
```
A new function is created to conform that password1 and password2 match:
```python
def password_match(password1, password2):
if password1 != password2:
raise ValueError("those passwords didn't match, try again")
```
And now we can create second password option that use this function:
```python
password2 = StrOption('password2',
'Confirm',
properties=('mandatory',),
validators=[Calculation(password_match, Params((ParamOption(password1), ParamSelfOption())))])
```
Finally we create optiondescription and config:
```python
od = OptionDescription('password', 'Define your password', [password1, password2])
root = OptionDescription('root', '', [login, od])
async def main():
config = await Config(root)
await config.property.read_write()
run(main())
```
Now we can test this "Config" with a tested password too weak:
```python
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
try:
await config.option('password.password1').value.set('aAbBc')
except ValueError as err:
print(f'Error: {err}')
run(main())
```
returns:
```
Error: "aAbBc" is an invalid string for "Password", please choose a stronger password, try a mix of letters, numbers and symbols
```
The password is part of error message. In this case it's a bad idea. So we have to remove "prefix" to the error message:
```python
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
try:
await config.option('password.password1').value.set('aAbBc')
except ValueError as err:
err.prefix = ''
print(f'Error: {err}')
run(main())
```
Now the error is:
```
Error: please choose a stronger password, try a mix of letters, numbers and symbols
```
Let's try with a password not weak but too short:
```python
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
try:
await config.option('password.password1').value.set('aZ$1')
except ValueError as err:
err.prefix = ''
print(f'Error: {err}')
run(main())
```
The error is:
```
Error: use 8 characters or more for your password
```
Now try a password with 8 characters:
```python
warnings.simplefilter('always', ValueWarning)
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
with warnings.catch_warnings(record=True) as warn:
await config.option('password.password1').value.set('aZ$1bN:2')
if warn:
warn[0].message.prefix = ''
print(f'Warning: {warn[0].message}')
password = await config.option('password.password1').value.get()
print(f'The password is "{password}"')
run(main())
```
Warning is display but password is store:
```
Warning: it would be better to use more than 12 characters for your password
The password is "aZ$1bN:2"
```
Try a password with the login as part of it:
```python
warnings.simplefilter('always', ValueWarning)
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
with warnings.catch_warnings(record=True) as warn:
await config.option('password.password1').value.set('aZ$1bN:2u@1Bjuser')
if warn:
warn[0].message.prefix = ''
print(f'Warning: {warn[0].message}')
password = await config.option('password.password1').value.get()
print(f'The password is "{password}"')
run(main())
```
Warning is display but password is store:
```
Warning: the login must not be part of the password
The password is "aZ$1bN:2u@1Bjuser"
```
Now try with a valid password but that doesn't match:
```python
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
await config.option('password.password1').value.set('aZ$1bN:2u@1Bj')
try:
await config.option('password.password2').value.set('aZ$1aaaa')
except ValueError as err:
err.prefix = ''
print(f'Error: {err}')
run(main())
```
An error is displayed:
```
Error: those passwords didn't match, try again
```
Finally try a valid password:
```python
async def main():
config = await Config(root)
await config.property.read_write()
await config.option('login').value.set('user')
await config.option('login').value.set('user')
await config.option('password.password1').value.set('aZ$1bN:2u@1Bj')
await config.option('password.password2').value.set('aZ$1bN:2u@1Bj')
await config.property.read_only()
user_login = await config.option('login').value.get()
password = await config.option('password.password2').value.get()
print(f'The password for "{user_login}" is "{password}"')
run(main())
```
As expected, we have:
```
The password for "user" is "aZ$1bN:2u@1Bj"
```
## Validator with a multi option
Assume we ask percentage value to an user. The sum of values mustn't be higher than 100% and shouldn't be lower than 100%.
Let's start by importing the objects:
```python
from asyncio import run
import warnings
from tiramisu import IntOption, OptionDescription, Config, \
Calculation, Params, ParamSelfOption
from tiramisu.error import ValueWarning
```
Continue by writing the validation function:
```python
def valid_pourcent(option):
total = sum(option)
if total > 100:
raise ValueError(f'the total {total}% is bigger than 100%')
if total < 100:
raise ValueWarning(f'the total {total}% is lower than 100%')
```
And create a simple option in a single OptionDescription:
```python
percent = IntOption('percent',
'Percent',
multi=True,
validators=[Calculation(valid_pourcent, Params(ParamSelfOption()))])
od = OptionDescription('root', 'root', [percent])
```
Now try with bigger sum:
```python
async def main():
config = await Config(od)
try:
await config.option('percent').value.set([20, 90])
except ValueError as err:
err.prefix = ''
print(f'Error: {err}')
percent_value = await config.option('percent').value.get()
print(f'The value is "{percent_value}"')
run(main())
```
The result is:
```
Error: the total 110% is bigger than 100%
The value is "[]"
```
Let's try with lower sum:
```python
async def main():
config = await Config(od)
warnings.simplefilter('always', ValueWarning)
with warnings.catch_warnings(record=True) as warn:
await config.option('percent').value.set([20, 70])
if warn:
warn[0].message.prefix = ''
print(f'Warning: {warn[0].message}')
percent_value = await config.option('percent').value.get()
print(f'The value is "{percent_value}"')
run(main())
```
The result is:
```
Warning: the total 90% is lower than 100%
The value is "[20, 70]"
```
Finally with correct value:
```python
async def main():
config = await Config(od)
await config.option('percent').value.set([20, 80])
percent_value = await config.option('percent').value.get()
print(f'The value is "{percent_value}"')
run(main())
```
The result is:
```
The value is "[20, 80]"
```
## Validator with a follower option
Assume we want distribute something to differents users. The sum of values mustn't be higher than 100%.
First, import all needed objects:
```python
from asyncio import run
import warnings
from tiramisu import StrOption, IntOption, Leadership, OptionDescription, Config, \
Calculation, Params, ParamSelfOption, ParamIndex
from tiramisu.error import ValueWarning
```
Let's start to write a function with three arguments:
- the first argument will have all values set for the follower
- the second argument will have only last value set for the follower
- the third argument will have the index
```python
def valid_pourcent(option, current_option, index):
if None in option:
return
total = sum(option)
if total > 100:
raise ValueError(f'the value {current_option} (at index {index}) is too big, the total is {total}%')
```
Continue by creating a calculation:
```python
calculation = Calculation(valid_pourcent, Params((ParamSelfOption(whole=True),
ParamSelfOption(),
ParamIndex())))
```
And instanciate differents option:
```python
user = StrOption('user', 'User', multi=True)
percent = IntOption('percent',
'Distribution',
multi=True,
validators=[calculation])
leader = Leadership('percent', 'Percent', [user, percent])
od = OptionDescription('root', 'root', [leader])
```
Add two values to the leader:
```python
async def main():
config = await Config(od)
await config.option('percent.user').value.set(['user1', 'user2'])
run(main())
```
The user user1 will have 20%:
```python
async def main():
config = await Config(od)
await config.option('percent.user').value.set(['user1', 'user2'])
await config.option('percent.percent', 0).value.set(20)
run(main())
```
If we try to set 90% to user2:
```python
async def main():
config = await Config(od)
await config.option('percent.user').value.set(['user1', 'user2'])
await config.option('percent.percent', 0).value.set(20)
try:
await config.option('percent.percent', 1).value.set(90)
except ValueError as err:
err.prefix = ''
print(f'Error: {err}')
run(main())
```
results:
```
Error: the value 90 (at index 1) is too big, the total is 110%
```
No problem with 80%:
```python
async def main():
config = await Config(od)
await config.option('percent.user').value.set(['user1', 'user2'])
await config.option('percent.percent', 0).value.set(20)
await config.option('percent.percent', 1).value.set(80)
run(main())
```

BIN
logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

140
logo.svg Normal file
View file

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="18.86796mm"
height="25.206835mm"
viewBox="0 0 18.867959 25.206835"
version="1.1"
id="svg5"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
sodipodi:docname="logo.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="4.404458"
inkscape:cx="1.3622562"
inkscape:cy="68.453372"
inkscape:window-width="1033"
inkscape:window-height="1080"
inkscape:window-x="26"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs2" />
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-78.220996,-39.872698)">
<text
xml:space="preserve"
style="font-size:2.52546px;line-height:1;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;stroke-width:0.631367"
x="93.453247"
y="48.8326"
id="text18049"><tspan
sodipodi:role="line"
id="tspan18047"
x="93.453247"
y="48.8326"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">I</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="51.358059"
id="tspan18051"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">R</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="53.883518"
id="tspan21745"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">A</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="56.408981"
id="tspan21747"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">M</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="58.934441"
id="tspan21749"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">I</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="61.4599"
id="tspan21751"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">S</tspan><tspan
sodipodi:role="line"
x="93.453247"
y="63.985359"
id="tspan21753"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:2.52546px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;stroke-width:0.631367">U</tspan></text>
<path
style="fill:#2a80af;fill-opacity:1;stroke:#000000;stroke-width:0.315683;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 81.95784,40.030698 13.710125,-1.58e-4 c 0.510538,0.02425 0.694831,0.0683 0.982497,0.311837 0.203261,0.250591 0.249844,0.413553 0.280237,0.871344 l -1.6e-5,2.550089 c 0,0 0.02416,0.6051 -0.27347,0.902731 -0.297626,0.297631 -0.46168,0.339646 -0.989248,0.360002 l -2.315853,1.55e-4 v -2.498 H 81.95784 Z"
id="path6247"
sodipodi:nodetypes="cccccsccccc" />
<ellipse
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.315695;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:7.7;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
id="path4757"
cx="95.089363"
cy="-42.528553"
transform="scale(1,-1)"
rx="0.61845386"
ry="0.61849999" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.315683;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 93.352109,45.026698 -13.710129,1.58e-4 c -0.51053,-0.02425 -0.69483,-0.0683 -0.98249,-0.311836 -0.20326,-0.250591 -0.24985,-0.413553 -0.28024,-0.871344 l 2e-5,-2.550089 c 0,0 -0.0242,-0.6051 0.27347,-0.902732 0.29762,-0.297631 0.46168,-0.339646 0.98924,-0.360002 l 2.31586,-1.55e-4 v 2.498 h 11.394269 z"
id="path6247-36"
sodipodi:nodetypes="cccccsccccc" />
<ellipse
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.315695;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:7.7;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
id="path4757-7"
cx="-80.220589"
cy="42.528843"
transform="scale(-1,1)"
rx="0.61845386"
ry="0.61849999" />
<g
id="g2099"
transform="rotate(-90,84.548611,28.232765)">
<path
style="fill:#2a80af;fill-opacity:1;stroke:#000000;stroke-width:0.315683;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 51.438689,29.084802 13.710125,-1.58e-4 c 0.510538,0.02425 0.694831,0.0683 0.982497,0.311837 0.203261,0.250591 0.249844,0.413553 0.280237,0.871344 l -1.6e-5,2.550089 c 0,0 0.02416,0.6051 -0.27347,0.902731 -0.297626,0.297631 -0.46168,0.339646 -0.989248,0.360002 l -2.315853,1.55e-4 v -2.498 H 51.438689 Z"
id="path6247-5"
sodipodi:nodetypes="cccccsccccc" />
<ellipse
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.315695;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:7.7;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
id="path4757-3"
cx="64.570213"
cy="-31.582657"
transform="scale(1,-1)"
rx="0.61845386"
ry="0.61849999" />
<path
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.315683;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 62.832958,34.080802 -13.710129,1.58e-4 c -0.51053,-0.02425 -0.69483,-0.0683 -0.98249,-0.311836 -0.20326,-0.250591 -0.24985,-0.413553 -0.28024,-0.871344 l 2e-5,-2.550089 c 0,0 -0.0242,-0.6051 0.27347,-0.902732 0.29762,-0.297631 0.46168,-0.339646 0.98924,-0.360002 l 2.31586,-1.55e-4 v 2.498 h 11.394269 z"
id="path6247-36-5"
sodipodi:nodetypes="cccccsccccc" />
<ellipse
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.315695;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:7.7;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke"
id="path4757-7-6"
cx="-49.701439"
cy="31.582947"
transform="scale(-1,1)"
rx="0.61845386"
ry="0.61849999" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.8 KiB

15
report/Makefile Normal file
View file

@ -0,0 +1,15 @@
.SUFFIXES:
.PHONY: all clean
all: html
generate:
python ./generate.py
html: generate
make -C ./build all
clean:
make -C ./build clean

0
report/__init__.py Normal file
View file

18
report/build/Makefile Normal file
View file

@ -0,0 +1,18 @@
SRC=$(wildcard *.txt)
HTMLFRAGMENT=$(addsuffix .html, $(basename $(SRC)))
.SUFFIXES:
.PHONY: all clean
all: html
html: $(HTMLFRAGMENT)
%.html: %.txt
./rst2html.py --stylesheet ./style.css $< > $@
clean:
rm -f *.html
rm -f *.txt

540
report/build/basic.css Normal file
View file

@ -0,0 +1,540 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar input[type="text"] {
width: 170px;
}
div.sphinxsidebar input[type="submit"] {
width: 30px;
}
img {
border: 0;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable dl, table.indextable dd {
margin-top: 0;
margin-bottom: 0;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- general body styles --------------------------------------------------- */
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.field-list ul {
padding-left: 1em;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px 7px 0 7px;
background-color: #ffe;
width: 40%;
float: right;
}
p.sidebar-title {
font-weight: bold;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
div.admonition dl {
margin-bottom: 0;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
border: 0;
border-collapse: collapse;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.field-list td, table.field-list th {
border: 0 !important;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
dl {
margin-bottom: 15px;
}
dd p {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dt:target, .highlighted {
background-color: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.refcount {
color: #060;
}
.optional {
font-size: 1.3em;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
padding: 5px 0px;
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
margin-left: 0.5em;
}
table.highlighttable td {
padding: 0 0.5em 0 0.5em;
}
tt.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
tt.descclassname {
background-color: transparent;
}
tt.xref, a tt {
background-color: transparent;
font-weight: bold;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}

38
report/build/rst2html.py Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/python
# unproudly borrowed from David Goodger's rst2html.py
""" A minimal front end to the Docutils Publisher, producing HTML with a
`config` role
"""
try:
import locale
locale.setlocale(locale.LC_ALL, '')
except:
pass
from docutils.core import publish_cmdline, default_description
# ____________________________________________________________
from docutils import nodes, utils
from docutils.parsers.rst import roles
# ____________________________________________________________
#register a :config: ReST link role for use in documentation
def config_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
basename = text
refuri = "report/build" + basename + '.html'
roles.set_classes(options)
node = nodes.reference(rawtext, utils.unescape(text), refuri=refuri,
**options)
return [node], []
roles.register_local_role('config', config_reference_role)
# ____________________________________________________________
description = ('Generates (X)HTML documents from standalone reStructuredText '
'sources. ' + default_description)
publish_cmdline(writer_name='html', description=description)

795
report/build/style.css Normal file
View file

@ -0,0 +1,795 @@
/*
* rtd.css
* ~~~~~~~~~~~~~~~
*
* Sphinx stylesheet -- sphinxdoc theme. Originally created by
* Armin Ronacher for Werkzeug.
*
* Customized for ReadTheDocs by Eric Pierce & Eric Holscher
*
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* RTD colors
* light blue: #e8ecef
* medium blue: #8ca1af
* dark blue: #465158
* dark grey: #444444
*
* white hover: #d1d9df;
* medium blue hover: #697983;
* green highlight: #8ecc4c
* light blue (project bar): #e8ecef
*/
@import url("basic.css");
/* PAGE LAYOUT -------------------------------------------------------------- */
body {
font: 100%/1.5 "ff-meta-web-pro-1","ff-meta-web-pro-2",Arial,"Helvetica Neue",sans-serif;
text-align: center;
color: black;
background-color: #465158;
padding: 0;
margin: 0;
}
div.document {
text-align: left;
background-color: #e8ecef;
}
div.bodywrapper {
background-color: #ffffff;
border-left: 1px solid #ccc;
border-bottom: 1px solid #ccc;
margin: 0 0 0 16em;
}
div.body {
margin: 0;
padding: 0.5em 1.3em;
min-width: 20em;
}
div.related {
font-size: 1em;
background-color: #465158;
}
div.documentwrapper {
float: left;
width: 100%;
background-color: #e8ecef;
}
/* HEADINGS --------------------------------------------------------------- */
h1 {
margin: 0;
padding: 0.7em 0 0.3em 0;
font-size: 1.5em;
line-height: 1.15;
color: #111;
clear: both;
}
h2 {
margin: 2em 0 0.2em 0;
font-size: 1.35em;
padding: 0;
color: #465158;
}
h3 {
margin: 1em 0 -0.3em 0;
font-size: 1.2em;
color: #6c818f;
}
div.body h1 a, div.body h2 a, div.body h3 a, div.body h4 a, div.body h5 a, div.body h6 a {
color: black;
}
h1 a.anchor, h2 a.anchor, h3 a.anchor, h4 a.anchor, h5 a.anchor, h6 a.anchor {
display: none;
margin: 0 0 0 0.3em;
padding: 0 0.2em 0 0.2em;
color: #aaa !important;
}
h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor,
h5:hover a.anchor, h6:hover a.anchor {
display: inline;
}
h1 a.anchor:hover, h2 a.anchor:hover, h3 a.anchor:hover, h4 a.anchor:hover,
h5 a.anchor:hover, h6 a.anchor:hover {
color: #777;
background-color: #eee;
}
/* LINKS ------------------------------------------------------------------ */
/* Normal links get a pseudo-underline */
a {
color: #444;
text-decoration: none;
border-bottom: 1px solid #ccc;
}
/* Links in sidebar, TOC, index trees and tables have no underline */
.sphinxsidebar a,
.toctree-wrapper a,
.indextable a,
#indices-and-tables a {
color: #444;
text-decoration: none;
border-bottom: none;
}
/* Most links get an underline-effect when hovered */
a:hover,
div.toctree-wrapper a:hover,
.indextable a:hover,
#indices-and-tables a:hover {
color: #111;
text-decoration: none;
border-bottom: 1px solid #111;
}
/* Footer links */
div.footer a {
color: #86989B;
text-decoration: none;
border: none;
}
div.footer a:hover {
color: #a6b8bb;
text-decoration: underline;
border: none;
}
/* Permalink anchor (subtle grey with a red hover) */
div.body a.headerlink {
color: #ccc;
font-size: 1em;
margin-left: 6px;
padding: 0 4px 0 4px;
text-decoration: none;
border: none;
}
div.body a.headerlink:hover {
color: #c60f0f;
border: none;
}
/* NAVIGATION BAR --------------------------------------------------------- */
div.related ul {
height: 2.5em;
}
div.related ul li {
margin: 0;
padding: 0.65em 0;
float: left;
display: block;
color: white; /* For the >> separators */
font-size: 0.8em;
}
div.related ul li.right {
float: right;
margin-right: 5px;
color: transparent; /* Hide the | separators */
}
/* "Breadcrumb" links in nav bar */
div.related ul li a {
order: none;
background-color: inherit;
font-weight: bold;
margin: 6px 0 6px 4px;
line-height: 1.75em;
color: #ffffff;
padding: 0.4em 0.8em;
border: none;
border-radius: 3px;
}
/* previous / next / modules / index links look more like buttons */
div.related ul li.right a {
margin: 0.375em 0;
background-color: #697983;
text-shadow: 0 1px rgba(0, 0, 0, 0.5);
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
/* All navbar links light up as buttons when hovered */
div.related ul li a:hover {
background-color: #8ca1af;
color: #ffffff;
text-decoration: none;
border-radius: 3px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
}
/* Take extra precautions for tt within links */
a tt,
div.related ul li a tt {
background: inherit !important;
color: inherit !important;
}
/* SIDEBAR ---------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 0;
}
div.sphinxsidebar {
margin: 0;
margin-left: -100%;
float: left;
top: 3em;
left: 0;
padding: 0 1em;
width: 14em;
font-size: 1em;
text-align: left;
background-color: #e8ecef;
}
div.sphinxsidebar img {
max-width: 12em;
}
div.sphinxsidebar h3,
div.sphinxsidebar h4,
div.sphinxsidebar p.logo {
margin: 1.2em 0 0.3em 0;
font-size: 1em;
padding: 0;
color: #222222;
font-family: "ff-meta-web-pro-1", "ff-meta-web-pro-2", "Arial", "Helvetica Neue", sans-serif;
}
div.sphinxsidebar h3 a {
color: #444444;
}
div.sphinxsidebar ul,
div.sphinxsidebar p {
margin-top: 0;
padding-left: 0;
line-height: 130%;
background-color: #e8ecef;
}
/* No bullets for nested lists, but a little extra indentation */
div.sphinxsidebar ul ul {
list-style-type: none;
margin-left: 1.5em;
padding: 0;
}
/* A little top/bottom padding to prevent adjacent links' borders
* from overlapping each other */
div.sphinxsidebar ul li {
padding: 1px 0;
}
/* A little left-padding to make these align with the ULs */
div.sphinxsidebar p.topless {
padding-left: 0 0 0 1em;
}
/* Make these into hidden one-liners */
div.sphinxsidebar ul li,
div.sphinxsidebar p.topless {
white-space: nowrap;
overflow: hidden;
}
/* ...which become visible when hovered */
div.sphinxsidebar ul li:hover,
div.sphinxsidebar p.topless:hover {
overflow: visible;
}
/* Search text box and "Go" button */
#searchbox {
margin-top: 2em;
margin-bottom: 1em;
background: #ddd;
padding: 0.5em;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
#searchbox h3 {
margin-top: 0;
}
/* Make search box and button abut and have a border */
input,
div.sphinxsidebar input {
border: 1px solid #999;
float: left;
}
/* Search textbox */
input[type="text"] {
margin: 0;
padding: 0 3px;
height: 20px;
width: 144px;
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
-moz-border-radius-topleft: 3px;
-moz-border-radius-bottomleft: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
}
/* Search button */
input[type="submit"] {
margin: 0 0 0 -1px; /* -1px prevents a double-border with textbox */
height: 22px;
color: #444;
background-color: #e8ecef;
padding: 1px 4px;
font-weight: bold;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
-moz-border-radius-topright: 3px;
-moz-border-radius-bottomright: 3px;
-webkit-border-top-right-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
}
input[type="submit"]:hover {
color: #ffffff;
background-color: #8ecc4c;
}
div.sphinxsidebar p.searchtip {
clear: both;
padding: 0.5em 0 0 0;
background: #ddd;
color: #666;
font-size: 0.9em;
}
/* Sidebar links are unusual */
div.sphinxsidebar li a,
div.sphinxsidebar p a {
background: #e8ecef; /* In case links overlap main content */
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border: 1px solid transparent; /* To prevent things jumping around on hover */
padding: 0 5px 0 5px;
}
div.sphinxsidebar li a:hover,
div.sphinxsidebar p a:hover {
color: #111;
text-decoration: none;
border: 1px solid #888;
}
div.sphinxsidebar p.logo a {
border: 0;
}
/* Tweak any link appearing in a heading */
div.sphinxsidebar h3 a {
}
/* OTHER STUFF ------------------------------------------------------------ */
cite, code, tt {
font-family: 'Consolas', 'Deja Vu Sans Mono',
'Bitstream Vera Sans Mono', monospace;
font-size: 0.95em;
letter-spacing: 0.01em;
}
tt {
background-color: #f2f2f2;
color: #444;
}
tt.descname, tt.descclassname, tt.xref {
border: 0;
}
hr {
border: 1px solid #abc;
margin: 2em;
}
pre, #_fontwidthtest {
font-family: 'Consolas', 'Deja Vu Sans Mono',
'Bitstream Vera Sans Mono', monospace;
margin: 1em 2em;
font-size: 0.95em;
letter-spacing: 0.015em;
line-height: 120%;
padding: 0.5em;
border: 1px solid #ccc;
background-color: #eee;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
pre a {
color: inherit;
text-decoration: underline;
}
td.linenos pre {
margin: 1em 0em;
}
td.code pre {
margin: 1em 0em;
}
div.quotebar {
background-color: #f8f8f8;
max-width: 250px;
float: right;
padding: 2px 7px;
border: 1px solid #ccc;
}
div.topic {
background-color: #f8f8f8;
}
table {
border-collapse: collapse;
margin: 0 -0.5em 0 -0.5em;
}
table td, table th {
padding: 0.2em 0.5em 0.2em 0.5em;
}
/* ADMONITIONS AND WARNINGS ------------------------------------------------- */
/* Shared by admonitions, warnings and sidebars */
div.admonition,
div.warning,
div.sidebar {
font-size: 0.9em;
margin: 2em;
padding: 0;
/*
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
*/
}
div.admonition p,
div.warning p,
div.sidebar p {
margin: 0.5em 1em 0.5em 1em;
padding: 0;
}
div.admonition pre,
div.warning pre,
div.sidebar pre {
margin: 0.4em 1em 0.4em 1em;
}
div.admonition p.admonition-title,
div.warning p.admonition-title,
div.sidebar p.sidebar-title {
margin: 0;
padding: 0.1em 0 0.1em 0.5em;
color: white;
font-weight: bold;
font-size: 1.1em;
text-shadow: 0 1px rgba(0, 0, 0, 0.5);
}
div.admonition ul, div.admonition ol,
div.warning ul, div.warning ol,
div.sidebar ul, div.sidebar ol {
margin: 0.1em 0.5em 0.5em 3em;
padding: 0;
}
/* Admonitions and sidebars only */
div.admonition, div.sidebar {
border: 1px solid #609060;
background-color: #e9ffe9;
}
div.admonition p.admonition-title,
div.sidebar p.sidebar-title {
background-color: #70A070;
border-bottom: 1px solid #609060;
}
/* Warnings only */
div.warning {
border: 1px solid #900000;
background-color: #ffe9e9;
}
div.warning p.admonition-title {
background-color: #b04040;
border-bottom: 1px solid #900000;
}
/* Sidebars only */
div.sidebar {
max-width: 30%;
}
div.versioninfo {
margin: 1em 0 0 0;
border: 1px solid #ccc;
background-color: #DDEAF0;
padding: 8px;
line-height: 1.3em;
font-size: 0.9em;
}
.viewcode-back {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva',
'Verdana', sans-serif;
}
div.viewcode-block:target {
background-color: #f4debf;
border-top: 1px solid #ac9;
border-bottom: 1px solid #ac9;
}
dl {
margin: 1em 0 2.5em 0;
}
/* Highlight target when you click an internal link */
dt:target {
background: #ffe080;
}
/* Don't highlight whole divs */
div.highlight {
background: transparent;
}
/* But do highlight spans (so search results can be highlighted) */
span.highlight {
background: #ffe080;
}
div.footer {
background-color: #465158;
color: #eeeeee;
padding: 0 2em 2em 2em;
clear: both;
font-size: 0.8em;
text-align: center;
}
p {
margin: 0.8em 0 0.5em 0;
}
.section p img.math {
margin: 0;
}
.section p img {
margin: 1em 2em;
}
/* MOBILE LAYOUT -------------------------------------------------------------- */
@media screen and (max-width: 600px) {
h1, h2, h3, h4, h5 {
position: relative;
}
ul {
padding-left: 1.25em;
}
div.bodywrapper a.headerlink, #indices-and-tables h1 a {
color: #e6e6e6;
font-size: 80%;
float: right;
line-height: 1.8;
position: absolute;
right: -0.7em;
visibility: inherit;
}
div.bodywrapper h1 a.headerlink, #indices-and-tables h1 a {
line-height: 1.5;
}
pre {
font-size: 0.7em;
overflow: auto;
word-wrap: break-word;
white-space: pre-wrap;
}
div.related ul {
height: 2.5em;
padding: 0;
text-align: left;
}
div.related ul li {
clear: both;
color: #465158;
padding: 0.2em 0;
}
div.related ul li:last-child {
border-bottom: 1px dotted #8ca1af;
padding-bottom: 0.4em;
margin-bottom: 1em;
width: 100%;
}
div.related ul li a {
color: #465158;
padding-right: 0;
}
div.related ul li a:hover {
background: inherit;
color: inherit;
}
div.related ul li.right {
clear: none;
padding: 0.65em 0;
margin-bottom: 0.5em;
}
div.related ul li.right a {
color: #fff;
padding-right: 0.8em;
}
div.related ul li.right a:hover {
background-color: #8ca1af;
}
div.body {
clear: both;
min-width: 0;
word-wrap: break-word;
}
div.bodywrapper {
margin: 0 0 0 0;
}
div.sphinxsidebar {
float: none;
margin: 0;
width: auto;
}
div.sphinxsidebar input[type="text"] {
height: 2em;
line-height: 2em;
width: 70%;
}
div.sphinxsidebar input[type="submit"] {
height: 2em;
margin-left: 0.5em;
width: 20%;
}
div.sphinxsidebar p.searchtip {
background: inherit;
margin-bottom: 1em;
}
div.sphinxsidebar ul li, div.sphinxsidebar p.topless {
white-space: normal;
}
.bodywrapper img {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 100%;
}
div.documentwrapper {
float: none;
}
div.admonition, div.warning, pre, blockquote {
margin-left: 0em;
margin-right: 0em;
}
.body p img {
margin: 0;
}
#searchbox {
background: transparent;
}
.related:not(:first-child) li {
display: none;
}
.related:not(:first-child) li.right {
display: block;
}
div.footer {
padding: 1em;
}
.rtd_doc_footer .badge {
float: none;
margin: 1em auto;
position: static;
}
.rtd_doc_footer .badge.revsys-inline {
margin-right: auto;
margin-bottom: 2em;
}
table.indextable {
display: block;
width: auto;
}
.indextable tr {
display: block;
}
.indextable td {
display: block;
padding: 0;
width: auto !important;
}
.indextable td dt {
margin: 1em 0;
}
ul.search {
margin-left: 0.25em;
}
ul.search li div.context {
font-size: 90%;
line-height: 1.1;
margin-bottom: 1;
margin-left: 0;
}
}

95
report/generate.py Normal file
View file

@ -0,0 +1,95 @@
from os.path import dirname, join
from rst import Rest, Paragraph, Strong, OrderedListItem, ListItem, Title, Link, Transition
from rst import Directive, Em, Quote, Text
from tiramisu.option import *
from tiramisu.config import *
#from makerestdoc import *
docdir = join(dirname(__file__), 'build')
def make_rst_file(filename, rstcontent):
fh = file(filename, 'w')
fh.write(rstcontent.text())
fh.close()
def descr_content(path, prefix, descr, root=False):
content = Rest()
title = Title(abovechar="", belowchar="=")
if root:
title.join(Text("Configuration's overview for: "), Quote(descr._name))
else:
title.join(Text("Group's overview for: "), Quote(descr._name))
content.add(title)
content.add(ListItem().join(Strong("name:"), Text(descr._name)))
if not root:
content.add(ListItem().join(Strong("path:"), Text(path)))
content.add(ListItem().join(Strong("description:"), Text(descr.impl_get_information('doc'))))
if not root:
content.add(ListItem().join(Strong("parent config:"), Text(prefix)))
if not root:
content.add(ListItem().join(Strong("type:"), Text(descr._group_type)))
if not root:
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
if not root:
content.add(ListItem().join(Strong("properties"), Text(str([prop for prop in descr._properties]))))
content.add(Transition())
content.add(Title(abovechar="", belowchar="-").join(Text("Ordered list of childrens for:"), Text(path)))
names, options = descr._children
for opt in options:
name = opt._name
link = Link(name + ":", join(path + '.' + name + ".html"))
# because of SympLink opt
if hasattr(opt, 'impl_get_information'):
doc = opt.impl_get_information('doc')
else:
doc = name
content.add(OrderedListItem(link, Text(opt.impl_get_information('doc'))))
content.add(Transition())
content.add(Paragraph(Link("back to index", "index.html")))
make_rst_file(join(docdir, path + '.txt'), content)
if root:
make_rst_file(join(docdir, 'index.txt'), content)
def opt_rst_content(path, prefix, descr, value):
content = Rest()
title = Title(abovechar="", belowchar="=")
title.join(Text("Configuration's option overview for: "), Quote(descr._name))
content.add(title)
content.add(ListItem().join(Strong("name:"), Text(descr._name)))
content.add(ListItem().join(Strong("type:"), Text(descr.__class__.__name__)))
content.add(ListItem().join(Strong("current value:"), Text(str(value))))
content.add(ListItem().join(Strong("path:"), Text(path)))
content.add(ListItem().join(Strong("parent config:"), Text(prefix)))
if isinstance(descr, ChoiceOption):
content.add(ListItem().join(Strong("possible values:"), Text(str(descr.impl_get_values()))))
if not isinstance(descr, SymLinkOption):
content.add(ListItem().join(Strong("mime type:"), Text(str(descr.__class__.__name__))))
content.add(ListItem().join(Strong("default value:"), Text(str(descr.impl_getdefault()))))
content.add(ListItem().join(Strong("description:"), Text(str(descr.impl_get_information('doc')))))
content.add(ListItem().join(Strong("requirements:"), Text(str(descr._requires))))
content.add(ListItem().join(Strong("properties"), Text(str([prop for prop in descr._properties]))))
else:
content.add(ListItem().join(Strong("links to:"), Text(str(descr.path))))
content.add(Transition())
content.add(Paragraph(Link("back to parent config", join(prefix + ".html"))))
make_rst_file(join(docdir, path + '.txt'), content)
def make_rest_overview(cfg, title=True):
descr = cfg._impl_descr
rootname = descr._name
descr_content(rootname, rootname, descr, root=True)
for path in descr.impl_getpaths(include_groups=True):
child = cfg.unwrap_from_path(path)
fullpath = rootname + '.' + path
prefix = fullpath.rsplit(".", 1)[0]
if isinstance(child, OptionDescription):
descr_content(fullpath, prefix, child)
else:
value = getattr(cfg, path)
opt_rst_content(fullpath, prefix, child, value)
if __name__ == '__main__':
from sampleconfig import get_example_config
make_rest_overview(get_example_config())
# ____________________________________________________________

410
report/rst.py Normal file
View file

@ -0,0 +1,410 @@
# unproudly borrowed from pypy :
# http://codespeak.net/svn/pypy/trunk/pypy/tool/rest/rst.py
""" reStructuredText generation tools
provides an api to build a tree from nodes, which can be converted to
ReStructuredText on demand
note that not all of ReST is supported, a usable subset is offered, but
certain features aren't supported, and also certain details (like how links
are generated, or how escaping is done) can not be controlled
"""
import re
def escape(txt):
"""escape ReST markup"""
if not isinstance(txt, str) and not isinstance(txt, unicode):
txt = str(txt)
# XXX this takes a very naive approach to escaping, but it seems to be
# sufficient...
for c in '\\*`|:_':
txt = txt.replace(c, '\\%s' % (c,))
return txt
class RestError(Exception):
""" raised on containment errors (wrong parent) """
class AbstractMetaclass(type):
def __new__(cls, *args):
obj = super(AbstractMetaclass, cls).__new__(cls, *args)
parent_cls = obj.parentclass
if parent_cls is None:
return obj
if not isinstance(parent_cls, list):
class_list = [parent_cls]
else:
class_list = parent_cls
if obj.allow_nesting:
class_list.append(obj)
for _class in class_list:
if not _class.allowed_child:
_class.allowed_child = {obj:True}
else:
_class.allowed_child[obj] = True
return obj
class AbstractNode(object):
""" Base class implementing rest generation
"""
sep = ''
__metaclass__ = AbstractMetaclass
parentclass = None # this exists to allow parent to know what
# children can exist
allow_nesting = False
allowed_child = {}
defaults = {}
_reg_whitespace = re.compile('\s+')
def __init__(self, *args, **kwargs):
self.parent = None
self.children = []
for child in args:
self._add(child)
for arg in kwargs:
setattr(self, arg, kwargs[arg])
def join(self, *children):
""" add child nodes
returns a reference to self
"""
for child in children:
self._add(child)
return self
def add(self, child):
""" adds a child node
returns a reference to the child
"""
self._add(child)
return child
def _add(self, child):
if child.__class__ not in self.allowed_child:
raise RestError("%r cannot be child of %r" % \
(child.__class__, self.__class__))
self.children.append(child)
child.parent = self
def __getitem__(self, item):
return self.children[item]
def __setitem__(self, item, value):
self.children[item] = value
def text(self):
""" return a ReST string representation of the node """
return self.sep.join([child.text() for child in self.children])
def wordlist(self):
""" return a list of ReST strings for this node and its children """
return [self.text()]
class Rest(AbstractNode):
""" Root node of a document """
sep = "\n\n"
def __init__(self, *args, **kwargs):
AbstractNode.__init__(self, *args, **kwargs)
self.links = {}
def render_links(self, check=False):
"""render the link attachments of the document"""
assert not check, "Link checking not implemented"
if not self.links:
return ""
link_texts = []
# XXX this could check for duplicates and remove them...
for link, target in self.links.iteritems():
link_texts.append(".. _`%s`: %s" % (escape(link), target))
return "\n" + "\n".join(link_texts) + "\n\n"
def text(self):
outcome = []
if (isinstance(self.children[0], Transition) or
isinstance(self.children[-1], Transition)):
raise ValueError, ('document must not begin or end with a '
'transition')
for child in self.children:
outcome.append(child.text())
# always a trailing newline
text = self.sep.join([i for i in outcome if i]) + "\n"
return text + self.render_links()
class Transition(AbstractNode):
""" a horizontal line """
parentclass = Rest
def __init__(self, char='-', width=80, *args, **kwargs):
self.char = char
self.width = width
super(Transition, self).__init__(*args, **kwargs)
def text(self):
return (self.width - 1) * self.char
class Paragraph(AbstractNode):
""" simple paragraph """
parentclass = Rest
sep = " "
indent = ""
# FIXME
width = 880
def __init__(self, *args, **kwargs):
# make shortcut
args = list(args)
for num, arg in enumerate(args):
if isinstance(arg, str):
args[num] = Text(arg)
super(Paragraph, self).__init__(*args, **kwargs)
def text(self):
texts = []
for child in self.children:
texts += child.wordlist()
buf = []
outcome = []
lgt = len(self.indent)
def grab(buf):
outcome.append(self.indent + self.sep.join(buf))
texts.reverse()
while texts:
next = texts[-1]
if not next:
texts.pop()
continue
if lgt + len(self.sep) + len(next) <= self.width or not buf:
buf.append(next)
lgt += len(next) + len(self.sep)
texts.pop()
else:
grab(buf)
lgt = len(self.indent)
buf = []
grab(buf)
return "\n".join(outcome)
class SubParagraph(Paragraph):
""" indented sub paragraph """
indent = " "
class Title(Paragraph):
""" title element """
parentclass = Rest
belowchar = "="
abovechar = ""
def text(self):
txt = self._get_text()
lines = []
if self.abovechar:
lines.append(self.abovechar * len(txt))
lines.append(txt)
if self.belowchar:
lines.append(self.belowchar * len(txt))
return "\n".join(lines)
def _get_text(self):
txt = []
for node in self.children:
txt += node.wordlist()
return ' '.join(txt)
class AbstractText(AbstractNode):
parentclass = [Paragraph, Title]
start = ""
end = ""
def __init__(self, _text):
self._text = _text
def text(self):
text = self.escape(self._text)
return self.start + text + self.end
def escape(self, text):
if not isinstance(text, str) and not isinstance(text, unicode):
text = str(text)
if self.start:
text = text.replace(self.start, '\\%s' % (self.start,))
if self.end and self.end != self.start:
text = text.replace(self.end, '\\%s' % (self.end,))
return text
class Text(AbstractText):
def wordlist(self):
text = escape(self._text)
return self._reg_whitespace.split(text)
class LiteralBlock(AbstractText):
parentclass = Rest
start = '::\n\n'
def text(self):
if not self._text.strip():
return ''
text = self.escape(self._text).split('\n')
for i, line in enumerate(text):
if line.strip():
text[i] = ' %s' % (line,)
return self.start + '\n'.join(text)
class Em(AbstractText):
start = "*"
end = "*"
class Strong(AbstractText):
start = "**"
end = "**"
class Quote(AbstractText):
start = '``'
end = '``'
class Anchor(AbstractText):
start = '_`'
end = '`'
class Footnote(AbstractText):
def __init__(self, note, symbol=False):
raise NotImplemented('XXX')
class Citation(AbstractText):
def __init__(self, text, cite):
raise NotImplemented('XXX')
class ListItem(Paragraph):
allow_nesting = True
item_chars = '*+-'
def text(self):
idepth = self.get_indent_depth()
indent = self.indent + (idepth + 1) * ' '
txt = '\n\n'.join(self.render_children(indent))
ret = []
item_char = self.item_chars[idepth]
ret += [indent[len(item_char)+1:], item_char, ' ', txt[len(indent):]]
return ''.join(ret)
def render_children(self, indent):
txt = []
buffer = []
def render_buffer(fro, to):
if not fro:
return
p = Paragraph(indent=indent, *fro)
p.parent = self.parent
to.append(p.text())
for child in self.children:
if isinstance(child, AbstractText):
buffer.append(child)
else:
if buffer:
render_buffer(buffer, txt)
buffer = []
txt.append(child.text())
render_buffer(buffer, txt)
return txt
def get_indent_depth(self):
depth = 0
current = self
while (current.parent is not None and
isinstance(current.parent, ListItem)):
depth += 1
current = current.parent
return depth
class OrderedListItem(ListItem):
item_chars = ["#."] * 5
class DListItem(ListItem):
item_chars = None
def __init__(self, term, definition, *args, **kwargs):
self.term = term
super(DListItem, self).__init__(definition, *args, **kwargs)
def text(self):
idepth = self.get_indent_depth()
indent = self.indent + (idepth + 1) * ' '
txt = '\n\n'.join(self.render_children(indent))
ret = []
ret += [indent[2:], self.term, '\n', txt]
return ''.join(ret)
class Link(AbstractText):
start = '`'
end = '`_'
def __init__(self, _text, target):
self._text = _text
self.target = target
self.rest = None
def text(self):
if self.rest is None:
self.rest = self.find_rest()
if self.rest.links.get(self._text, self.target) != self.target:
raise ValueError('link name %r already in use for a different '
'target' % (self.target,))
self.rest.links[self._text] = self.target
return AbstractText.text(self)
def find_rest(self):
# XXX little overkill, but who cares...
next = self
while next.parent is not None:
next = next.parent
return next
class InternalLink(AbstractText):
start = '`'
end = '`_'
class LinkTarget(Paragraph):
def __init__(self, name, target):
self.name = name
self.target = target
def text(self):
return ".. _`%s`:%s\n" % (self.name, self.target)
class Substitution(AbstractText):
def __init__(self, text, **kwargs):
raise NotImplemented('XXX')
class Directive(Paragraph):
indent = ' '
def __init__(self, name, *args, **options):
self.name = name
self.content = args
super(Directive, self).__init__()
self.options = options
def text(self):
# XXX not very pretty...
txt = '.. %s::' % (self.name,)
options = '\n'.join([' :%s: %s' % (k, v) for (k, v) in
self.options.iteritems()])
if options:
txt += '\n%s' % (options,)
if self.content:
txt += '\n'
for item in self.content:
txt += '\n ' + item
return txt

25
report/sampleconfig.py Normal file
View file

@ -0,0 +1,25 @@
# coding: utf-8
from tiramisu.config import *
from tiramisu.option import *
gcoption = ChoiceOption('name', 'GC name', ('ref', 'framework'), 'ref')
gcdummy = BoolOption('dummy', 'dummy', default=False)
objspaceoption = ChoiceOption('objspace', 'Object space',
('std', 'thunk'), 'std')
booloption = BoolOption('bool', 'Test boolean option', default=True)
intoption = IntOption('int', 'Test int option', default=0)
floatoption = FloatOption('float', 'Test float option', default=2.3)
stroption = StrOption('str', 'Test string option', default="abc")
boolop = BoolOption('boolop', 'Test boolean option op', default=True)
wantref_option = BoolOption('wantref', 'Test requires', default=False)
wantframework_option = BoolOption('wantframework', 'Test requires',
default=False)
gcgroup = OptionDescription('gc', 'doc pour gc', [gcoption, gcdummy, floatoption])
descr = OptionDescription('essai', 'une éééééé doc pour essai', [gcgroup, booloption, objspaceoption,
wantref_option, stroption,
wantframework_option,
intoption, boolop])
def get_example_config():
return Config(descr)

51
setup.py Normal file
View file

@ -0,0 +1,51 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup
import os
from tiramisu import __version__
ORI_PACKAGE_NAME = 'tiramisu'
PACKAGE_NAME = os.environ.get('PACKAGE_DST', ORI_PACKAGE_NAME)
if PACKAGE_NAME != ORI_PACKAGE_NAME:
package_dir = {PACKAGE_NAME: ORI_PACKAGE_NAME}
else:
package_dir = None
setup(
version=__version__,
author="Tiramisu's team",
author_email='gnunux@gnunux.info',
name=PACKAGE_NAME,
description='an options controller tool',
url='https://framagit.org/tiramisu/tiramisu',
license='GNU Library or Lesser General Public License (LGPL)',
provides=['tiramisu_api'],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
"Operating System :: OS Independent",
"Natural Language :: English",
"Natural Language :: French",
],
long_description="""\
An options controller tool
-------------------------------------
Due to more and more available options required to set up an operating system,
compiler options or whatever, it became quite annoying to hand the necessary
options to where they are actually used and even more annoying to add new
options. To circumvent these problems the configuration control was
introduced...
Tiramisu is an options handler and an options controller, wich aims at
producing flexible and fast options access.
This version requires Python 3.5 or later.
""",
include_package_data=True,
package_dir=package_dir,
packages=[PACKAGE_NAME],
)

0
tests/__init__.py Normal file
View file

0
tests/auto/__init__.py Normal file
View file

14
tests/auto/autopath.py Normal file
View file

@ -0,0 +1,14 @@
"""automatically sets the PYTHONPATH before running the unit tests
This is supposed to be used in development mode (i.e. testing from a fresh
checkout)
"""
from os.path import dirname, abspath, join, normpath
import sys
def do_autopath():
HERE = dirname(abspath(__file__))
PATH = normpath(join(HERE, '..', '..', 'tiramisu'))
if PATH not in sys.path:
sys.path.insert(1, PATH)

1826
tests/auto/test_auto.py Normal file

File diff suppressed because it is too large Load diff

14
tests/autopath.py Normal file
View file

@ -0,0 +1,14 @@
"""automatically sets the PYTHONPATH before running the unit tests
This is supposed to be used in development mode (i.e. testing from a fresh
checkout)
"""
from os.path import dirname, abspath, join, normpath
import sys
def do_autopath():
HERE = dirname(abspath(__file__))
PATH = normpath(join(HERE, '..', 'tiramisu'))
if PATH not in sys.path:
sys.path.insert(1, PATH)

85
tests/config.py Normal file
View file

@ -0,0 +1,85 @@
# from json import dumps, loads
import asyncio
from os import environ
try:
from tiramisu_api import Config
class TestConfig(Config):
def __init__(self,
config):
self.test_option = config.option
json = self.test_option.dict()
# assert json == loads(dumps(json))
super().__init__(json)
def send_data(self,
updates):
return self.updates_data(self.test_option.updates(updates))
PARAMS = ['tiramisu', 'tiramisu-api']
except:
PARAMS = ['tiramisu']
import pytest
async def get_config(config, type, error=False):
if type == 'tiramisu':
return config
if error:
await config.property.add('demoting_error_warning')
return TestConfig(config)
def value_list(values):
if values[0] == '':
del values[0]
return tuple(values)
async def global_owner(config, config_type):
return await config.owner.get()
@pytest.fixture(params=PARAMS)
def config_type(request):
return request.param
LOOP = None
@pytest.fixture(scope='session')
def event_loop(request):
"""Create an instance of the default event loop for each test case."""
global LOOP
if LOOP is None:
LOOP = asyncio.get_event_loop_policy().new_event_loop()
return LOOP
async def _delete_sessions(meta):
if await meta.config.type() != 'config':
for conf in await meta.config.list():
await _delete_sessions(conf)
await meta.session.reset()
async def delete_sessions(confs):
if not isinstance(confs, list):
confs = [confs]
for conf in confs:
await _delete_sessions(conf)
if environ.get('TIRAMISU_STORAGE') == 'postgres':
async with confs[0]._config_bag.context.getconnection() as connection:
assert await connection.fetchrow('SELECT * FROM session') is None
assert await connection.fetchrow('SELECT * FROM value') is None
assert await connection.fetchrow('SELECT * FROM information') is None
assert await connection.fetchrow('SELECT * FROM property') is None
assert await connection.fetchrow('SELECT * FROM permissive') is None
elif environ.get('TIRAMISU_STORAGE') == 'sqlite3':
async with confs[0]._config_bag.context.getconnection() as connection:
assert await connection.select('SELECT * FROM session') is None
assert await connection.select('SELECT * FROM value') is None
assert await connection.select('SELECT * FROM information') is None
assert await connection.select('SELECT * FROM property') is None
assert await connection.select('SELECT * FROM permissive') is None
else:
from tiramisu import list_sessions
assert not await list_sessions()

0
tests/dict/__init__.py Normal file
View file

View file

View file

@ -0,0 +1,43 @@
{
"schema": {
"options": {
"properties": {
"options.boolean": {
"type": "boolean",
"title": "Boolean 1"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.boolean": {
"clearable": true
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,12 @@
"""just an boolean option
"""
from tiramisu.option import BoolOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = BoolOption('boolean', "Boolean 1")
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("boolean1", "Simple boolean", [descr1])
return descr

View file

@ -0,0 +1,47 @@
{
"schema": {
"options": {
"properties": {
"options.boolean": {
"type": "boolean",
"title": "Boolean 1 frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.boolean": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.boolean": {
"clearable": true
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,12 @@
"""just an boolean option
"""
from tiramisu.option import BoolOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = BoolOption('boolean', "Boolean 1 frozen", properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("boolean1_frozen", "Simple boolean", [descr1])
return descr

View file

@ -0,0 +1,49 @@
{
"schema": {
"options": {
"properties": {
"options.choice": {
"type": "choice",
"enum": [
"",
"choice 1",
"choice 2"
],
"title": "Choice description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,10 @@
from tiramisu.option import ChoiceOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice', "Choice description", ("choice 1", "choice 2"))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("choice1", "Simple choice", [descr1])
return descr

View file

@ -0,0 +1,53 @@
{
"schema": {
"options": {
"properties": {
"options.choice": {
"type": "choice",
"enum": [
"",
"choice 1",
"choice 2"
],
"title": "Choice description frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.choice": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,10 @@
from tiramisu.option import ChoiceOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice', "Choice description frozen", ("choice 1", "choice 2"), properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("choice1_frozen", "Simple choice", [descr1])
return descr

View file

@ -0,0 +1,104 @@
{
"schema": {
"options": {
"properties": {
"options.choice1": {
"properties": {
"options.choice1.choice1": {
"type": "choice",
"isMulti": true,
"enum": [
"choice 1",
"choice 2"
],
"title": "Choice description leader"
},
"options.choice1.choice2": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 3",
"choice 4"
],
"title": "Choice description follower 1"
},
"options.choice1.choice3": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 5",
"choice 6"
],
"title": "Choice description follower 2"
},
"options.choice1.choice4": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 7",
"choice 8"
],
"title": "Choice description follower 3"
}
},
"type": "array",
"title": "Common configuration 1"
}
},
"type": "object",
"title": "Common configuration 2"
}
},
"model": {
"options.choice1.choice1": {
"required": true,
"properties": [
"unique"
]
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice1.choice1": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice2": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice3": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice4": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,16 @@
from tiramisu.option import ChoiceOption, OptionDescription
from tiramisu import Leadership
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice1', "Choice description leader", ("choice 1", "choice 2"), multi=True)
option1 = ChoiceOption('choice2', "Choice description follower 1", ("choice 3", "choice 4"), multi=True)
option2 = ChoiceOption('choice3', "Choice description follower 2", ("choice 5", "choice 6"), multi=True)
option3 = ChoiceOption('choice4', "Choice description follower 3", ("choice 7", "choice 8"), multi=True)
descr1 = Leadership("choice1", "Common configuration 1",
[option, option1, option2, option3])
descr = OptionDescription("options", "Common configuration 2", [descr1])
descr = OptionDescription("choice1_leadership", "Leader followers with choice", [descr])
return descr

View file

@ -0,0 +1,109 @@
{
"schema": {
"options": {
"properties": {
"options.choice1": {
"properties": {
"options.choice1.choice1": {
"type": "choice",
"isMulti": true,
"enum": [
"choice 1",
"choice 2"
],
"title": "Choice description leader"
},
"options.choice1.choice2": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 3",
"choice 4"
],
"title": "Choice description follower 1"
},
"options.choice1.choice3": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 5",
"choice 6"
],
"title": "Choice description follower 2 hidden"
},
"options.choice1.choice4": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 7",
"choice 8"
],
"title": "Choice description follower 3"
}
},
"type": "array",
"title": "Slave 2 is hidden"
}
},
"type": "object",
"title": "Common configuration 2"
}
},
"model": {
"options.choice1.choice1": {
"required": true,
"properties": [
"unique"
]
},
"options.choice1.choice3": {
"null": {
"display": false
}
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice1.choice1": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice2": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice3": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice4": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,16 @@
from tiramisu.option import ChoiceOption, OptionDescription
from tiramisu import Leadership
from tiramisu.setting import groups
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice1', "Choice description leader", ("choice 1", "choice 2"), multi=True)
option1 = ChoiceOption('choice2', "Choice description follower 1", ("choice 3", "choice 4"), multi=True)
option2 = ChoiceOption('choice3', "Choice description follower 2 hidden", ("choice 5", "choice 6"), multi=True, properties=('hidden',))
option3 = ChoiceOption('choice4', "Choice description follower 3", ("choice 7", "choice 8"), multi=True)
descr1 = Leadership("choice1", "Slave 2 is hidden",
[option, option1, option2, option3])
descr = OptionDescription("options", "Common configuration 2", [descr1])
descr = OptionDescription("choice1_leadership_hidden", "Leader follower with choice, one is hidden", [descr])
return descr

View file

@ -0,0 +1,114 @@
{
"schema": {
"options": {
"properties": {
"options.choice1": {
"properties": {
"options.choice1.choice1": {
"type": "choice",
"isMulti": true,
"enum": [
"choice 1",
"choice 2"
],
"title": "Choice leader"
},
"options.choice1.choice2": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 3",
"choice 4"
],
"title": "Choice follower 1"
},
"options.choice1.choice3": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 5",
"choice 6"
],
"title": "Choice follower 2"
},
"options.choice1.choice4": {
"type": "choice",
"isMulti": true,
"enum": [
"",
"choice 7",
"choice 8"
],
"title": "Choice follower 3"
}
},
"type": "array",
"title": "Common configuration 1"
}
},
"type": "object",
"title": "Common configuration 2"
}
},
"model": {
"options.choice1.choice1": {
"required": true,
"properties": [
"unique"
],
"value": [
"choice 2"
],
"owner": "user"
},
"options.choice1.choice2": {
"0": {
"value": "choice 4",
"owner": "user"
}
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice1.choice1": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice2": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice3": {
"clearable": true,
"type": "choice"
},
"options.choice1.choice4": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,25 @@
from tiramisu.option import ChoiceOption, OptionDescription
from tiramisu import Leadership
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice1', "Choice leader", ("choice 1", "choice 2"), multi=True)
option1 = ChoiceOption('choice2', "Choice follower 1", ("choice 3", "choice 4"), multi=True)
option2 = ChoiceOption('choice3', "Choice follower 2", ("choice 5", "choice 6"), multi=True)
option3 = ChoiceOption('choice4', "Choice follower 3", ("choice 7", "choice 8"), multi=True)
descr1 = Leadership("choice1", "Common configuration 1",
[option, option1, option2, option3])
descr = OptionDescription("options", "Common configuration 2", [descr1])
descr = OptionDescription("choice1_leadership_value", "Leader followers with choices, leader is 'choice 2' and follower 1 is 'choice 4'", [descr])
return descr
async def get_values(api, allpath=False):
if allpath:
root = 'choice1_leadership_value.'
else:
root = ''
await api.option(root + 'options.choice1.choice1').value.set(['choice 2'])
await api.option(root + 'options.choice1.choice2', 0).value.set('choice 4')

View file

@ -0,0 +1,56 @@
{
"schema": {
"options": {
"properties": {
"options.choice": {
"type": "choice",
"isMulti": true,
"enum": [
"choice 1",
"choice 2"
],
"title": "Choice description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.choice": {
"required": true,
"properties": [
"unique"
]
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice": {
"clearable": true,
"type": "choice"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,10 @@
from tiramisu.option import ChoiceOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice', "Choice description", ("choice 1", "choice 2"), multi=True)
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("choice1_multi", "Multi choice", [descr1])
return descr

View file

@ -0,0 +1,53 @@
{
"schema": {
"options": {
"properties": {
"options.choice": {
"type": "choice",
"enum": [
"",
"choice 1",
"choice 2"
],
"title": "Choice description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice": {
"clearable": true,
"type": "choice",
"displayed": {
"choice 1": "renamed 1",
"choice 2": "renamed 2"
}
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,20 @@
from tiramisu.option import ChoiceOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = ChoiceOption('choice', "Choice description", ("choice 1", "choice 2"))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("choice1_rename", "Rename displayed value", [descr1])
return descr
def get_form(allpath=False):
key = 'options.choice'
if allpath:
key = 'choice1_rename.' + key
return [{'key': key,
'displayed': {'choice 1': 'renamed 1',
'choice 2': 'renamed 2'}
}]

View file

@ -0,0 +1,85 @@
{
"schema": {
"options": {
"properties": {
"options.choice": {
"type": "choice",
"enum": [
"hide",
"show"
],
"value": "hide",
"title": "Choice description"
},
"options.unicode2": {
"type": "string",
"title": "Unicode 2"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.choice": {
"required": true,
"value": "hide"
},
"options.unicode2": {
"display": false,
"hidden": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.choice": {
"clearable": true,
"type": "choice",
"dependencies": {
"default": {
"show": [
"options.unicode2"
]
},
"expected": {
"show": {
"show": [
"options.unicode2"
]
},
"hide": {
"hide": [
"options.unicode2"
]
}
}
}
},
"options.unicode2": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,14 @@
from tiramisu import ChoiceOption, StrOption, OptionDescription, Calculation, ParamValue, ParamOption, Params, calc_value
def get_description():
"""generate description for this test
"""
option1 = ChoiceOption('choice', "Choice description", ("hide", "show"), default='hide', properties=('mandatory',))
hidden_property = Calculation(calc_value,
Params(ParamValue('hidden'),
kwargs={'condition': ParamOption(option1, todict=True),
'expected': ParamValue('hide')}))
option2 = StrOption('unicode2', "Unicode 2", properties=(hidden_property,))
descr1 = OptionDescription("options", "Common configuration", [option1, option2])
descr = OptionDescription("choice1_requires", "Choice with requirement", [descr1])
return descr

View file

@ -0,0 +1,44 @@
{
"schema": {
"options": {
"properties": {
"options.date": {
"type": "date",
"title": "Date description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.date": {
"clearable": true,
"remote": true
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

9
tests/dict/data/date1.py Normal file
View file

@ -0,0 +1,9 @@
from tiramisu.option import DateOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = DateOption('date', "Date description")
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("date1", "Simple date", [descr1])
return descr

View file

@ -0,0 +1,48 @@
{
"schema": {
"options": {
"properties": {
"options.date": {
"type": "date",
"title": "Date description frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.date": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.date": {
"clearable": true,
"remote": true
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,9 @@
from tiramisu.option import DateOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = DateOption('date', "Date description frozen", properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("date1_frozen", "Simple date", [descr1])
return descr

View file

@ -0,0 +1,43 @@
{
"schema": {
"usbpath": {
"type": "filename",
"title": "Chemin d'acc\u00e8s"
}
},
"model": {
"usbpath": {
"required": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"usbpath": {
"clearable": true,
"pattern": "^[a-zA-Z0-9\\-\\._~/+]+$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from tiramisu.option import FilenameOption, OptionDescription
def get_description():
usbpath = FilenameOption('usbpath', "Chemin d'accès", properties=('mandatory',))
descr = OptionDescription("filename1", "Simple filename", [usbpath])
return descr

View file

@ -0,0 +1,72 @@
{
"schema": {
"options": {
"properties": {
"options.hostname1": {
"type": "domainname",
"title": "Domainname Description"
},
"options.hostname2": {
"type": "domainname",
"title": "Domainname without dot Description"
},
"options.hostname3": {
"type": "domainname",
"title": "Hostname or IP Description"
},
"options.hostname4": {
"type": "domainname",
"title": "Netbios Description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.hostname1": {
"clearable": true,
"pattern": "^((?!-)[a-z0-9-]{1,63}\\.){1,}[a-z0-9-]{1,63}$",
"type": "input"
},
"options.hostname2": {
"clearable": true,
"pattern": "^((?!-)[a-z0-9-]{0,63}\\.){0,}[a-z0-9-]{1,63}$",
"type": "input"
},
"options.hostname3": {
"clearable": true,
"pattern": "^(?:((?!-)[a-z0-9-]{1,63})|(?:(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)))$",
"type": "input"
},
"options.hostname4": {
"clearable": true,
"pattern": "^((?!-)[a-z0-9-]{1,15})$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,12 @@
from tiramisu.option import DomainnameOption, OptionDescription
def get_description():
"""generate description for this test
"""
option1 = DomainnameOption('hostname1', "Domainname Description")
option2 = DomainnameOption('hostname2', "Domainname without dot Description", allow_without_dot=True)
option3 = DomainnameOption('hostname3', "Hostname or IP Description", type='hostname', allow_ip=True)
option4 = DomainnameOption('hostname4', "Netbios Description", type='netbios')
descr1 = OptionDescription("options", "Common configuration", [option1, option2, option3, option4])
descr = OptionDescription("hostname1", "Simple hostnames", [descr1])
return descr

45
tests/dict/data/ip1.json Normal file
View file

@ -0,0 +1,45 @@
{
"schema": {
"options": {
"properties": {
"options.ip": {
"type": "ip",
"title": "IP Description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.ip": {
"clearable": true,
"remote": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

9
tests/dict/data/ip1.py Normal file
View file

@ -0,0 +1,9 @@
from tiramisu.option import IPOption, OptionDescription
def get_description():
"""generate description for this test
"""
option1 = IPOption('ip', "IP Description")
descr1 = OptionDescription("options", "Common configuration", [option1])
descr = OptionDescription("ip1", "Simple IP", [descr1])
return descr

View file

@ -0,0 +1,49 @@
{
"schema": {
"options": {
"properties": {
"options.ip": {
"type": "ip",
"title": "IP Description frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.ip": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.ip": {
"clearable": true,
"remote": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,9 @@
from tiramisu.option import IPOption, OptionDescription
def get_description():
"""generate description for this test
"""
option1 = IPOption('ip', "IP Description frozen", properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option1])
descr = OptionDescription("ip1_frozen", "Simple IP", [descr1])
return descr

View file

@ -0,0 +1,45 @@
{
"schema": {
"options": {
"properties": {
"options.mail": {
"type": "email",
"title": "Mail Description"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.mail": {
"clearable": true,
"pattern": "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

10
tests/dict/data/mail1.py Normal file
View file

@ -0,0 +1,10 @@
from tiramisu.option import EmailOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = EmailOption('mail', "Mail Description")
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("mail1", "Simple mail", [descr1])
return descr

View file

@ -0,0 +1,45 @@
{
"schema": {
"options": {
"properties": {
"options.integer": {
"type": "integer",
"title": "integer 1"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.integer": {
"clearable": true,
"pattern": "^[0-9]+$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,10 @@
from tiramisu.option import IntOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = IntOption('integer', "integer 1")
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("number1", "Simple number", [descr1])
return descr

View file

@ -0,0 +1,49 @@
{
"schema": {
"options": {
"properties": {
"options.integer": {
"type": "integer",
"title": "integer 1 frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.integer": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.integer": {
"clearable": true,
"pattern": "^[0-9]+$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,10 @@
from tiramisu.option import IntOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = IntOption('integer', "integer 1 frozen", properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("number1_frozen", "Simple number", [descr1])
return descr

View file

@ -0,0 +1,51 @@
{
"schema": {
"options": {
"properties": {
"options.integer": {
"type": "integer",
"value": 0,
"title": "integer 1"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.integer": {
"value": 3,
"owner": "user"
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.integer": {
"clearable": true,
"pattern": "^[0-9]+$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,18 @@
from tiramisu.option import IntOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = IntOption('integer', "integer 1", 0)
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("number1_mod_value", "Number with modified value 3 and default value 0", [descr1])
return descr
async def get_values(api, allpath=False):
if allpath:
root = 'number1_mod_value.'
else:
root = ''
await api.option(root + 'options.integer').value.set(3)

View file

@ -0,0 +1,50 @@
{
"schema": {
"options": {
"properties": {
"options.integer": {
"type": "integer",
"value": 0,
"title": "integer 1"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.integer": {
"value": 0
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.integer": {
"clearable": true,
"pattern": "^[0-9]+$",
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,11 @@
from tiramisu.option import IntOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = IntOption('integer', "integer 1", 0)
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("number1_value", "Number with value 0", [descr1])
return descr

View file

@ -0,0 +1 @@
{"options.unicode": null}

View file

@ -0,0 +1 @@
{"options.unicode": "val"}

View file

@ -0,0 +1,44 @@
{
"schema": {
"options": {
"properties": {
"options.unicode": {
"type": "string",
"title": "Unicode 1"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.unicode": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,5 @@
{"cmd": "config.option('options.unicode').value.set('val')",
"body": {"updates": [{"action": "modify",
"name": "options.unicode",
"value": "val"}]}
}

View file

@ -0,0 +1,11 @@
"""just an unicode option
"""
from tiramisu.option import StrOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = StrOption('unicode', "Unicode 1")
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("unicode1", "Simple unicode", [descr1])
return descr

View file

@ -0,0 +1,3 @@
{"updates": ["options.unicode"],
"model": {"options.unicode": {"owner": "user",
"value": "val"}}}

View file

@ -0,0 +1,48 @@
{
"schema": {
"options": {
"properties": {
"options.unicode": {
"type": "string",
"title": "Unicode 1 frozen"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.unicode": {
"readOnly": true
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.unicode": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,11 @@
"""just an unicode option
"""
from tiramisu.option import StrOption, OptionDescription
def get_description():
"""generate description for this test
"""
option = StrOption('unicode', "Unicode 1 frozen", properties=('frozen',))
descr1 = OptionDescription("options", "Common configuration", [option])
descr = OptionDescription("unicode1_frozen", "Simple unicode", [descr1])
return descr

View file

@ -0,0 +1,93 @@
{
"schema": {
"options": {
"properties": {
"options.unicode": {
"properties": {
"options.unicode.unicode": {
"type": "string",
"isMulti": true,
"title": "Unicode leader"
},
"options.unicode.unicode1": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 1"
},
"options.unicode.unicode2": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 2"
},
"options.unicode.unicode3": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 3"
}
},
"type": "array",
"title": "Common configuration"
}
},
"type": "object",
"title": "Common configuration"
}
},
"model": {
"options.unicode": {
"display": false,
"properties": [
"hidden"
]
},
"options.unicode.unicode": {
"required": true,
"properties": [
"unique"
],
"hidden": true,
"display": false
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.unicode.unicode": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode1": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode2": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode3": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,15 @@
from tiramisu.option import StrOption, OptionDescription
from tiramisu import Leadership
def get_description():
"""generate description for this test
"""
option = StrOption('unicode', "Unicode leader", multi=True)
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
option3 = StrOption('unicode3', "Unicode follower 3", multi=True)
descr1 = Leadership("unicode", "Common configuration",
[option, option1, option2, option3], properties=('hidden',))
descr = OptionDescription("options", "Common configuration", [descr1])
descr = OptionDescription("unicode1_leader_hidden_followers", "Leader follower with unicode and hidden leader", [descr])
return descr

View file

@ -0,0 +1,85 @@
{
"schema": {
"options": {
"properties": {
"options.unicode": {
"properties": {
"options.unicode.unicode": {
"type": "string",
"isMulti": true,
"title": "Unicode leader"
},
"options.unicode.unicode1": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 1"
},
"options.unicode.unicode2": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 2"
},
"options.unicode.unicode3": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 3"
}
},
"type": "array",
"title": "Common configuration 1"
}
},
"type": "object",
"title": "Common configuration 2"
}
},
"model": {
"options.unicode.unicode": {
"required": true,
"properties": [
"unique"
]
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.unicode.unicode": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode1": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode2": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode3": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

View file

@ -0,0 +1,15 @@
from tiramisu.option import StrOption, OptionDescription, Leadership
def get_description():
"""generate description for this test
"""
option = StrOption('unicode', "Unicode leader", multi=True)
option1 = StrOption('unicode1', "Unicode follower 1", multi=True)
option2 = StrOption('unicode2', "Unicode follower 2", multi=True)
option3 = StrOption('unicode3', "Unicode follower 3", multi=True)
descr1 = Leadership("unicode", "Common configuration 1",
[option, option1, option2, option3])
descr = OptionDescription("options", "Common configuration 2", [descr1])
descr = OptionDescription("unicode1_leadership", "Leader followers with Unicode", [descr])
return descr

View file

@ -0,0 +1,102 @@
{
"schema": {
"options": {
"properties": {
"options.unicode": {
"properties": {
"options.unicode.unicode": {
"type": "string",
"isMulti": true,
"value": [
"val1",
"val2"
],
"title": "Unicode leader"
},
"options.unicode.unicode1": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 1"
},
"options.unicode.unicode2": {
"type": "string",
"defaultmulti": "follower2",
"isMulti": true,
"title": "Unicode follower 2 with default multi"
},
"options.unicode.unicode3": {
"type": "string",
"isMulti": true,
"title": "Unicode follower 3"
}
},
"type": "array",
"title": "Common configuration 1"
}
},
"type": "object",
"title": "Common configuration 2"
}
},
"model": {
"options.unicode.unicode": {
"required": true,
"properties": [
"unique"
],
"value": [
"val1",
"val2"
]
},
"options.unicode.unicode2": {
"0": {
"value": "follower2"
},
"1": {
"value": "follower2"
}
}
},
"global": {
"owner": "user",
"properties": [
"cache",
"demoting_error_warning",
"disabled",
"force_store_value",
"frozen",
"hidden",
"validator",
"warnings"
],
"permissives": [
"hidden"
]
},
"form": {
"options.unicode.unicode": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode1": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode2": {
"clearable": true,
"type": "input"
},
"options.unicode.unicode3": {
"clearable": true,
"type": "input"
},
"null": [
{
"title": "Configurer",
"type": "submit"
}
]
},
"version": "1.0"
}

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