Skip to content

Commit c88a381

Browse files
Taha Dhiaeddine AmdouniTaha Dhiaeddine Amdouni
Taha Dhiaeddine Amdouni
authored and
Taha Dhiaeddine Amdouni
committed
commit from mac
1 parent a459794 commit c88a381

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+8562
-82
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# https://github.com/Omega014/AdventCalendarCollection
2+
3+
import json
4+
import os
5+
from datetime import datetime
6+
7+
import ui
8+
9+
import scraper
10+
11+
12+
class AdventCalendarCollection (object):
13+
def __init__(self):
14+
self.view = ui.load_view('AdventCalendarCollection')
15+
self.view.background_color = "#ffebd5"
16+
self.view.present('fullscreen')
17+
self.view.name = 'AdventCalendarCollection'
18+
self.reload_data(None)
19+
self.change_today_bg_color()
20+
21+
def refresh(self, sender):
22+
scraper.main()
23+
self.reload_data(None)
24+
25+
def reload_data(self, sender):
26+
filepath = os.path.join(os.path.realpath('./'), 'registrations.json')
27+
with open(filepath, 'r') as f:
28+
registrations = json.load(f)
29+
# jsonに保存する時点でdayだけ保存しても良いかもなぁ...
30+
for data in registrations:
31+
day = data['date'].split('-')[-1]
32+
if day[0] == '0':
33+
day = day[1]
34+
title = data['title']
35+
self.view['textview'+day].text = title
36+
37+
def change_today_bg_color(self):
38+
# 今日の日だけカレンダーの背景に色をつける
39+
today_datetime = datetime.now()
40+
if today_datetime.month == 12:
41+
today = str(today_datetime.day)
42+
self.view['textview'+today].background_color = '#ffd9d9'
43+
44+
45+
AdventCalendarCollection()

0 commit comments

Comments
 (0)