Skip to main content

maruval

Version 1.0.5

Build Status codecov.io PyPI version Code style: black

Command line utilities for marugoto content

  • maruval: validate marugoto data
  • marufind: a utility to find folders with particular contents
  • marupretty: pretty-print a JSON file or all files in a directory

Installing dependencies

maruval is predominantly written Python, so your machine needs Python and the Python package manager pip for installation. You should already have Python.

To check if you have pip, type which pip into your command line. If this returns a path to pip, you can proceed to Installing maruval.

Otherwise, to install pip, run the following command:

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

Now which pip should show a path to a pip executable.

Installing maruval

Once you have Python, pip3/pip, and maybe jq, run the following:

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

Configuring maruval for Atom

Each tool can be run from the command line, but perhaps more usefully, they can be run from within an Atom editing session.

Run the following to configure Atom:

python -m maruval.atom

Then, restart Atom and type maruval into the command palette to see the available commands.

Configuring marupretty

If you want to use marupretty, the JSON pretty printer, you'll need to have the jq utility installed. Use the following command to do this:

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

Command line usage

Below describes how to use each of the three tools from the command line.

maruval: validate content

The main tool, maruval, checks for syntax and content errors in your JSON data. Use it on the command line like this:

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

Optional arguments:

  • -f/--fail-first will stop maruval after first error
  • -nw/--no-warnings will suppress warning messages

Example output (on some purposely broken data):

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: find particular content directories

This utility takes two required arguments: the first is a comma-separated list of JSON file types; the second is the path to the dataset.

The default mode of the tool is to show directories that contain all the listed JSON file types. You can use the -any or -only flags to match directories containing any of the listed types, or only the listed types. The optional -not flag will invert the results.

# 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 utility to tidy up a file or content directory, requires jq

This utility will format all files in the given directory, so you don't have to worry too much about whitespace and so on when modifying JSON files by hand.

marupretty <path-to-content>

Getting help

The following commands can be used to get more information about the usage of the tools:

maruval --help
marufind --help

Metadata

Release files for maruval 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maruval 1.0.5
File Size Uploaded
maruval-1.0.5.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maruval 1.0.5
File Interpreter ABI Platform
maruval-1.0.5-py3.7.egg Legacy Egg format - - Details

Total release size: 42.1 kB

Release files / maruval-1.0.5.tar.gz

Download URL maruval-1.0.5.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2ce9c6512fee326005f59e104a684386b4c26adf5447c1193ba6a3251b2bc25c
BLAKE2b-256 checksum
How to use checksums
6689fe66f1452c79cdaa9de54844c7998f417c3fae562343072c3284b4019b06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

Release files / maruval-1.0.5-py3.7.egg

Download URL maruval-1.0.5-py3.7.egg
Size 29.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
1eac3646b6a7c30151c24ccc10506559a25fb59d11857925ff03cd3b6c437771
BLAKE2b-256 checksum
How to use checksums
b413152f77eb654fdcbb6c8ceae8372adbe8c3b209efb48681cd4ddfac27f570
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

1 release file

1.0.0

3 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page