1
1
# def lists():
2
+ from MiniSystem .system import *
3
+ from MiniSystem .arquivo import *
2
4
people = {"Johnny Gabriel" : 26 , "Jorge Marcelino" : 30 , "Maria de Fatima" : 67 , "Clelia Pereira" : 61 , "Almir Aguiar" : 34 ,
3
5
"Cleiton Aguiar" : 36 , "Jéssica Lira" : 29 , "Lucas Cauan" : 9 , "Daniel Caique" : 8 }
4
6
# return people
5
7
# "Marcelo da Costa": 35
8
+ arq = "FileSystem.txt"
9
+
10
+
6
11
7
12
def menu (msg = "PRINCIPAL MENU" ):
8
13
a = "=" * 50
9
14
# msg = "MENU PRINCIPAL"
10
- c = a .count ("=" ) # conta quantas vezes aparece sinal '='
15
+ # c = a.count("=") # conta quantas vezes aparece sinal '='
11
16
print (a )
12
- c = c / 2
13
- d = c // 1.5
14
- d = int (d )
15
- print (' ' * (d ), f'{ msg } ' , ' ' * (d ))
17
+ # c = c / 2
18
+ # d = c // 1.5
19
+ # d = int(d)
20
+ # print(' ' * (d), f'{msg.center()}', ' ' * (d))
21
+ print (f'{ msg .center (50 )} ' )
16
22
print (a )
17
23
option ()
18
24
@@ -38,57 +44,32 @@ def option():
38
44
print ("\033 [0;34m3 - Quit of the system\033 [m" )
39
45
print ("=" * 50 )
40
46
choice = int (input ("Your option: " ))
41
- # if(type(choice) != int(choice)):
42
- # while(type(choice) != int(choice)):
43
- # choice = int(input("Your option: "))
44
- # if(choice.isnumeric()):
45
- # choice = int(choice)
46
- # else:
47
- # while(choice is not choice.isdigit()):
48
- # print("=" * 50)
49
- # print("\033[0;31mERROR!\033[m")
50
- # print(
51
- # "\033[0;34mType only:\n1 - See people's list\n2 - Registry new person or\n3 - Quit of the system\033[m")
52
- # choice = input("Your option: ")
53
- # print("=" * 50)
54
47
except :
55
- print ("=" * 50 )
56
- print ("\033 [0;31mERROR!\033 [m" )
57
- print ("\033 [0;34mType only:\033 [m" )
58
- # print(
59
- # "\033[0;34mType only:\n1 - See people's list\n2 - Registry new person or\n3 - Quit of the system\033[m")
60
- # choice = int(input("Your option: "))
61
- continue
62
- # choice = input("Your option: ")
63
- # while(choice.isnumeric() != int(choice)):
64
- # print("=" * 50)
65
- # print("\033[0;31mERROR!\033[m")
66
- # print("\033[0;34mType only:\n1 - See people's list\n2 - Registry new person or\n3 - Quit of the system\033[m")
67
- # choice = int(input("Your option: "))
68
- else :
69
- while (choice > 3 or choice < 0 ):
70
48
print ("=" * 50 )
71
49
print ("\033 [0;31mERROR!\033 [m" )
72
- print ("\033 [0;34mType only:\n 1 - See people's list\n 2 - Registry new person or\n 3 - Quit of the system\033 [m" )
73
- choice = int (input ("Your option: " ))
74
- print ("=" * 50 )
75
- # menu("="*30)
76
- if (choice == 1 ):
77
- seePeop ()
78
- elif (choice == 2 ):
79
- newReg ("NEW REGISTRY" )
80
- else :
81
- if (choice == 3 ):
82
- from time import sleep
83
- sleep (2 )
84
- print ("Logging out of the System so far!" )
85
- # else:
86
- # while (choice > 3 or choice < 0):
87
- # print("\033[0;31mERROR!\033[m")
88
- # print(
89
- # "\033[0;33mType only:\n1 - See people's list\n2 - Registry new person or\n3 - Quit of the system\033[m")
90
- # choice = int(input("Your option: "))
91
- # Error Handling
50
+ print ("\033 [0;34mType only:\033 [m" )
51
+ continue
52
+ else :
53
+ if (choice > 3 or choice < 0 ):
54
+ while (choice > 3 or choice < 0 ):
55
+ print ("=" * 50 )
56
+ print ("\033 [0;31mERROR!\033 [m" )
57
+ print ("\033 [0;34mType only:\n 1 - See people's list\n 2 - Registry new person or\n 3 - Quit of the system\033 [m" )
58
+ choice = int (input ("Your option: " ))
59
+ break
60
+ if (choice == 1 ):
61
+ readFile (arq )
62
+ break
63
+ elif (choice == 2 ):
64
+ newReg ("NEW REGISTRY" )
65
+ else :
66
+ if (choice == 3 ):
67
+ from time import sleep
68
+ sleep (2 )
69
+ print ("Logging out of the System so far!" )
70
+ break
71
+ break
72
+ break
92
73
93
74
94
75
def seePeop ():
@@ -109,11 +90,48 @@ def regPeop():
109
90
age = input ("Age: " )
110
91
while (age .isnumeric () != True ):
111
92
age = input ("Age: " )
112
- people [ name ] = age
113
- # for last in people.values():
114
- # if(last == name)
93
+ a = open ( arq , "at" )
94
+ a . write ( f" { name } ; { age } \n " )
95
+ # arq[name] = age
115
96
print (f"New registry noted of { name } added" )
97
+ a .close ()
116
98
menu ("PRINCIPAL MENU" )
117
99
118
- # menu("PRINCIPAL MENU")
119
- # option()
100
+
101
+ def filExist (nome ):
102
+ try :
103
+ a = open (nome , "rt" )
104
+ a .close ()
105
+ except FileNotFoundError :
106
+ return False
107
+ else :
108
+ return True
109
+
110
+
111
+
112
+ def creatFile (nome ):
113
+ try :
114
+ a = open (nome , "wt+" )
115
+ a .close ()
116
+ except :
117
+ print ("There is some problem with the create the file" )
118
+ else :
119
+ print (f"File { nome } , created with success!" )
120
+ readFile (arq )
121
+
122
+
123
+ def readFile (name ):
124
+ try :
125
+ a = open (name , "rt" )
126
+ except :
127
+ print ("There is a problem with the program" )
128
+ else :
129
+ # menu("List of People")
130
+ print ("List of People" )
131
+ for linhas in a :
132
+ dado = linhas .split (";" )
133
+ dado [1 ] = dado [1 ].replace ("\n " , "" )
134
+ print (f"{ dado [0 ]:<30} { dado [1 ]:>3} anos" )
135
+ print (a .read ())
136
+ finally :
137
+ option ()
0 commit comments