mirror of
https://github.com/firmai/financial-machine-learning.git
synced 2026-08-19 05:48:07 +00:00
auto update readme
This commit is contained in:
+26
-1
@@ -22,9 +22,10 @@ def get_wiki_rating(input_rating):
|
||||
return '<sub>{}</sub>'.format(result_text)
|
||||
|
||||
|
||||
def generate_wiki_per_category(output_path):
|
||||
def generate_wiki_per_category(output_path, update_readme: bool = True):
|
||||
"""
|
||||
|
||||
:param update_readme:
|
||||
:param output_path:
|
||||
"""
|
||||
repo_df = get_repo_list()
|
||||
@@ -44,6 +45,7 @@ def generate_wiki_per_category(output_path):
|
||||
'rating': category_df['rating']
|
||||
})
|
||||
# add color for the status
|
||||
formatted_df = formatted_df.sort_values(by=['rating', 'star_count'], ascending=False).reset_index(drop=True)
|
||||
formatted_df['repo_status'] = formatted_df['repo_status'].apply(lambda x: get_wiki_status_color(x))
|
||||
formatted_df['rating'] = formatted_df['rating'].apply(lambda x: get_wiki_rating(x))
|
||||
formatted_df.columns = ['<sub>{}</sub>'.format(x) for x in formatted_df.columns]
|
||||
@@ -54,6 +56,29 @@ def generate_wiki_per_category(output_path):
|
||||
f.write(formatted_df.to_markdown(index=False))
|
||||
print('wiki generated in [{}]'.format(output_path_full))
|
||||
|
||||
if update_readme:
|
||||
check_str = '[PLACEHOLDER:{}]'.format(clean_category_name)
|
||||
all_read_me = ''
|
||||
with open(os.path.join(PROJECT_ROOT_DIR, 'README.md')) as f:
|
||||
all_read_me = f.read()
|
||||
if check_str not in all_read_me:
|
||||
print(f'section {check_str} not found')
|
||||
continue
|
||||
|
||||
# only display top 5, then expandable for extra 5
|
||||
with open(os.path.join(PROJECT_ROOT_DIR, 'README.md'), 'w') as f:
|
||||
table_str = formatted_df.iloc[:5].to_markdown(index=False)
|
||||
collapsible_str = """
|
||||
|
||||
<details>
|
||||
<summary><sub>next 5</sub></summary>
|
||||
{}
|
||||
</details>
|
||||
""".format(formatted_df.iloc[5:10].to_markdown(index=False))
|
||||
new_str = table_str + collapsible_str
|
||||
s = all_read_me.replace(check_str, new_str)
|
||||
f.write(s)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
local_path = os.path.join(PROJECT_ROOT_DIR, 'generated_wiki')
|
||||
|
||||
Reference in New Issue
Block a user