forked from werhereitacademy/Python_Modul_Week_2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzaman.py
More file actions
56 lines (38 loc) · 1.38 KB
/
zaman.py
File metadata and controls
56 lines (38 loc) · 1.38 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
from datetime import datetime, timedelta
import json
import os
import uye_islemleri
import kitap_islemleri
takip_dosyasi = "zaman.json"
def kontrol():
if not os.path.exists(takip_dosyasi):
with open(takip_dosyasi, "w", encoding= "utf-8") as t:
json.dump([], t, ensure_ascii = False, indent=4)
return True
def takip_oku():
kontrol()
with open(takip_dosyasi, "r", encoding= "utf-8") as t:
takip_listesi = json.load(f)
return takip_listesi
def takip_yaz(takip_listesi):
with open(takip_dosyasi, "w", encoding="utf-8") as t:
json.dump(takip_listesi, t, ensure_ascii=False, indent=4)
def takip_sil(uye_id, kitap_adi):
takip = takip_oku()
yeni_takip = []
for kayit in takip:
if not(kayit["id"]==uye_id and kayit["Kitap_adi"]==kitap_adi):
yeni_takip.append(kayit)
takip_yaz(yeni_takip)
def tarih(uye_id,kitap_adi):
bugun = datetime.now()
iki_hafta_sonra = bugun + timedelta(days=14)
suan = bugun.strftime("%Y-%m-%d")
ozel = iki_hafta_sonra.strftime("%Y-%m-%d")
odunc_kitap = {"id": uye_id, "Kitap_adi":kitap_adi,"Kayit_Tarihi": suan,"Kitap_iade_tarih":ozel}
takip = takip_oku()
takip.append(odunc_kitap)
takip_yaz(takip)
print(takip)
if __name__ == "__main__":
print(kontrol())