美文网首页
Python工程的文档结构

Python工程的文档结构

作者: SeanCheney | 来源:发表于2018-07-31 09:07 被阅读296次

    Python工程的文档结构,可以参考https://stackoverflow.com/questions/193161/what-is-the-best-project-structure-for-a-python-application

    有个答主提到了《Filesystem structure of a Python project》(http://as.ynchrono.us/2007/12/filesystem-structure-of-python-project_21.html),确实写的不错。这篇文章推荐的结构:

    Project/
    |-- bin/
    |   |-- project
    |
    |-- project/
    |   |-- test/
    |   |   |-- __init__.py
    |   |   |-- test_main.py
    |   |   
    |   |-- __init__.py
    |   |-- main.py
    |
    |-- setup.py
    |-- README
    

    开源工程对文档结构肯定更高些,可以参考:https://jeffknupp.com/blog/2013/08/16/open-sourcing-a-python-project-the-right-way/。作者Jeff Knupp还写过一本介绍Pythonic Code的小书,值得一看!(下载此书:https://github.com/iamseancheney/pythonbooks/blob/master/PythonStyle-Writing_idiomatic_python_3.pdf

    其实更好的方法,可能是直接去GitHub上参考高赞项目的结构,比如PySpider(https://github.com/binux/pyspider)的文档结构:

    PySpider
    .
    ├── Dockerfile
    ├── LICENSE
    ├── MANIFEST.in
    ├── README.md
    ├── data
    ├── docs
    │   ├── About-Projects.md
    │   ├── About-Tasks.md
    │   ├── Architecture.md
    │   ├── Command-Line.md
    │   ├── Deployment-demo.pyspider.org.md
    │   ├── Deployment.md
    │   ├── Frequently-Asked-Questions.md
    │   ├── Quickstart.md
    │   ├── Running-pyspider-with-Docker.md
    │   ├── Script-Environment.md
    │   ├── Working-with-Results.md
    │   ├── apis
    │   │   ├── @catch_status_code_error.md
    │   │   ├── @every.md
    │   │   ├── Response.md
    │   │   ├── index.md
    │   │   ├── self.crawl.md
    │   │   └── self.send_message.md
    │   ├── conf.py
    │   ├── imgs
    │   │   ├── creating_a_project.png
    │   │   ├── css_selector_helper.png
    │   │   ├── demo.png
    │   │   ├── developer-tools-network-filter.png
    │   │   ├── developer-tools-network.png
    │   │   ├── index_page.png
    │   │   ├── inspect_element.png
    │   │   ├── pyspider-arch.png
    │   │   ├── request-headers.png
    │   │   ├── run_one_step.png
    │   │   ├── search-for-request.png
    │   │   ├── tutorial_imdb_front.png
    │   │   └── twitch.png
    │   ├── index.md
    │   └── tutorial
    │       ├── AJAX-and-more-HTTP.md
    │       ├── HTML-and-CSS-Selector.md
    │       ├── Render-with-PhantomJS.md
    │       └── index.md
    ├── mkdocs.yml
    ├── pyspider
    │   ├── __init__.py
    │   ├── database
    │   │   ├── __init__.py
    │   │   ├── base
    │   │   │   ├── __init__.py
    │   │   │   ├── projectdb.py
    │   │   │   ├── resultdb.py
    │   │   │   └── taskdb.py
    │   │   ├── basedb.py
    │   │   ├── elasticsearch
    │   │   │   ├── __init__.py
    │   │   │   ├── projectdb.py
    │   │   │   ├── resultdb.py
    │   │   │   └── taskdb.py
    │   │   ├── local
    │   │   │   ├── __init__.py
    │   │   │   └── projectdb.py
    │   │   ├── mongodb
    │   │   │   ├── __init__.py
    │   │   │   ├── mongodbbase.py
    │   │   │   ├── projectdb.py
    │   │   │   ├── resultdb.py
    │   │   │   └── taskdb.py
    │   │   ├── mysql
    │   │   │   ├── __init__.py
    │   │   │   ├── mysqlbase.py
    │   │   │   ├── projectdb.py
    │   │   │   ├── resultdb.py
    │   │   │   └── taskdb.py
    │   │   ├── redis
    │   │   │   ├── __init__.py
    │   │   │   └── taskdb.py
    │   │   ├── sqlalchemy
    │   │   │   ├── __init__.py
    │   │   │   ├── projectdb.py
    │   │   │   ├── resultdb.py
    │   │   │   ├── sqlalchemybase.py
    │   │   │   └── taskdb.py
    │   │   └── sqlite
    │   │       ├── __init__.py
    │   │       ├── projectdb.py
    │   │       ├── resultdb.py
    │   │       ├── sqlitebase.py
    │   │       └── taskdb.py
    │   ├── fetcher
    │   │   ├── __init__.py
    │   │   ├── cookie_utils.py
    │   │   ├── phantomjs_fetcher.js
    │   │   ├── splash_fetcher.lua
    │   │   └── tornado_fetcher.py
    │   ├── libs
    │   │   ├── ListIO.py
    │   │   ├── __init__.py
    │   │   ├── base_handler.py
    │   │   ├── bench.py
    │   │   ├── counter.py
    │   │   ├── dataurl.py
    │   │   ├── log.py
    │   │   ├── multiprocessing_queue.py
    │   │   ├── pprint.py
    │   │   ├── response.py
    │   │   ├── result_dump.py
    │   │   ├── sample_handler.py
    │   │   ├── url.py
    │   │   ├── utils.py
    │   │   └── wsgi_xmlrpc.py
    │   ├── logging.conf
    │   ├── message_queue
    │   │   ├── __init__.py
    │   │   ├── beanstalk.py
    │   │   ├── kombu_queue.py
    │   │   ├── rabbitmq.py
    │   │   └── redis_queue.py
    │   ├── processor
    │   │   ├── __init__.py
    │   │   ├── processor.py
    │   │   └── project_module.py
    │   ├── result
    │   │   ├── __init__.py
    │   │   └── result_worker.py
    │   ├── run.py
    │   ├── scheduler
    │   │   ├── __init__.py
    │   │   ├── scheduler.py
    │   │   ├── task_queue.py
    │   │   └── token_bucket.py
    │   └── webui
    │       ├── __init__.py
    │       ├── app.py
    │       ├── bench_test.py
    │       ├── debug.py
    │       ├── index.py
    │       ├── login.py
    │       ├── result.py
    │       ├── static
    │       │   ├── css_selector_helper.min.js
    │       │   ├── debug.min.css
    │       │   ├── debug.min.js
    │       │   ├── index.min.css
    │       │   ├── index.min.js
    │       │   ├── package.json
    │       │   ├── result.min.css
    │       │   ├── result.min.js
    │       │   ├── src
    │       │   │   ├── css_selector_helper.js
    │       │   │   ├── debug.js
    │       │   │   ├── debug.less
    │       │   │   ├── index.js
    │       │   │   ├── index.less
    │       │   │   ├── result.less
    │       │   │   ├── splitter.js
    │       │   │   ├── task.less
    │       │   │   ├── tasks.less
    │       │   │   └── variable.less
    │       │   ├── task.min.css
    │       │   ├── task.min.js
    │       │   ├── tasks.min.css
    │       │   ├── tasks.min.js
    │       │   └── webpack.config.js
    │       ├── task.py
    │       ├── templates
    │       │   ├── debug.html
    │       │   ├── index.html
    │       │   ├── result.html
    │       │   ├── task.html
    │       │   └── tasks.html
    │       └── webdav.py
    ├── requirements.txt
    ├── run.py
    ├── setup.py
    ├── tests
    │   ├── __init__.py
    │   ├── data_fetcher_processor_handler.py
    │   ├── data_handler.py
    │   ├── data_sample_handler.py
    │   ├── data_test_webpage.py
    │   ├── test_base_handler.py
    │   ├── test_bench.py
    │   ├── test_counter.py
    │   ├── test_database.py
    │   ├── test_fetcher.py
    │   ├── test_fetcher_processor.py
    │   ├── test_message_queue.py
    │   ├── test_processor.py
    │   ├── test_response.py
    │   ├── test_result_dump.py
    │   ├── test_result_worker.py
    │   ├── test_run.py
    │   ├── test_scheduler.py
    │   ├── test_task_queue.py
    │   ├── test_utils.py
    │   ├── test_webdav.py
    │   ├── test_webui.py
    │   └── test_xmlrpc.py
    ├── tools
    │   └── migrate.py
    └── tox.ini
    
    27 directories, 177 files
    

    相关文章

      网友评论

          本文标题:Python工程的文档结构

          本文链接:https://www.haomeiwen.com/subject/zhvfvftx.html