Skip to content

Commit f407d77

Browse files
committed
review code
1 parent bff8ddd commit f407d77

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

everyday_wechat/control/weather/sojson.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import json
55
import os
66

7+
__all__ = ['get_sojson_weather', 'get_sojson_weather_tomorrow']
78

89
with open(os.path.join(os.path.dirname(__file__), '_city_sojson.json'), 'r', encoding='utf-8') as f:
910
CITY_CODE_DICT = json.loads(f.read())
1011

11-
1212
MSG_TOMORROW = '明日{city_name}天气\n{_date} {week}\n【明日天气】{_type}\n【明日气温】{low_temp} {high_temp}\n【明日风速】{speed}\n【出行提醒】{notice}'
1313
MSG_TODAY = '今日{city_name}天气\n{_date},{week}\n【今日天气】{_type}\n【今日气温】{low_temp} {high_temp}\n【今日风速】{speed}\n【出行提醒】{notice}'
1414

@@ -80,7 +80,7 @@ def get_sojson_weather_tomorrow(city_name):
8080
"""
8181
if not city_name:
8282
return None
83-
city_code = city_dict.get(city_name, None)
83+
city_code = CITY_CODE_DICT.get(city_name, None)
8484
if not city_code:
8585
print('没有此城市的消息...')
8686
return None

everyday_wechat/utils/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import copy as mycopy
88
import yaml
99

10+
__all__ = ['set', 'get', 'copy', 'update', '_print']
11+
1012

1113
# def init():
1214
# """
@@ -36,29 +38,35 @@ def get_yaml():
3638
print('你的 _config.yaml 文件配置出错...')
3739
return None
3840

41+
3942
opts = get_yaml()
4043

44+
4145
def set(key, value):
4246
""" 通过 key 设置某一项值 """
4347
opts[key] = value
4448

49+
4550
def get(key, default=None):
4651
""" 通过 key 获取值 """
4752
return opts.get(key, default)
4853

54+
4955
def copy():
5056
""" 复制配置 """
5157
return mycopy.deepcopy(opts)
5258

59+
5360
def update(new_opts):
5461
""" 全部替换配置 """
5562
opts.update(new_opts)
5663

64+
5765
def _print():
5866
print(opts)
5967

68+
6069
if __name__ == '__main__':
61-
init()
6270
you = get('is_forced_switch')
6371
print(you)
6472
# print(copy())

0 commit comments

Comments
 (0)