用于定义然后下载和预处理外部静态文件的实用程序。

grablib的Python项目详细描述


Build Statuscodecov.ioPyPI Statuslicense

版权所有(c)2013-2017 Samuel Colvin

有点像bower,但是在python中,更简单,并且有更多的特性。

grablib可以:

  • 从url下载文件,包括有选择地从zip文件中提取。
  • 创建.grablib.lock,它保留所有下载文件的哈希值,这意味着资产不能意外更改。
  • 使用libsass编译sass/scss/css。
  • 使用jsmin连接和缩小javascript。

定义文件可以是json或yaml(请参见examples)。

安装

grablib需要python 3.6+

pip install grablib[build]

(您也可以简单地使用pip install grablib来安装,而不需要构建需求, 这在不使用grablib进行构建时非常有用,因为它避免了安装 jsminlibsass,这可能比较慢。)

cli用法

这样定义静态文件:(grablib.yml

download_root:'static/libs'download:'http://code.jquery.com/jquery-1.11.3.js':'js/jquery.js''https://github.com/twbs/bootstrap-sass/archive/v3.3.6.zip':'bootstrap-sass-3.3.6/assets/(.+)$':'bootstrap-sass/''GITHUB/codemirror/CodeMirror/5.8.0/lib/codemirror.js':'codemirror/'# simple scss file to import and compile bootstrap from above,# generally this would be in your code# this file just reads "@import 'bootstrap-sass/stylesheets/bootstrap';"'https://git.io/v1Z5J':'build_bootstrap.scss'debug:truebuild_root:'static/prod'build:# delete the entire static/prod directory before building, this is required for sass,# and generally saferwipe:'.*'cat:# concatenate jquery and codemirror into "libraries.js"# it won't get minified as debug is true, but without that it would'libraries.js':-'DL/js/jquery.js'-'DL/codemirror/codemirror.js'sass:# compile all css, scss and sass files which don't start with _ from the "download_root"# into the "css" directory, here that will just be build_bootstrap.scss which will# build the whole of bootstrap.# debug: true means you'll get map files and a copy of sass files so maps work properly.'css':'DL/'

然后下载并构建静态文件,只需:

grablib

库使用

您还可以从python调用grablib:

fromgrablibimportGrabgrab=Grab('path/to/definitions.json|yml')grab.download()grab.build()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java根据两个数组的值对数组进行排序   具有自签名证书和NTLM代理的java Maven SSL repo错误   java自定义字体按钮不工作AndroidStudio   java通过Spring MVC web应用程序向客户端发送文本文件   Java Spring Web服务SOAP身份验证   ANT property environment=“env”无法在JAVA中检索它,但如果作为ANT命令运行,则可以正常工作   java是为spring mvc rest api或spring boot api对应用服务器的每个新请求创建的服务、存储库和组件的新实例吗?   java私有静态最终字符串未完成其工作   PKCS12的安全Java密钥重新处理   java JPA继承表每类SQLSyntaxErrorException