代码拉取完成,页面将自动刷新
同步操作将从 JackMa007/zju-icicles 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import os
EXCLUDE_DIRS = ['.git', 'docs', '.vscode', '.circleci']
README_MD = ['README.md', 'readme.md', 'index.md']
TXT_EXTS = ['md', 'txt']
TXT_URL_PREFIX = 'https://github.com/QSCTech/zju-icicles/blob/master/'
BIN_URL_PREFIX = 'https://github.com/QSCTech/zju-icicles/raw/master/'
def list_files(course: str):
filelist_texts = '## 文件列表\n\n'
readme_path = ''
for root, dirs, files in os.walk(course):
level = root.replace(course, '').count(os.sep)
indent = ' ' * 4 * level
filelist_texts += '{}- {}\n'.format(indent, os.path.basename(root))
subindent = ' ' * 4 * (level + 1)
for f in files:
if f not in README_MD:
if f.split('.')[-1] in TXT_EXTS:
filelist_texts += '{}- [{}]({})\n'.format(subindent,
f, '{}{}/{}'.format(TXT_URL_PREFIX, root, f))
else:
filelist_texts += '{}- [{}]({})\n'.format(subindent,
f, '{}{}/{}'.format(BIN_URL_PREFIX, root, f))
else:
readme_path = '{}/{}'.format(root, f)
return filelist_texts, readme_path
def generate_md(course: str, filelist_texts: str, readme_path: str):
final_texts = ['\n\n', filelist_texts]
if readme_path:
with open(readme_path, 'r') as file:
final_texts = file.readlines() + final_texts
with open('docs/{}.md'.format(course), 'w') as file:
file.writelines(final_texts)
if __name__ == '__main__':
courses = list(filter(lambda x: os.path.isdir(x) and (
x not in EXCLUDE_DIRS), os.listdir('.'))) # list courses
for course in courses:
filelist_texts, readme_path = list_files(course)
generate_md(course, filelist_texts, readme_path)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。