-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate.py
112 lines (89 loc) · 2.99 KB
/
calculate.py
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
#Going to rewrite this project with sql and maybe transform it to a web app
from beebox import Beebox
import json
import time
#Gerekli kütüphaneler
#Kovan çıta sayısını geri döndürür
def cita_durum(no):
no = int(no)
with open("arilar.json","r",encoding="utf-8") as y:
data = json.load(y)
for i in data:
if i["No"] == no:
return (i["Cita"])
#Kovan durumunu geri döndürür
def durum_durum(no):
no = int(no)
with open("arilar.json","r",encoding="utf-8") as y:
data = json.load(y)
for i in data:
if i["No"] == no:
return(i["Durum"])
#Kovan ilaç durumunu geri döndürür
def ilac_durum(no):
no = int(no)
with open("arilar.json","r",encoding="utf-8") as y:
data = json.load(y)
for i in data:
if i["No"] == no:
return(i["Ilac"])
#Kovan sayısını geri döndürür eğer dosya ilk açılış yapıyorsa x=1 verir
#Bu kod otomatik sıralama yapar
def kovansayi():
try:
with open("arilar.json","r",encoding="utf-8") as y:
data = json.load(y)
x=1
for i in data:
x+=1
except:
x=1
return x
return x
# Burada uyarı vermesinin sebebi İ nin kullanılmamış olması burada i = n eleman sayısı
#Bir Kovanın tüm durumunu gösterir no parametresi alır
def durum_goster(no):
x=str(ilac_durum(no))
y=str(cita_durum(no))
v=str(durum_durum(no))
print(f"No: "+no+" Çıta: "+y+ " Durum: "+v+ " İlaç: " + x+"\n")
time.sleep(2)
#Tüm kovanların durumunu gösterir
def tum_durum():
with open("arilar.json","r",encoding="utf-8") as y:
data = json.load(y)
x=str(kovansayi()-1)
print("No - Çıta - Durum - İlaç\n")
time.sleep(1)
for i in data:
print(i["No"],"-",i["Cita"],"-",i["Durum"],"-",i["Ilac"])
print(f"\nToplam kovan sayısı: "+x+"\n")
time.sleep(3)
def edit_kovan(no):
with open("arilar.json","r+",encoding="utf-8") as y:
data = json.load(y)
no = int(no)
for i in data:
x = int(i["No"])
if x == no:
print("Method works")
def delete_kovan(no):
f = open("arilar.json","r+",encoding="utf-8")
data = json.load(f)
no = int(no)
for i in data:
x = int(i["No"])
if x == no:
no = no -1
del data[no]
print("Method works check if deleted correctly")
renumber = input("Yeniden numaralandır?")
if renumber =="Y":
x = 1
for i in data:
i["No"] = x
x+=1
with open("arilar.json","w",encoding="utf-8") as y:
json.dump(data,y)
print("\nİşlem başarılı..\n")
f.close