V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
neo1218
V2EX  ›  Python

用 click 做的 flask 项目生成工具 mana!

  •  
  •   neo1218 ·
    neo1218 · 2015-10-31 21:05:25 +08:00 · 3463 次点击
    这是一个创建于 3097 天前的主题,其中的信息可能已经有所发展或是发生改变。
    用 click ( http://click.pocoo.org/5/ )写了一个终端命令 mana ( https://github.com/neo1218/mana ),帮助快速生成 flask 项目框架,并在相关文件中预填代码,主要目的是减少基础代码的重复性编写,希望大家给点意见!
    ps:真的很佩服 Armin Ronacher ( https://github.com/mitsuhiko )写了 click 和 flask 这两个好东西😄
    14 条回复    2015-11-01 19:00:57 +08:00
    stephen001
        1
    stephen001  
       2015-10-31 21:07:53 +08:00
    good
    Sakuramiku
        2
    Sakuramiku  
       2015-10-31 21:08:13 +08:00
    看了一下,挺不错的,加油
    neo1218
        3
    neo1218  
    OP
       2015-10-31 21:08:13 +08:00
    @stephen001 谢谢
    nicksite
        4
    nicksite  
       2015-10-31 21:17:59 +08:00
    感谢,我也想做代码自动化生成的工作,这下可以作参考了。
    hustlzp
        5
    hustlzp  
       2015-10-31 21:30:55 +08:00
    赞!
    neo1218
        6
    neo1218  
    OP
       2015-10-31 21:36:17 +08:00
    @hustlzp 谢谢,我看了你做的很多东西!!!学到很多
    hustlzp
        7
    hustlzp  
       2015-10-31 21:46:31 +08:00
    @neo1218 互相学习 :)
    HongxuChen
        8
    HongxuChen  
       2015-10-31 22:02:03 +08:00
    一些建议:

    - 英文注释
    - "<U+1F37A>" 可能在终端(模拟器)中显示不正确
    - 尽量少用系统命令 touch , mkdir 等;如果必须, os.popen/os.system -> subprocess
    - templates 目录不要用 python, 可以使用文本
    - 使用 os.path.join
    - 感觉你是为了使用 click 而使用, argparse 似乎够了
    - "open https://121.43.230.104:520/mana" 有点哗众取宠; 另外 open 只在 mac 有用
    humiaozuzu
        9
    humiaozuzu  
       2015-10-31 22:06:11 +08:00
    为啥不用 cookiecutter 做。。。
    neo1218
        10
    neo1218  
    OP
       2015-10-31 22:12:05 +08:00
    @HongxuChen 谢谢,建议提的很好, mana home 我是仿造 brew home 的,确实有些心血来潮😄,但是感觉 help 信息说的不够详细, mana home 还是有帮助的,只是我实现的有问题。。
    然后,我的确是想做一个自动构建目录的工具,使用 click 而不使用 argparse 是因为我先接触了 click ,而且确实感觉 click 不错~
    HongxuChen
        11
    HongxuChen  
       2015-11-01 11:02:08 +08:00
    另外,建议多使用 context manager
    neo1218
        12
    neo1218  
    OP
       2015-11-01 11:09:28 +08:00
    @HongxuChen 好的,多谢了!我会不断的重构代码的。
    1130335361
        13
    1130335361  
       2015-11-01 17:46:14 +08:00
    README 里有一个错误 app.regist_blueprint --> app.register_blueprint
    neo1218
        14
    neo1218  
    OP
       2015-11-01 19:00:57 +08:00
    @1130335361 已经改过来了,当时抱怨的太激动了!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2557 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:03 · PVG 00:03 · LAX 09:03 · JFK 12:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.