From d97dd05eab5622266abfe273c33ca9d26ccbd183 Mon Sep 17 00:00:00 2001 From: Mars Liu Date: Wed, 29 Dec 2021 12:21:25 +0800 Subject: [PATCH] reflection for author search --- main.py | 17 ++++++----------- src/tree.py | 9 +++++++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index b3de0bf..69afaa0 100644 --- a/main.py +++ b/main.py @@ -9,17 +9,12 @@ if __name__ == '__main__': ignore_keywords=True, enable_notebook=False, authors={ - "Python小白进阶": "youcans", - "youcans": "youcans", - "AI浩": "hhhhhhhhhhwwwwwwwwww", - "hhhhhhhhhhwwwwwwwwww": "hhhhhhhhhhwwwwwwwwww", - "吴佳WuJia": "yvettewu", - "yvettewu": "yvettewu", - "幻灰龙": "huanhuilong", - "feilong": "huanhuilong", - "huanhuilong": "huanhuilong", - "xiaozhi_5638": "xiaozhi_5638", - "请叫我卷福": "xiaozhi_5638" + "youcans":["Python小白进阶"], + "hhhhhhhhhhwwwwwwwwww":["AI浩"], + "yvettewu": ["吴佳WuJia"], + "huanhuilong":["幻灰龙", + "feilong"], + "xiaozhi_5638": ["请叫我卷福"], } ) walker.walk() diff --git a/src/tree.py b/src/tree.py index 99a6936..7a18dd2 100644 --- a/src/tree.py +++ b/src/tree.py @@ -16,6 +16,12 @@ formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) 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): ret = subprocess.Popen([ @@ -27,8 +33,7 @@ def user_name(md_file, author_dict): if line.startswith('Author'): author_lines.append(line.split(' ')[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): with open(p, 'r') as f: -- GitLab