提交 d97dd05e 编写于 作者: M Mars Liu

reflection for author search

上级 6b2febf6
...@@ -9,17 +9,12 @@ if __name__ == '__main__': ...@@ -9,17 +9,12 @@ if __name__ == '__main__':
ignore_keywords=True, ignore_keywords=True,
enable_notebook=False, enable_notebook=False,
authors={ authors={
"Python小白进阶": "youcans", "youcans":["Python小白进阶"],
"youcans": "youcans", "hhhhhhhhhhwwwwwwwwww":["AI浩"],
"AI浩": "hhhhhhhhhhwwwwwwwwww", "yvettewu": ["吴佳WuJia"],
"hhhhhhhhhhwwwwwwwwww": "hhhhhhhhhhwwwwwwwwww", "huanhuilong":["幻灰龙",
"吴佳WuJia": "yvettewu", "feilong"],
"yvettewu": "yvettewu", "xiaozhi_5638": ["请叫我卷福"],
"幻灰龙": "huanhuilong",
"feilong": "huanhuilong",
"huanhuilong": "huanhuilong",
"xiaozhi_5638": "xiaozhi_5638",
"请叫我卷福": "xiaozhi_5638"
} }
) )
walker.walk() walker.walk()
......
...@@ -16,6 +16,12 @@ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') ...@@ -16,6 +16,12 @@ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter) handler.setFormatter(formatter)
logger.addHandler(handler) logger.addHandler(handler)
def search_author(author_dict, username):
for key in author_dict:
names = author_dict[key]
if username in names:
return key
return username
def user_name(md_file, author_dict): def user_name(md_file, author_dict):
ret = subprocess.Popen([ ret = subprocess.Popen([
...@@ -27,8 +33,7 @@ def user_name(md_file, author_dict): ...@@ -27,8 +33,7 @@ def user_name(md_file, author_dict):
if line.startswith('Author'): if line.startswith('Author'):
author_lines.append(line.split(' ')[1]) author_lines.append(line.split(' ')[1])
author_nick_name = author_lines[-1] author_nick_name = author_lines[-1]
return author_dict.get(author_nick_name, "") return search_author(author_dict, author_nick_name)
def load_json(p): def load_json(p):
with open(p, 'r') as f: with open(p, 'r') as f:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册