Commentaires initiaux et ajout de deux fonctions relatives au BMI
This commit is contained in:
parent
d6e4046c8f
commit
b715e3d8e8
|
@ -23,8 +23,8 @@ msgstr "Un script en ligne de commande pour gérer votre poids."
|
|||
msgid "optional : file data"
|
||||
msgstr "fichier de données : optionnel"
|
||||
|
||||
msgid "optional : weight"
|
||||
msgstr "poids : optionnel"
|
||||
msgid "optional : weight in kilogram"
|
||||
msgstr "poids : optionnel en kilogramme"
|
||||
|
||||
msgid "optional : type"
|
||||
msgstr "type : optionnel"
|
||||
|
@ -79,3 +79,6 @@ msgstr "-votre commentaire : {comment}"
|
|||
|
||||
msgid "-other : {other}"
|
||||
msgstr "-autre : {other}"
|
||||
|
||||
msgid "optional : size in meter"
|
||||
msgstr "taille en mètre : optionnelle"
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
1.7
|
|
@ -40,7 +40,16 @@ _ = en.gettext # english
|
|||
# Voir : https://medium.com/i18n-and-l10n-resources-for-developers/how-to-translate-python-applications-with-the-gnu-gettext-module-5c1c085041
|
||||
|
||||
"""
|
||||
A measurement is characterized by :
|
||||
This program allow you to store and visualise your weight.
|
||||
No database is necessary because all is stored in files.
|
||||
Three files are important :
|
||||
- weight-cli.py, the principal program
|
||||
- data2.csv, the data file and
|
||||
- Fonctionnel.txt, the code for Gnuplot
|
||||
But other files are present, as personal.txt with your other
|
||||
parameters.
|
||||
|
||||
A measure is characterized by :
|
||||
- its value
|
||||
- its type
|
||||
- its date
|
||||
|
@ -48,6 +57,12 @@ A measurement is characterized by :
|
|||
- its identifier
|
||||
- one comment
|
||||
- other
|
||||
|
||||
Actually, weight-cli allow to add or remove a measure,
|
||||
visualise all the measure, plot a graph of these.
|
||||
|
||||
To know witch parameters are available, type :
|
||||
weight-cli --help or weight-cli -h
|
||||
"""
|
||||
|
||||
def save_file_data():
|
||||
|
@ -66,7 +81,6 @@ def save_file_data():
|
|||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
|
||||
def save_mesure():
|
||||
""" Displaying and recording a measure """
|
||||
print(_("Your measure has been recorded"))
|
||||
|
@ -183,6 +197,11 @@ def plot_graph():
|
|||
stdout, stderr = process.communicate()
|
||||
#print(stdout)
|
||||
|
||||
def save_size():
|
||||
""" Store the size """
|
||||
f = open('personal.txt', "w")
|
||||
f.write(str(args.size))
|
||||
f.close()
|
||||
|
||||
def tests_subproc():
|
||||
""" Test of the subprocess module """
|
||||
|
@ -190,6 +209,22 @@ def tests_subproc():
|
|||
stdout, stderr = process.communicate()
|
||||
print(stdout)
|
||||
|
||||
def bmi(the_weight):
|
||||
""" Return the BMI for a given weight """
|
||||
f = open('personal.txt', "r")
|
||||
the_size = float(f.read())
|
||||
f.close()
|
||||
bmi = the_weight / pow(the_size, 2)
|
||||
return(bmi)
|
||||
|
||||
def bmi_weight_max():
|
||||
""" Return the weight for BMI max """
|
||||
f = open('personal.txt', "r")
|
||||
the_size = float(f.read())
|
||||
f.close()
|
||||
weight_max = 29.9 * pow(the_size, 2)
|
||||
return(weight_max)
|
||||
|
||||
### Main ###
|
||||
""" Weight Recording Program
|
||||
Be careful, the data.csv file has a header line that lacks
|
||||
|
@ -205,10 +240,15 @@ parser.add_argument('-da', '--data',
|
|||
default='data2.csv',
|
||||
help=_('optional : file data')
|
||||
)
|
||||
parser.add_argument('-s', '--size',
|
||||
type=float,
|
||||
default=-1,
|
||||
help=_('optional : size in meter')
|
||||
)
|
||||
parser.add_argument('-w', '--weight',
|
||||
type=float,
|
||||
default=-1,
|
||||
help=_('optional : weight')
|
||||
help=_('optional : weight in kilogram')
|
||||
)
|
||||
parser.add_argument('-t', '--type',
|
||||
default='WEIGHT',
|
||||
|
@ -268,6 +308,8 @@ args = parser.parse_args()
|
|||
# Launching of actions
|
||||
if args.data != 'data2.csv':
|
||||
save_file_data()
|
||||
if args.size != -1:
|
||||
save_size()
|
||||
if args.weight != -1:
|
||||
save_mesure()
|
||||
if args.read:
|
||||
|
|
Loading…
Reference in New Issue