Skip to content

Commit

Permalink
Merge pull request #115 from learningequality/imscp_preset
Browse files Browse the repository at this point in the history
Imscp preset
  • Loading branch information
rtibbles authored Oct 19, 2023
2 parents cb33ad1 + 6822ca8 commit 7c082b0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ test:
build:
pip install -e .
python scripts/generate_from_specs.py
pre-commit run --all-files || true

release: clean build
python setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "0.2.0"
"version": "0.2.2"
}
4 changes: 4 additions & 0 deletions le_utils/constants/format_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
QTI_THUMBNAIL = "qti_thumbnail"
QTI_THUMBNAIL_READABLE = "QTI Thumbnail"

IMSCP_ZIP = "imscp_zip"
IMSCP_ZIP_READABLE = "IMSCP Zip"


SLIDESHOW_IMAGE = "slideshow_image"
SLIDESHOW_IMAGE_READABLE = "Slideshow Image"
Expand Down Expand Up @@ -114,6 +117,7 @@
(SLIDESHOW_IMAGE, SLIDESHOW_IMAGE_READABLE),
(SLIDESHOW_THUMBNAIL, SLIDESHOW_THUMBNAIL_READABLE),
(SLIDESHOW_MANIFEST, SLIDESHOW_MANIFEST_READABLE),
(IMSCP_ZIP, IMSCP_ZIP_READABLE),
)


Expand Down
12 changes: 12 additions & 0 deletions le_utils/resources/presetlookup.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@
"allowed_formats": ["png", "jpg", "jpeg"],
"convertible_formats": []
},
"imscp_zip": {
"readable_name": "IMSCP Zip",
"multi_language": false,
"supplementary": false,
"thumbnail": false,
"subtitle": false,
"display": true,
"order": 1,
"kind": "html5",
"allowed_formats": ["zip"],
"convertible_formats": []
},
"h5p": {
"readable_name": "H5P",
"multi_language": false,
Expand Down
20 changes: 17 additions & 3 deletions scripts/generate_from_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import re
import string
import subprocess
import sys
from collections import OrderedDict
from glob import glob
Expand Down Expand Up @@ -238,26 +239,34 @@ def write_js_file(output_file, name, ordered_output, schema=None):


def write_labels_src_files(label_outputs):
output_files = []
for label_type, ordered_output in label_outputs.items():
py_output_file = os.path.join(
py_labels_output_dir, "{}.py".format(pascal_to_snake(label_type))
)
write_python_file(py_output_file, label_type, ordered_output)
output_files.append(py_output_file)

js_output_file = os.path.join(js_labels_output_dir, "{}.js".format(label_type))
write_js_file(js_output_file, label_type, ordered_output)
output_files.append(js_output_file)
return output_files


def write_constants_src_files(constants_outputs, schemas):
output_files = []
for constant_type, ordered_output in constants_outputs.items():
py_output_file = os.path.join(
py_output_dir, "{}.py".format(pascal_to_snake(constant_type))
)
schema = schemas.get(constant_type)
write_python_file(py_output_file, constant_type, ordered_output, schema=schema)
output_files.append(py_output_file)

js_output_file = os.path.join(js_output_dir, "{}.js".format(constant_type))
write_js_file(js_output_file, constant_type, ordered_output, schema=schema)
output_files.append(js_output_file)
return output_files


def set_package_json_version():
Expand All @@ -279,6 +288,7 @@ def set_package_json_version():
else:
f.write("\n")
f.write(line.rstrip())
return [package_json]


if __name__ == "__main__":
Expand All @@ -289,8 +299,12 @@ def set_package_json_version():
schemas_to_write, schema_constants_to_write = read_schema_specs()
constants_to_write.update(schema_constants_to_write)

write_labels_src_files(labels_to_write)
output_files = []

write_constants_src_files(constants_to_write, schemas_to_write)
output_files += write_labels_src_files(labels_to_write)

set_package_json_version()
output_files += write_constants_src_files(constants_to_write, schemas_to_write)

output_files += set_package_json_version()

subprocess.call(["pre-commit", "run", "--files"] + output_files)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
setup(
name="le-utils",
packages=find_packages(),
version="0.2.1",
version="0.2.2",
description="LE-Utils contains shared constants used in Kolibri, Ricecooker, and Kolibri Studio.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 7c082b0

Please sign in to comment.