2018-12-11 15:57:58 +08:00
|
|
|
''' mbinary
|
|
|
|
#########################################################################
|
|
|
|
# File : genReadme.py
|
|
|
|
# Author: mbinary
|
|
|
|
# Mail: zhuheqin1@gmail.com
|
2019-01-31 12:09:46 +08:00
|
|
|
# Blog: https://mbinary.xyz
|
2018-12-11 15:57:58 +08:00
|
|
|
# Github: https://github.com/mbinary
|
|
|
|
# Created Time: 2018-12-11 15:53
|
|
|
|
# Description:
|
|
|
|
#########################################################################
|
|
|
|
'''
|
|
|
|
# coding: utf-8
|
|
|
|
from tree import tree
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
from config import README
|
|
|
|
|
|
|
|
parser = ArgumentParser()
|
|
|
|
|
2020-04-15 12:28:20 +08:00
|
|
|
parser.add_argument('-p', '--path', default='.', help='path to walk')
|
|
|
|
parser.add_argument('-f', '--fileinclude', action='store_true',
|
|
|
|
default=True, help='if has, list files and dirs, else only dirs')
|
|
|
|
parser.add_argument('-d', '--depth', type=int, default=2)
|
|
|
|
# 获取参数
|
2018-12-11 15:57:58 +08:00
|
|
|
args = parser.parse_args()
|
|
|
|
FILE = args.fileinclude
|
|
|
|
PATH = args.path
|
|
|
|
DEPTH = args.depth
|
|
|
|
|
|
|
|
|
2020-04-15 12:28:20 +08:00
|
|
|
idxs = tree(PATH, DEPTH, FILE)
|
2018-12-11 15:57:58 +08:00
|
|
|
s = README.format(index='\n'.join(idxs))
|
2020-04-15 12:28:20 +08:00
|
|
|
with open('README.md', 'w') as f:
|
2018-12-11 15:57:58 +08:00
|
|
|
f.write(s)
|