@@ -74,10 +74,10 @@ def isLeapYear(year):
74
74
75
75
76
76
# 判断day是否是month的最后一天
77
- def isLastDayOfMonth (month , day ):
78
- if month == 2 and isLeapYear (YEAR ):
79
- return day == leapDay
80
- return day == monthLastDayMapping [month ]
77
+ def isLastDayOfMonth (num_month , num_day ):
78
+ if num_month == 2 and isLeapYear (YEAR ):
79
+ return num_day == leapDay
80
+ return num_day == monthLastDayMapping [num_month ]
81
81
82
82
83
83
if isLeapYear (YEAR ):
@@ -101,7 +101,7 @@ def isLastDayOfMonth(month, day):
101
101
festivals [month .zfill (2 ) + day .zfill (2 )] = f [0 ]
102
102
103
103
# 在这里增加想要添加的节日,可以覆盖掉上面的节日
104
- festivals ['0101' ] = '元旦'
104
+ # festivals['0101'] = '元旦'
105
105
106
106
res = []
107
107
langs = []
@@ -110,8 +110,7 @@ def isLastDayOfMonth(month, day):
110
110
codeLang = lang_json [langIndex ]
111
111
try :
112
112
url = 'https://zh.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&uselang=zh-cn&titles=' + \
113
- quote (codeLang [
114
- 'desc' ], 'utf-8' )
113
+ quote (codeLang ['desc' ], 'utf-8' )
115
114
# 请求头部
116
115
headers = {
117
116
'User-Agent' :
@@ -123,14 +122,13 @@ def isLastDayOfMonth(month, day):
123
122
# 读取响应,获得文本
124
123
wiki = json .loads (response .text )
125
124
desc = jsonpath .jsonpath (wiki , '$..extract' )
126
- codeLang ['descWiki' ] = desc [0 ].split ('\n ' )[0 ]
125
+ # codeLang['descWiki'] = desc[0].split('\n')[0]
126
+ codeLang ['descWiki' ] = desc [0 ].split ('。' )[0 ] + "。"
127
127
langIndex = langIndex + 1
128
128
except Exception as e :
129
- print ("!!!!!!!error!!!!!!!!! !" , e )
129
+ print ("Error !" , e )
130
130
continue
131
- code_string = open ('hacking-date/HackingDate.' + codeLang ['code' ],
132
- 'r' ,
133
- encoding = 'utf8' )
131
+ code_string = open ('hacking-date/HackingDate.' + codeLang ['code' ], 'r' , encoding = 'utf8' )
134
132
# 对内容中的特殊符合进行转义,以在HTML中显示
135
133
codeLang ['code' ] = html .escape (code_string .read ())
136
134
langs .append (codeLang )
@@ -213,6 +211,7 @@ def isLastDayOfMonth(month, day):
213
211
rows = rows + '</tr>'
214
212
215
213
# 生成后面的7天一页的日历
214
+ # noinspection PyUnboundLocalVariable
216
215
if weekday == 0 or len (page ) == 0 :
217
216
if PUNCHED :
218
217
page = pageTemplate .replace ('{{pclass}}' , 'page punched' )
@@ -231,6 +230,7 @@ def isLastDayOfMonth(month, day):
231
230
)
232
231
page = page .replace ('{{main-week}}' , f'{ weeks [date .getWeek ()]} ' )
233
232
page = page .replace ('{{mwclass}}' , 'main-week' )
233
+ # noinspection DuplicatedCode
234
234
if (str (date .getMonth ()).zfill (2 ) + str (date .getDay ()).zfill (2 )
235
235
in festivals .keys ()):
236
236
ldata = festivals [str (date .getMonth ()).zfill (2 ) +
@@ -276,8 +276,7 @@ def isLastDayOfMonth(month, day):
276
276
277
277
page = page .replace ('{{desc}}' , langs [langIndex ]['descWiki' ])
278
278
if QR :
279
- wiki_url = 'https://zh.wikipedia.org/wiki/' + quote (langs [langIndex ][
280
- 'desc' ], 'utf-8' )
279
+ wiki_url = 'https://zh.wikipedia.org/wiki/' + quote (langs [langIndex ]['desc' ], 'utf-8' )
281
280
# qr = 'https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=' + wiki_url
282
281
qr = 'https://chart.apis.google.com/chart?chs=360x360&cht=qr&choe=UTF-8&chld=M|0&chl=' + wiki_url
283
282
else :
@@ -289,6 +288,7 @@ def isLastDayOfMonth(month, day):
289
288
page = page .replace ('{{wclass' + str (weekday + 1 ) + '}}' , '' )
290
289
page = page .replace (f'{{{{date{ weekday + 1 } }}}}' , # 此处用fstring时一定要注意{要进行转义
291
290
str (date .getMonth ()).zfill (2 ) + "-" + str (date .getDay ()).zfill (2 ))
291
+ # noinspection DuplicatedCode
292
292
if (str (date .getMonth ()).zfill (2 ) + str (date .getDay ()).zfill (2 )
293
293
in festivals .keys ()):
294
294
ldata = festivals [str (date .getMonth ()).zfill (2 ) +
0 commit comments