跳转到主要内容

marugoto游戏内容的验证器

项目描述

maruval

版本 1.0.5

Build Status codecov.io PyPI version Code style: black

marugoto内容的命令行工具

  • maruval:验证marugoto数据
  • marufind:一个用于查找特定内容文件夹的实用程序
  • marupretty:格式化JSON文件或目录中的所有文件

安装依赖项

maruval 主要用Python编写,因此您的机器需要Python和Python包管理器 pip 来进行安装。您应该已经安装了Python。

要检查您是否有 pip,请在命令行中输入 which pip。如果这返回了 pip 的路径,您可以继续到 安装maruval

否则,要安装 pip,请运行以下命令

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py && rm get-pip.py

现在 which pip 应该显示一个指向 pip 可执行文件的路径。

安装 maruval

一旦您有了 Pythonpip3/pip,以及可能还需要 jq,请运行以下命令

pip install maruval
# or, from the git repo:
git clone https://github.com/uzh/marugoto-validator && cd marugoto-validator && python.setup.py install

Atom 配置 maruval

每个工具都可以从命令行运行,但也许更有用,它们还可以在Atom编辑会话中运行。

运行以下命令以配置Atom

python -m maruval.atom

然后,重新启动Atom并在命令面板中输入 maruval,以查看可用命令。

配置 marupretty

如果您想使用JSON美化打印工具 marupretty,则需要安装 jq 实用程序。使用以下命令执行此操作

# note: requires sudo
sudo python -m maruval.jq
# or, get it at https://stedolan.github.io/jq/ and save it as `jq` your PATH...

命令行使用

以下描述了如何从命令行使用这三个工具。

maruval:验证内容

主要工具 maruval 检查JSON数据中的语法和内容错误。您可以在命令行中使用它,如下所示

maruval -f -nw <path-to-content>

可选参数

  • -f/--fail-first 将在第一个错误后停止 maruval
  • -nw/--no-warnings 将抑制警告消息

示例输出(在某些故意损坏的数据上)

danny@thinkpad:~/marugoto/content$ maruval PlantationLives/
Validating content at PlantationLives/
868 JSON files found.

====================================================================================================
Problem #1 -- Syntax error in PlantationLives/chapter2/2.2.10/page.json
----------------------------------------------------------------------------------------------------

Expecting property name enclosed in double quotes: line 5 column 26 (char 94)

====================================================================================================
Problem #2 -- Content error in PlantationLives/chapter3/2.3.2/imageComponent1.json
----------------------------------------------------------------------------------------------------

'cannot be string' is not of type 'integer'

Failed validating 'type' in schema['properties']['numberOfColumns']:
    {'type': 'integer'}

On instance['numberOfColumns']:
    'cannot be string'

====================================================================================================
Problem #3 -- Syntax error in PlantationLives/chapter3/2.3.5/imageComponent1.json
----------------------------------------------------------------------------------------------------

Expecting ',' delimiter: line 10 column 3 (char 144)

====================================================================================================

All done. 3 errors found. 865 files OK.

marufind:查找特定内容目录

此实用程序需要两个必需参数:第一个是逗号分隔的JSON文件类型列表;第二个是数据集的路径。

工具的默认模式是显示包含所有列出的JSON文件类型的目录。您可以使用-any-only标志来匹配包含列出的任何类型的目录,或仅匹配列出的类型。可选的-not标志将反转结果。

# show directories containing both a videoComponent and textExercise file
marufind videoComponent,textExercise <path-to-content>
# show the opposite
marufind -not videoComponent,textExercise <path-to-content>
# show directories containing any of these files
marufind -any videoComponent,textExercise <path-to-content>
# show directories not containing any of these files
marufind -not -any videoComponent,textExercise <path-to-content>
# show directories containing only page, mail and dialog files
marufind -only page,mail,dialog <path-to-content>
# invert this --- directories containing more than these files
marufind -not -only page,mail,dialog <path-to-content>

marupretty:用于整理文件或内容目录的bash实用工具,需要jq

此实用工具将格式化指定目录中的所有文件,因此您在手动修改JSON文件时不必过多担心空白等问题。

marupretty <path-to-content>

获取帮助

以下命令可以用于获取有关工具使用的信息。

maruval --help
marufind --help

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

maruval-1.0.5.tar.gz (12.4 kB 查看散列)

上传时间

构建分发

maruval-1.0.5-py3.7.egg (29.7 kB 查看散列)

上传时间

由以下支持