Skip to content

Commit

Permalink
message dans fih2chaine
Browse files Browse the repository at this point in the history
  • Loading branch information
byache committed Dec 25, 2021
1 parent 4e2aa75 commit e2cc380
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions pydiderotlibs/chaines.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def taille(objet):
return builtins.len(objet)


def fich2chaine(fichier='optionnel'):
def fich2chaine(fichier='optionnel', message=''):
"""
Retourne chaine formée du contenu du fichier ``fichier``.
Expand All @@ -36,13 +36,15 @@ def fich2chaine(fichier='optionnel'):
fich = tkf.askopenfile(
parent=fen,
mode='rb',
title="Choisissez un fichier")
title="Choisissez un fichier "+message)
try:
fen.destroy()
except BaseException:
pass
if fich is not None:
if not not fich : #si fich est différent de None ou de ()
fichier = fich.name
else:
return ""
if fichier != 'optionnel':
filin = open(fichier, 'r')
chaine = "\n".join([line.strip() for line in filin])
Expand Down
12 changes: 7 additions & 5 deletions pydiderotlibs/nmea.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import datetime
from .chaines import fich2chaine

#dans nmea_timedata et dans fich2chaine, revoir l'affichage d'un texte avant "choisissez un fichier"
#dans nmea_timedata et dans fich2chaine, revoir l'affichage d'un texte avant "choisissez un fichier"
#ajouter un test pour que le csv soit enregistré avec le suffixe .csv

def mk_dict(msg):
"""
Expand Down Expand Up @@ -75,7 +76,7 @@ def nmea_timedata(datatype,fichier='optionnel'):
fichier (file,optionnel): Le nom complet (avec le chemin) d'un fichier contenant des trames nmea.
"""
ch = fich2chaine(fichier)
ch = fich2chaine(fichier,"contenant les trames nmea.")
liste = []
typ = []
origin = None
Expand All @@ -101,7 +102,7 @@ def nmea_timedata(datatype,fichier='optionnel'):
except Exception as e:
excep=1
if excep==1:
print('Error while parsing.')
print('Error while parsing in nmea_timedata().')
return(liste)


Expand All @@ -122,7 +123,7 @@ def nmea2csv(entree='optionnel', fichier='optionnel'):
fen.destroy()
except BaseException:
pass
if not not fich: #si fich contient quelque chose
if not not fich: #si fich contient quelque chose de différent de None ou ()
entree = fich
else:
return False
Expand All @@ -138,6 +139,7 @@ def nmea2csv(entree='optionnel', fichier='optionnel'):
pass
if not not fich: #si fich contient quelque chose
fichier = fich.name
print(fich.name)
else:
return False
if entree != 'optionnel':
Expand All @@ -163,7 +165,7 @@ def nmea2csv(entree='optionnel', fichier='optionnel'):
except Exception as e:
excep=1
if excep==1:
print('Error while parsing.')
print('Error while parsing in nmea2csv().')
filout.close()
return True
else:
Expand Down

0 comments on commit e2cc380

Please sign in to comment.