From fd69b6b5fd9117baeb2b39fa75c3efa3740e2227 Mon Sep 17 00:00:00 2001 From: Denise sur Lya Date: Thu, 18 Jun 2020 23:52:53 +0200 Subject: =?UTF-8?q?couleurs=20personnalisables,=20affichage=20am=C3=A9lior?= =?UTF-8?q?=C3=A9=20(on=20peut=20masquer=20notamment).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + COPYING | 5 +++ app.py | 3 ++ configuration.py | 29 +++++++++++++- data/changelog_data.txt | 2 + data_OMS/licence | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ gestionOMS.py | 20 +++++++--- gestion_couleurs.py | 62 ++++++++++++++++++++++++++++++ gestion_donnees.py | 84 ++++++++++++++-------------------------- licence | 20 ++++++++++ static/style.css | 20 +++++++++- templates/apropos.html | 1 + templates/index.html | 23 ++++++----- trace_courbe.py | 62 ++++++++++++++++++++++-------- 14 files changed, 343 insertions(+), 89 deletions(-) create mode 100644 .gitignore create mode 100644 COPYING create mode 100644 data_OMS/licence create mode 100644 gestion_couleurs.py create mode 100644 licence diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d50c38d --- /dev/null +++ b/COPYING @@ -0,0 +1,5 @@ +-------------- +Attention : application de licences : + +Le dossier data_OMS est sous licence CC BY-NC-SA 3.0 IGO +Le reste du projet est sous licence diff --git a/app.py b/app.py index 0d2054b..3deb7f6 100644 --- a/app.py +++ b/app.py @@ -45,6 +45,8 @@ def courbe_image(ext): # Régler la configuration et les données config = gere_configuration(data,liste_err) l_jours,l_poids = gere_donneespoids(data,config["naissance"],liste_err) + + #print(config) texte = donnees_vers_json(l_jours,l_poids,config) @@ -56,6 +58,7 @@ def courbe_image(ext): fig = cree_figure(config,l_jours,l_poids,liste_err) result = "success" output = io.BytesIO() + #warning("Là ça va",liste_err) FigureCanvas(fig).print_png(output) plt.close(fig) except: diff --git a/configuration.py b/configuration.py index ef017fa..e173ad9 100644 --- a/configuration.py +++ b/configuration.py @@ -17,9 +17,11 @@ f_poids_perc_mixte = chemin_oms+"wfa_mix_p_exp.txt" # Pour les courbes percentiles liste_data_choisie_p = [(5,1),(7,5),(8,10),(10,25),(11,50),(12,75), (14,90), (15,95),(17,99)] +liste_data_choisie_p.sort(reverse=True) # pour le sigma : (colonne,sigma) liste_data_choisie_z = [(2,-3),(3,-2),(4,-1),(5,0),(6,1),(7,2),(8,3)] +liste_data_choisie_z.sort(reverse=True) liste_unites_valides = ["jours", "semaines", "mois", "années"] @@ -52,6 +54,24 @@ hauteur_graphique_min = 2 # Nombre de lignes par défaut dans le formulaire nombre_lignes_form = 5 +# couleurs par défaut +couleur_defaut_1 = "#0000FF" # bleu +couleur_defaut_2 = "#00FF00" # vert +couleur_defaut_3 = "#FF0000" # rouge +couleur_defaut_1_tuple = (0,0,1) +couleur_defaut_2_tuple = (0,1,0) +couleur_defaut_3_tuple = (1,0,0) + +# couleurs par défaut fond +couleur_defaut_fond = "#FFFFFF" +couleur_defaut_fond_tuple = (1,1,1) +couleur_defaut_cadretxt = "#000000" +couleur_defaut_cadretxt_tuple = (0,0,0) +couleur_defaut_grille = "#7f7f7f" +couleur_defaut_grille_tuple = (0.5,0.5,0.5) + +#couleur_defaut_erreur = (0,0,0) # noir + # initialiser la config def config_init(): @@ -60,6 +80,13 @@ def config_init(): "nb_data":nombre_lignes_form, "age_0": "0j", "legende": "oui", - "positionlegende": "hg"} + "positionlegende": "hg", + "couleur1": couleur_defaut_1, + "couleur2": couleur_defaut_2, + "couleur3": couleur_defaut_3, + "couleur_fond": couleur_defaut_fond, + "couleur_grille": couleur_defaut_grille, + "couleur_cadretxt": couleur_defaut_cadretxt + } diff --git a/data/changelog_data.txt b/data/changelog_data.txt index f939444..c10f53e 100644 --- a/data/changelog_data.txt +++ b/data/changelog_data.txt @@ -1,6 +1,8 @@ "Version 0.4","18/06/2020","" diff --git a/data_OMS/licence b/data_OMS/licence new file mode 100644 index 0000000..1e96007 --- /dev/null +++ b/data_OMS/licence @@ -0,0 +1,100 @@ +-------------- +Les documents de ce dossier sont sous licence CC BY-NC-SA 3.0 IGO + +Les quatre fichiers : wfa_boys_p_exp.txt wfa_girls_p_exp.txt wfa_boys_z_exp.txt wfa_girls_z_exp.txt sont les données de l'Organisation Mondiale de la Santé (OMS) et peuvent être retrouvés ici : +https://www.who.int/childgrowth/standards/weight_for_age/en/ + +Les deux autres fichiers : wfa_mix_p_exp.txt et wfa_mix_z_exp.txt ont été générés à partir des fichiers de l'OMS. + +-------------- +Résumé de la licence en français (voir https://creativecommons.org/licenses/by-nc-sa/3.0/igo/deed.fr) + +Vous êtes autorisé à : + +Partager - copier, distribuer et communiquer le matériel par tous moyens et sous tous formats +Adapter - remixer, transformer et créer à partir du matériel + + L'Offrant ne peut retirer les autorisations concédées par la licence tant que vous appliquez les termes de cette licence. + +Selon les conditions suivantes : + + Attribution - Vous devez créditer l'Oeuvre, intégrer un lien vers la licence et indiquer si des modifications ont été effectuées à l'Oeuvre. Vous devez indiquer ces informations par tous les moyens raisonnables, sans toutefois suggérer que l'Offrant vous soutient ou soutient la façon dont vous avez utilisé son Oeuvre. + + Pas d'Utilisation Commerciale - Vous n'êtes pas autorisé à faire un usage commercial de cette Oeuvre, tout ou partie du matériel la composant. + + Partage dans les Mêmes Conditions - Dans le cas où vous effectuez un remix, que vous transformez, ou créez à partir du matériel composant l'Oeuvre originale, vous devez diffuser l'Oeuvre modifiée dans les même conditions, c'est à dire avec la même licence avec laquelle l'Oeuvre originale a été diffusée. + + Pas de restrictions complémentaires - Vous n'êtes pas autorisé à appliquer des conditions légales ou des mesures techniques qui restreindraient légalement autrui à utiliser l'Oeuvre dans les conditions décrites par la licence. + +-------------- +Texte complet de licence, en anglais + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE (“LICENSE”). THE LICENSOR (DEFINED BELOW) HOLDS COPYRIGHT AND OTHER RIGHTS IN THE WORK. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION FOR YOUR ACCEPTANCE AND AGREEMENT TO THE TERMS OF THE LICENSE. + +1. Definitions + + “IGO” means, solely and exclusively for purposes of this License, an organization established by a treaty or other instrument governed by international law and possessing its own international legal personality. Other organizations established to carry out activities across national borders and that accordingly enjoy immunity from legal process are also IGOs for the sole and exclusive purposes of this License. IGOs may include as members, in addition to states, other entities. + "Work" means the literary and/or artistic work eligible for copyright protection, whatever may be the mode or form of its expression including digital form, and offered under the terms of this License. It is understood that a database, which by reason of the selection and arrangement of its contents constitutes an intellectual creation, is considered a Work. + "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License and may be, but is not necessarily, an IGO. + "You" means an individual or entity exercising rights under this License. + "License Elements" means the following high-level license attributes as selected by the Licensor and indicated in the title of this License: Attribution, Noncommercial, ShareAlike. + "Reproduce" means to make a copy of the Work in any manner or form, and by any means. + "Distribute" means the activity of making publicly available the Work or Adaptation (or copies of the Work or Adaptation), as applicable, by sale, rental, public lending or any other known form of transfer of ownership or possession of the Work or copy of the Work. + "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. + "Adaptation" means a work derived from or based upon the Work, or upon the Work and other pre-existing works. Adaptations may include works such as translations, derivative works, or any alterations and arrangements of any kind involving the Work. For purposes of this License, where the Work is a musical work, performance, or phonogram, the synchronization of the Work in timed-relation with a moving image is an Adaptation. For the avoidance of doubt, including the Work in a Collection is not an Adaptation. + "Collection" means a collection of literary or artistic works or other works or subject matter other than works listed in Section 1(b) 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. For the avoidance of doubt, a Collection will not be considered as an Adaptation. + +2. Scope of this License. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright protection. + +3. License Grant. Subject to the terms and conditions of this License, the Licensor hereby grants You a worldwide, royalty-free, non-exclusive license to exercise the rights in the Work as follows: + + to Reproduce, Distribute and Publicly Perform the Work, to incorporate the Work into one or more Collections, and to Reproduce, Distribute and Publicly Perform the Work as incorporated in the Collections; and, + to create, Reproduce, Distribute and Publicly Perform Adaptations, provided that You clearly label, demarcate or otherwise identify that changes were made to the original Work. + +This License lasts for the duration of the term of the copyright in the Work licensed by the Licensor. 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. All rights not expressly granted by the Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(e). + +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 (see section 8(a)). 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 a Licensor You must, to the extent practicable, remove from the Collection any credit (inclusive of any logo, trademark, official mark or official emblem) as required by Section 4(d), as requested. If You create an Adaptation, upon notice from a Licensor You must, to the extent practicable, remove from the Adaptation any credit (inclusive of any logo, trademark, official mark or official emblem) as required by Section 4(d), 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; or (iii) either the unported Creative Commons license or a ported Creative Commons license (either this or a later license version) containing the same License Elements (the “Applicable License”). (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 this 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. + You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be primarily intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works. + 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) any attributions that the Licensor indicates be associated with the Work as indicated in a copyright notice, (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that the 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 Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation. The credit required by this Section 4(d) may be implemented in any reasonable manner; provided, however, that in the case of an Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributors to 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 contributors. 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 Licensor or others designated for attribution, of You or Your use of the Work, without the separate, express prior written permission of the Licensor or such others. + + 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 reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and, + Voluntary License Schemes. To the extent possible, the Licensor waives the right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary licensing scheme. In all other cases the Licensor expressly reserves the right to collect such royalties. + Except as otherwise agreed in writing by the Licensor, 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 honor or reputation of the Licensor where moral rights apply. + +5. Representations, Warranties and Disclaimer + +THE 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, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. + +6. Limitation on Liability + +IN NO EVENT WILL THE 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 THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. Termination + + Subject to the terms and conditions set forth in this License, the license granted here lasts for the duration of the term of the copyright in the Work licensed by the Licensor as stated in Section 3. Notwithstanding the above, the 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 below. + If You fail to comply with this License, then 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. Notwithstanding the foregoing, this License reinstates automatically as of the date the violation is cured, provided it is cured within 30 days of You discovering the violation, or upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 7(b) does not affect any rights the Licensor may have to seek remedies for violations of this License by You. + +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, the 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, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action, 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 Licensor. + This License constitutes the entire agreement between You and the Licensor with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. The 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). Interpretation of the scope of the rights granted by the Licensor and the conditions imposed on You under this License, this License, and the rights and conditions set forth herein shall be made with reference to copyright as determined in accordance with general principles of international law, including the above mentioned conventions. + Nothing in this License constitutes or may be interpreted as a limitation upon or waiver of any privileges and immunities that may apply to the Licensor or You, including immunity from the legal processes of any jurisdiction, national court or other authority. + + Where the Licensor is an IGO, any and all disputes arising under this License that cannot be settled amicably shall be resolved in accordance with the following procedure: + Pursuant to a notice of mediation communicated by reasonable means by either You or the Licensor to the other, the dispute shall be submitted to non-binding mediation conducted in accordance with rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with those communicated in the notice of mediation. The language used in the mediation proceedings shall be English unless otherwise agreed. + If any such dispute has not been settled within 45 days following the date on which the notice of mediation is provided, either You or the Licensor may, pursuant to a notice of arbitration communicated by reasonable means to the other, elect to have the dispute referred to and finally determined by arbitration. The arbitration shall be conducted in accordance with the rules designated by the Licensor in the copyright notice published with the Work, or if none then in accordance with the UNCITRAL Arbitration Rules as then in force. The arbitral tribunal shall consist of a sole arbitrator and the language of the proceedings shall be English unless otherwise agreed. The place of arbitration shall be where the Licensor has its headquarters. The arbitral proceedings shall be conducted remotely (e.g., via telephone conference or written submissions) whenever practicable. + Interpretation of this License in any dispute submitted to mediation or arbitration shall be as set forth in Section 8(f), above. + diff --git a/gestionOMS.py b/gestionOMS.py index 0ff4d5d..5b773d9 100644 --- a/gestionOMS.py +++ b/gestionOMS.py @@ -7,6 +7,7 @@ Created on Mon May 18 08:59:11 2020 """ from gestion_erreurs import * from configuration import * +from gestion_couleurs import * import csv @@ -35,13 +36,20 @@ def affichepercentile(pc): def afficheecarttype(z): if z==0: return "Moyenne" - elif z<0: - return str(z)+"z" else: - return "+"+str(z)+"z" - -liste_data_labels_p = [(nocol,affichepercentile(pc),degrade(pc)) for (nocol,pc) in liste_data_choisie_p] -liste_data_labels_z = [(nocol,afficheecarttype(z),degrade((z+3)/3*50) ) for (nocol,z) in liste_data_choisie_z] + #return ("z = "+str(z)) + if z>0: + chaine = r"$+"+str(z)+" \sigma$" + else: + chaine = r"$"+str(z)+"\sigma$" + return (chaine) + +def renvoie_liste_labels(conf,liste_data_choisie_p,liste_data_choisie_z,liste_err): + """ fabrique les deux listes de labels OMS""" + #warning(str(liste_data_choisie_p),liste_err) + liste_data_labels_p = [(nocol,affichepercentile(pc),degrade_choix(conf["couleur1"],conf["couleur2"],conf["couleur3"],pc)) for (nocol,pc) in liste_data_choisie_p] + liste_data_labels_z = [(nocol,afficheecarttype(z),degrade_choix(conf["couleur1"],conf["couleur2"],conf["couleur3"],(z+3)/3*50) ) for (nocol,z) in liste_data_choisie_z] + return liste_data_labels_p,liste_data_labels_z #liste_data_labels= liste_data_labels_z diff --git a/gestion_couleurs.py b/gestion_couleurs.py new file mode 100644 index 0000000..c1b3690 --- /dev/null +++ b/gestion_couleurs.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + + +### Gérer les couleurs + +from gestion_erreurs import * + +def rgb_vers_tuple(chaine,defaut,liste_err): + """ convertit une chaine rgb genre #00FF1B + vers un tuple python (entre 0 et 1) + En cas d'erreur, on met un warning et on renvoie + le defaut""" + chaine2 = chaine.lstrip("#") + try: + r = int(chaine2[0:2],16)/255 + v = int(chaine2[2:4],16)/255 + b = int(chaine2[4:6],16)/255 + except: + warning("Impossible de convertir la couleur "+chaine,liste_err) + return defaut + return (r,v,b) + +def tuple_vers_rgb( t): + """ conversion inverse : renvoie une chaine + de type #FF0045""" + (r,v,b) = t + if (r>1): + r=1 + elif r<0: + r=0 + if (v>1): + v=1 + elif v<0: + v=0 + if (b>1): + b=1 + elif b<0: + b=0 + + r = int(r*255) + v = int(v*255) + b = int(b*255) + return '#%02x%02x%02x' % (r,v,b) + +def progressif(x,y,nb): + """ renvoie x pour 0, y pour 50, + et entre deux pour les intermédiaires""" + return (x*(50-nb)/50 + y*nb/50) + +def degrade_choix(col1,col2,col3,nb): + """ retourne un dégradé entre col1 et col2 (nb<50) + et entre col2 et col3 (nb>50)""" + if nb>100: + nb=100 + elif nb<0: + nb = 0 + + if nb<50: + return tuple( progressif(col1[i],col2[i],nb) for i in (0,1,2) ) + else: + return tuple( progressif(col2[i],col3[i],nb-50) for i in (0,1,2) ) \ No newline at end of file diff --git a/gestion_donnees.py b/gestion_donnees.py index a2d0a1e..caacaf0 100644 --- a/gestion_donnees.py +++ b/gestion_donnees.py @@ -3,6 +3,7 @@ from configuration import * from gestion_erreurs import * +from gestion_couleurs import * import datetime import json import unidecode @@ -239,19 +240,29 @@ def gere_configuration(data,liste_err): positionlegende = "upper left" configuration["positionlegende"] = positionlegende + #warning("bla"+data["couleur1"],liste_err) + coul1 = rgb_vers_tuple(data.get("couleur1",""),couleur_defaut_1_tuple,liste_err) + coul2 = rgb_vers_tuple(data.get("couleur2",""),couleur_defaut_2_tuple,liste_err) + coul3 = rgb_vers_tuple(data.get("couleur3",""),couleur_defaut_3_tuple,liste_err) + #warning("bla2"+str(coul1),liste_err) + configuration["couleur1"] = coul1 + configuration["couleur2"] = coul2 + configuration["couleur3"] = coul3 + + # couleur de fond + coul_fond = rgb_vers_tuple(data.get("couleur_fond",""),couleur_defaut_fond_tuple,liste_err) + configuration["couleur_fond"] = coul_fond + + # couleur d'axes et de texte + coul_cadretxt = rgb_vers_tuple(data.get("couleur_cadretxt",""),couleur_defaut_cadretxt_tuple,liste_err) + configuration["couleur_cadretxt"] = coul_cadretxt + + # couleur de la grille + coul_grille = rgb_vers_tuple(data.get("couleur_grille",""),couleur_defaut_grille_tuple,liste_err) + configuration["couleur_grille"] = coul_grille + #warning(str(configuration["couleur1"]),liste_err) + return configuration - -#def configuration_vers_texte(config): -# """ exporte le texte associé à une configuration -# on dumpe simplement sauf pour maxi """ -# texte = "# Section configuration\n" -# for (cle,val) in config.items(): -# if cle != "maxi": -# texte+= cle + "=" + str(val) + "\n" -# else: -# texte+= cle + "=" + convertit_age_vers_texte(val)+"\n" -# texte +="\n" -# return texte def gere_donneespoids(data,naissance,liste_err): @@ -289,18 +300,6 @@ def gere_donneespoids(data,naissance,liste_err): l_poids = [x[1] for x in liste_donnees] return (l_jours,l_poids) - - -#def donnees_poids_vers_texte(l_jours,l_poids): -# """ retourne le texte correspondant aux données de poids """ -# texte = "# Section données\n" -# -# for i in range(len(l_poids)): -# texte +=convertit_age_vers_texte(l_jours[i])+","+convertit_poids_vers_texte(l_poids[i])+"\n" -# -# texte+="\n" -# return texte - @@ -316,41 +315,14 @@ def donnees_vers_json(l_jours,l_poids,config): gros_dico["naissance"] = convertit_date_vers_texte(gros_dico["naissance"]) # gérer l'age maxi gros_dico["maxi"] = convertit_age_vers_texte(gros_dico["maxi"]) + # gérer les couleurs + for cle in ["couleur1", "couleur2", "couleur3", "couleur_fond","couleur_grille","couleur_cadretxt"]: + gros_dico[cle] = tuple_vers_rgb(gros_dico[cle]) + + return json.dumps(gros_dico, indent=2,ensure_ascii=False ) -#def fichier_texte_vers_configdonnees(fichier,liste_err): -# """ prend le texte importé et l'exporte vers configuration et données -# sous forme de valeurs du formulaire """ -# -# valform = {} -# indice_formulaire = 0 # l'indice du formulaire pour les données : age_1, date_1, poids_1 etc -# num_ligne = 0 -# lignes = fichier.readlines() -# for ligne in lignes: -# num_ligne +=1 -# ligne = str(ligne,"utf8") -# ligne = ligne.rstrip("\n") -# if ligne != "" and ligne[0] != "#" and not(ligne.isspace()): # les lignes commençant par # sont des commentaires -# # On essaie de partitionner pour voir -# (var,egal,val) = ligne.partition("=") -# if egal == "=": # c'est une ligne de config -# valform[var] = val -# else: -# (age,virgule,poids) = ligne.partition(",") # On partitionne avec , -# if virgule == ",": -# # c'est une ligne de data -# valform["age_"+str(indice_formulaire)] = age -# valform["poids_"+str(indice_formulaire)] = poids -# indice_formulaire +=1 -# -# else: -# warning("La ligne "+str(num_ligne)+" n'est pas reconnue et sera ignorée : <"+ligne+">",liste_err) -# -# #le nb max du formulaire -# valform["nb_data"] = max(indice_formulaire +2,nombre_lignes_form) -# -# return valform def fichier_json_vers_configdonnees(fichier,liste_err): """ prend le json importé et l'exporte vers les valeurs du formulaire """ diff --git a/licence b/licence new file mode 100644 index 0000000..f9241d4 --- /dev/null +++ b/licence @@ -0,0 +1,20 @@ +Copyright (c) 2020 Denise Maurice + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/static/style.css b/static/style.css index 58fdd24..97f20d9 100644 --- a/static/style.css +++ b/static/style.css @@ -1,7 +1,25 @@ body { - background-color:#CCCCCC; + background-color:#EEEEEE; } +h1 { + background: #55f; + padding: 5px 10px; + border-radius: 10px; + color: #ffc0b0; + text-align: center; +} + +#warnings { + background: #ff8060; +} + +input[type="text"] { + max-width: 20vw; +} + + + #sectioncourbe { display: none; } diff --git a/templates/apropos.html b/templates/apropos.html index ba8ade3..9f2b076 100644 --- a/templates/apropos.html +++ b/templates/apropos.html @@ -5,5 +5,6 @@

Ces données, ainsi que ce site web, sont sous licence CC BY-NC-SA 3.0 IGO

+

Le code source (licence MIT sauf en ce qui concerne les données) est disponible là.

{% endblock %} diff --git a/templates/index.html b/templates/index.html index 60693d4..2b1b82b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -76,7 +76,7 @@ {% endfor %} -
  • +
  • Dimensions du graphique :
  • @@ -86,24 +86,18 @@ Position :
  • +
  • Couleur courbe du bas | Couleur courbe du milieu | Couleur courbe du haut
  • +
  • Couleur du fond | Couleur de la grille | Couleur des axes, texte et courbe
  • - +

    -
    - -

    Courbe

    - -
    - -
    -

    Alerte : la courbe a eu quelques soucis à se générer. Voici la liste des erreurs.

    @@ -112,6 +106,15 @@ Position :