-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.py
More file actions
131 lines (123 loc) · 4.19 KB
/
menu.py
File metadata and controls
131 lines (123 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import ast
import chardet
import chardet
def kisiekle():
Marka = input("Araç Markasını giriniz:")
Model = input("Araç Modelini giriniz:")
Yil = input("Araç Yaşını giriniz:")
Plaka = input("Araç Plakasını giriniz:")
arac = {
"Marka": Marka,
"Model": Model,
"Yas": Yil,
"Plaka": Plaka
}
with open("Araclist.xx", "a", encoding="utf-8") as dosya:
dosya.write(f"{str(arac)}\n")
print(f"{Marka} {Model} {Yil} {Plaka} Plakalı Araç eklendi.")
def listele():
with open("Araclist.xx", "rb") as dosya:
raw_data = dosya.read()
result = chardet.detect(raw_data)
encoding = result['encoding']
with open("Araclist.xx", "r", encoding=encoding) as dosya:
aa = dosya.read()
print(aa)
def ara():
with open("Araclist.xx", "rb") as dosya:
raw_data = dosya.read()
result = chardet.detect(raw_data)
encoding = result['encoding']
with open("Araclist.xx", "r", encoding=encoding) as dosya:
okunan = dosya.readlines()
aranan = input("Aranan Plaka: ").lower()
bulundu = False
for satir in okunan:
arac = ast.literal_eval(satir.strip())
if arac["Plaka"].lower() == aranan:
print(arac)
bulundu = True
break
if not bulundu:
print(f"{aranan} plakalı araç sistemde yer almamaktadır.")
def duzelt():
with open("Araclist.xx", "rb") as dosya:
raw_data = dosya.read()
result = chardet.detect(raw_data)
encoding = result['encoding']
with open("Araclist.xx", "r", encoding=encoding) as dosya:
okunan = dosya.readlines()
aranan = input("Düzeltilecek plaka: ").lower()
yeni_liste = []
bulundu = False
for satir in okunan:
arac = ast.literal_eval(satir.strip())
if arac["Plaka"].lower() == aranan:
print(arac)
yeniAd = input("Yeni marka: ")
yeniModel = input("Yeni model: ")
yeniYas = input("Yeni yaş: ")
arac["Marka"] = yeniAd
arac["Model"] = yeniModel
arac["Yas"] = yeniYas
bulundu = True
yeni_liste.append(arac)
if not bulundu:
print(f"{aranan} plakalı araç sistemde yer almamaktadır.")
with open("Araclist.xx", "w", encoding="utf-8") as dosya:
for arac in yeni_liste:
dosya.write(f"{str(arac)}\n")
def sil():
with open("Araclist.xx", "rb") as dosya:
raw_data = dosya.read()
result = chardet.detect(raw_data)
encoding = result['encoding']
with open("Araclist.xx", "r", encoding=encoding) as dosya:
okunan = dosya.readlines()
aranan = input("Silinecek plaka: ").lower()
yeni_liste = []
bulundu = False
for satir in okunan:
arac = ast.literal_eval(satir.strip())
if arac["Plaka"].lower() != aranan:
yeni_liste.append(satir)
else:
bulundu = True
if not bulundu:
print(f"{aranan} plakalı araç sistemde yer almamaktadır.")
else:
with open("Araclist.xx", "w", encoding="utf-8") as dosya:
for satir in yeni_liste:
dosya.write(satir)
print(f"{aranan} plakalı araç silindi.")
def menu():
print("╔═══════════════════╗")
print("║ Kurye Araç ║")
print("║ Uygulaması ║")
print("║1-Araç Ekle ║")
print("║2-Araç Listele ║")
print("║3-Ara ║")
print("║4-Düzelt ║")
print("║5-Sil ║")
print("║ Seçiminiz nedir? ║")
print("╚═══════════════════╝")
secim = input("Seçiminizi Yapınız:")
if secim == "1":
kisiekle()
menu()
elif secim == "2":
listele()
menu()
elif secim == "3":
ara()
menu()
elif secim == "4":
duzelt()
menu()
elif secim == "5":
sil()
menu()
else:
print("Hatalı seçim. Lütfen tekrar deneyin.")
menu()
menu()