json-to-files 作者 simonw

星标

README 源代码

json-to-files

PyPI Changelog Tests License

根据 JSON 对象在磁盘上创建独立文件

安装

使用 pip 安装此工具

pip install json-to-files

用法

此工具接受一个 JSON 文件,其格式如下

{
    "foo.txt": "The contents of foo.txt",
    "bar/baz.txt": "The contents of baz.txt"
}

并使用它在磁盘上写入以下文件

  • foo.txt,内容为 "The contents of foo.txt"
  • bar/baz.txt,内容为 "The contents of baz.txt"

您可以像这样运行它

json-to-files bundle.json

或者您可以指定一个目录来写入这些文件

json-to-files bundle.json -d /tmp/other-directory

bundles.json 文件名是可选的 - 如果省略,此工具将从标准输入读取

cat bundle.json | json-to-files

开发

要为此工具贡献,首先签出代码。然后创建一个新的虚拟环境

cd json-to-files
python -m venv venv
source venv/bin/activate

现在安装依赖项和测试依赖项

pip install -e '.[test]'

运行测试

pytest