forked from heqin-zhu/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenReadme.py
More file actions
32 lines (28 loc) · 954 Bytes
/
genReadme.py
File metadata and controls
32 lines (28 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
''' mbinary
#########################################################################
# File : genReadme.py
# Author: mbinary
# Mail: [email protected]
# Blog: https://mbinary.xyz
# 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()
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)
#获取参数
args = parser.parse_args()
FILE = args.fileinclude
PATH = args.path
DEPTH = args.depth
idxs = tree(PATH,DEPTH,FILE)
s = README.format(index='\n'.join(idxs))
with open('README.md','w') as f:
f.write(s)