Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of the recursion through pre-commit that I think is happening with these changes.

So to make sure I understand, you added to the pre-commit config to run make build when the source files run, and thereby removed this part of make build where it runs pre-commit, which I recall was added to reformat the generated files in a consistent manner. But then in scripts/generate_from_specs.py, you added a call to run pre-commit but only on the output files:

subprocess.call(["pre-commit", "run", "--files"] + output_files)

So technically the new pre-commit hook shouldn't run against the output files because they shouldn't match the regex, thereby not triggering make build again, but still the new hook would take pre-commit through make, python, then back to pre-commit again. I think I had brought up potentially having python scripts/generate_from_specs.py output the list of files for pre-commit.


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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff is straightforward here and love calling pre-commit after generation

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