Automation project tree directory

tree_str = ''
from pathlib import Path
def generate_tree(pathname, n=0):
    global tree_str
    if pathname.is_file():
        tree_str += '    |' * n + '-' * 4 + pathname.name + '\n'
    elif pathname.is_dir():
        tree_str += '    |' * n + '-' * 4 + \
            str(pathname.relative_to(pathname.parent)) + '\\' + '\n'
        for cp in pathname.iterdir():
            generate_tree(cp, n + 1)
if __name__ =='__main__':
    pathname = Path.cwd()
    generate_tree(pathname)
    print(tree_str)

----quality_management_logic
|----.idea
| |----encodings.xml
| |----misc.xml
| |----modules.xml
| |----quality_management_logic.iml
| |----workspace.xml
|----.pytest_cache
| |----.gitignore
| |----CACHEDIR.TAG
| |----README.md
| |----v
| | |----cache
| | | |----nodeids
| | | |----stepwise
|----applyCenter
| |----init.py
|----commonCenter
| |----Ada.py
| |----apiRequests.py
| |----caps.yaml
| |----comm.py
| |----DataManangerl.py
| |----data_pan.py
| |----encrypt_rsa.py
| |----logUtil.py
| |----Pan.py
| |----init.py
| |----pycache
| | |----Ada.cpython-37.pyc
| | |----apiRequests.cpython-37.pyc
| | |----comm.cpython-37.pyc
| | |----encrypt_rsa.cpython-37.pyc
| | |----logUtil.cpython-37.pyc
| | |----Pan.cpython-37.pyc
| | |----init.cpython-37.pyc
|----compare_excel.py
|----configCenter
| |----Telephoneverification.py
| |----init.py
|----dataCenter
| |----adaback.jpg
| |----adacard.jpg
| |----adacard_back.jpg
| |----adacard_front.jpg
| |----compare_data.py
| |----comrare_md5.py
| |----face.img
| |----frontImage.img
| |----get_adaback.py
| |----get_adacard.py
| |--- -get_adacard_yd.py
| |----get_pancard.py
| |----get_pancard_yd.py
| |----IDFY docking new input item 0424
version.xls | |----IDFY docking new input item 0424 version
1.xls
| |----in_data.py
| |----jietiao.py
| |----jietiao_data.py
| |----pancard.jpg | |----pancard_back.png
| |----pancard_front.png
| |----zhzj.py
| |---- init .py
| |---- pycache
| | |----compare_data.cpython-37.pyc
| | |----get_adacard_yd.cpython-37.pyc
| | |----get_pancard.cpython-37.pyc
| | |----get_pancard_yd.cpython-37.pyc
| | | |----in_data.cpython-37.pyc
| | | |----jietiao.cpython-37.pyc
| | |---- init 37.pyc-.cpython
| | ---- encryption .txt
| | ---- categories or subcategories .xls does not exist
| | ---- unencrypted .txt
| | ---- source .txt file
|----demo.py
|----GenTree.py
|----in_finance.py
|----in_finance_bak.py
|----lib
| |----common_lib.py
| |- ---read_write_excel.py
| |---- init .py
| |---- pycache
| | | |----common_lib.cpython-37.pyc
| | |---- init .cpython-37.pyc
|----logs
| |----debug.log
| |----debug.log.1
| |----errors.log
| |----info.log
|----main_t.py
|----requestsUnify
| |----init.py
|----settings.py
|----init.py
|----pycache
| |----main_t.cpython-37.pyc
| |----settings.cpython-37.pyc
| |----init.cpython-37.pyc

Process finished with exit code 0

Guess you like

Origin blog.csdn.net/kairui_guxiaobai/article/details/106365301