Add function undo remove a line.
This commit is contained in:
parent
0e26143ee2
commit
4e33c77308
@ -1,6 +1,3 @@
|
||||
6|WEIGHT|2020-04-15 11:16:58|True| |6e test|
|
||||
7|WEIGHT|2020-04-15 11:18:06|True| |7e test|
|
||||
8|WEIGHT|2020-04-15 11:26:06|true||8e test|
|
||||
9|WEIGHT|2020-04-15 11:27:45|true||9e test|
|
||||
10|WEIGHT|2020-04-15 11:39:12|true||10e test|
|
||||
10.1|WEIGHT|2020-04-15 15:22:22|true||11e test|
|
||||
13.0|WEIGHT|2020-04-20 17:39:31|true||8e test|
|
||||
|
|
1
remove.txt
Normal file
1
remove.txt
Normal file
@ -0,0 +1 @@
|
||||
2 13.0|WEIGHT|2020-04-20 17:39:31|true||8e test|
|
@ -77,11 +77,15 @@ def read_measures():
|
||||
data_file.close()
|
||||
|
||||
def remove_measure():
|
||||
''' Supprime une mesure '''
|
||||
''' Remove a measure '''
|
||||
f = open(args.data, "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
# remove the line item from list, by line number, starts from 0
|
||||
store_temp = str(args.remove)+' '+contents[args.remove]
|
||||
g = open('remove.txt', "w")
|
||||
g.write(str(store_temp))
|
||||
g.close()
|
||||
contents.pop(args.remove)
|
||||
|
||||
f = open(args.data, "w")
|
||||
@ -89,6 +93,22 @@ def remove_measure():
|
||||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
def undo_remove():
|
||||
''' Undo remove the last line removed '''
|
||||
f = open(args.data, "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
g = open('remove.txt', 'r')
|
||||
store_temp = g.readline().split(' ',1)
|
||||
g.close()
|
||||
# insert the line item from list, by line number, starts from 0
|
||||
contents.insert(int(store_temp[0]), store_temp[1])
|
||||
|
||||
f = open(args.data, "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
def trace_graph():
|
||||
''' Trace le graphe de l'évolution du poids avec Gnuplot '''
|
||||
#process = Popen(['gnuplot', 'Fonctionnel.txt'], stdout=PIPE, stderr=PIPE)
|
||||
@ -115,7 +135,7 @@ parser = argparse.ArgumentParser()
|
||||
# Création des arguments
|
||||
parser.add_argument('-da', '--data',
|
||||
default='data2.csv',
|
||||
help='optional data'
|
||||
help='optional file data'
|
||||
)
|
||||
parser.add_argument('-w', '--weight',
|
||||
type=float,
|
||||
@ -163,6 +183,10 @@ parser.add_argument('-tst', '--tests',
|
||||
help='optional tests operations',
|
||||
action='store_true'
|
||||
)
|
||||
parser.add_argument('-ur', '--undoremove',
|
||||
help='optional undo remove the last line removed',
|
||||
action='store_true'
|
||||
)
|
||||
# Récupération des arguments
|
||||
args = parser.parse_args()
|
||||
# Lancement des actions
|
||||
@ -176,5 +200,6 @@ if args.graph:
|
||||
trace_graph()
|
||||
if args.tests:
|
||||
tests_subproc()
|
||||
|
||||
if args.undoremove:
|
||||
undo_remove()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user