diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..4b07985 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,23 @@ +name: Publish npmjs Package + +on: + release: + types: [published] + +jobs: + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + registry-url: https://registry.npmjs.org/ + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 2.7 + - run: make release-npm + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_API_TOKEN}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 36cafb9..7a10d1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ Release History =============== +0.1.32 Oct 4, 2021 +------------------- + - Added new labelslookup.json constants + - Added labelstemplatelookup.json and idforlabels.py + - Added build-label target for Makefile release + 0.1.22 Oct 3, 2019 ------------------- diff --git a/Makefile b/Makefile index 2c6173a..995f533 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean clean-test clean-pyc clean-build test release +.PHONY: clean clean-test clean-pyc clean-build test release build-labels clean: clean-build clean-pyc clean-test @@ -23,6 +23,13 @@ clean-test: ## remove test and coverage artifacts test: pytest -s -release: clean +build-labels: + python scripts/generate_labels.py + +release: clean build-labels python setup.py sdist twine upload dist/*.tar.gz + +release-npm: clean build-labels + cd js + npm publish diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..fa7fc89 --- /dev/null +++ b/js/index.js @@ -0,0 +1,18 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +import Needs from "./labels/Needs"; +import AccessibilityCategories from "./labels/AccessibilityCategories"; +import ResourceType from "./labels/ResourceType"; +import Levels from "./labels/Levels"; +import Subjects from "./labels/Subjects"; +import LearningActivities from "./labels/LearningActivities"; + +export default { + Needs: Needs, + AccessibilityCategories: AccessibilityCategories, + ResourceType: ResourceType, + Levels: Levels, + Subjects: Subjects, + LearningActivities: LearningActivities, +}; diff --git a/js/labels/AccessibilityCategories.js b/js/labels/AccessibilityCategories.js new file mode 100644 index 0000000..6026e4b --- /dev/null +++ b/js/labels/AccessibilityCategories.js @@ -0,0 +1,11 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + AUDIO_DESCRIPTION: "LNqKSN9j", + ALT_TEXT: "Lb0tb9VC", + CAPTIONS_SUBTITLES: "WnIhbgkY", + HIGH_CONTRAST: "uF4CI2wP", + TAGGED_PDF: "Kxx#meDW", + SIGN_LANGUAGE: "Dr4cVXkc", +}; diff --git a/js/labels/LearningActivities.js b/js/labels/LearningActivities.js new file mode 100644 index 0000000..73daec3 --- /dev/null +++ b/js/labels/LearningActivities.js @@ -0,0 +1,12 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + READ: "wA01urpi", + CREATE: "UXADWcXZ", + PRACTICE: "VwRCom7G", + WATCH: "UD5UGM0z", + REFLECT: "3dSeJhqs", + EXPLORE: "#j8L0eq3", + LISTEN: "mkA1R3NU", +}; diff --git a/js/labels/Levels.js b/js/labels/Levels.js new file mode 100644 index 0000000..3e3c9bb --- /dev/null +++ b/js/labels/Levels.js @@ -0,0 +1,14 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + UPPER_SECONDARY: "ZEjiwvOb", + WORK_SKILLS: "Z#97dvst", + LOWER_PRIMARY: "wnarlxKo", + LOWER_SECONDARY: "eLt0Mbu4", + UPPER_PRIMARY: "BkGYi3lD", + PRESCHOOL: "FOhG0ib", + BASIC_SKILLS: "H64ZOHfi", + PROFESSIONAL: "ZrgBU73s", + TERTIARY: "FYxwbxts", +}; diff --git a/js/labels/Needs.js b/js/labels/Needs.js new file mode 100644 index 0000000..23c71cb --- /dev/null +++ b/js/labels/Needs.js @@ -0,0 +1,15 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + PRIOR_KNOWLEDGE: "sccgQZDd", + MATERIALS: "Hsw9k7Bz", + FOR_BEGINNERS: "sccgQZDd.sAQsauuo", + PAPER_PENCIL: "Hsw9k7Bz.OFIbUAK9", + OTHER_SUPPLIES: "Hsw9k7Bz.#lLv#LB7", + INTERNET: "Hsw9k7Bz.G4h2UBuK", + SPECIAL_SOFTWARE: "Hsw9k7Bz.dbXQw755", + PEOPLE: "lsoCk5Uy", + PEERS: "lsoCk5Uy.MKIzZKDO", + TEACHER: "lsoCk5Uy.H&MVs7S#", +}; diff --git a/js/labels/ResourceType.js b/js/labels/ResourceType.js new file mode 100644 index 0000000..37ee3b3 --- /dev/null +++ b/js/labels/ResourceType.js @@ -0,0 +1,15 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + MEDIA: "rReY3LOO", + TEXTBOOK: "LQYjqpA", + LESSON_PLAN: "OqyPqhxW", + GAME: "9dUN1LWT", + BOOK: "0Et83gje", + TUTORIAL: "WtHeUU1", + ACTIVITY: "J45AL9Nb", + LESSON: "xgFjFhrA", + GUIDE: "204TGB4U", + EXERCISE: "WEEETopZ", +}; diff --git a/js/labels/Subjects.js b/js/labels/Subjects.js new file mode 100644 index 0000000..7d600c0 --- /dev/null +++ b/js/labels/Subjects.js @@ -0,0 +1,62 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +export default { + LOGIC_AND_CRITICAL_THINKING: "nX2&DRtz.YMBXStib", + CALCULUS: "d&WXdXWF.qs0Xlaxq.8rJ57ht6", + NUMERACY: "nX2&DRtz.Tsyej9ta", + READING_COMPREHENSION: "d&WXdXWF.kHKJ&PbV.r7RxB#9t", + TECHNICAL_AND_VOCATIONAL_TRAINING: "l7DsPDlm.ISEXeZt&", + LEARNING_SKILLS: "nX2&DRtz.fP2j70bj", + PROGRAMMING: "d&WXdXWF.e#RTW9E#.CfnlTDZ#", + WRITING: "d&WXdXWF.kHKJ&PbV.KFJOCr&6", + ANTHROPOLOGY: "d&WXdXWF.K80UMYnW.ViBlbQR&", + LESSON_PLANS: "ziJ6PCuU.lOBPr5ix", + SOCIAL_SCIENCES: "d&WXdXWF.K80UMYnW", + LITERATURE: "d&WXdXWF.kHKJ&PbV.DJLBbaEk", + MATHEMATICS: "d&WXdXWF.qs0Xlaxq", + DAILY_LIFE: "PbGoe2MV", + CHEMISTRY: "d&WXdXWF.i1IdaNwr.#r5ocgid", + PHYSICS: "d&WXdXWF.i1IdaNwr.r#wbt#jF", + FOR_TEACHERS: "ziJ6PCuU", + ARTS: "d&WXdXWF.5QAjgfv7", + MENTAL_HEALTH: "PbGoe2MV.d8&gCo2N", + DANCE: "d&WXdXWF.5QAjgfv7.BUMJJBnS", + WORK: "l7DsPDlm", + SCIENCES: "d&WXdXWF.i1IdaNwr", + CIVIC_EDUCATION: "d&WXdXWF.K80UMYnW.F863vKiF", + TOOLS_AND_SOFTWARE_TRAINING: "l7DsPDlm.ISEXeZt&.1JfIbP&N", + ASTRONOMY: "d&WXdXWF.i1IdaNwr.mjSF4QlF", + EARTH_SCIENCE: "d&WXdXWF.i1IdaNwr.zbDzxDE7", + COMPUTER_SCIENCE: "d&WXdXWF.e#RTW9E#", + SOCIOLOGY: "d&WXdXWF.K80UMYnW.75WBu1ZS", + CURRENT_EVENTS: "PbGoe2MV.J7CU1IxN", + BIOLOGY: "d&WXdXWF.i1IdaNwr.uErN4PdS", + POLITICAL_SCIENCE: "d&WXdXWF.K80UMYnW.K72&pITr", + DRAMA: "d&WXdXWF.5QAjgfv7.XsWznP4o", + MUSIC: "d&WXdXWF.5QAjgfv7.u0aKjT4i", + MECHANICAL_ENGINEERING: "d&WXdXWF.e#RTW9E#.8ZoaPsVW", + DIGITAL_LITERACY: "nX2&DRtz.wZ3EAedB", + WEB_DESIGN: "d&WXdXWF.e#RTW9E#.P7s8FxQ8", + LITERACY: "nX2&DRtz.HLo9TbNq", + ENTREPRENEURSHIP: "PbGoe2MV.kyxTNsRS", + GUIDES: "ziJ6PCuU.RLfhp37t", + HISTORY: "d&WXdXWF.zWtcJ&F2", + VISUAL_ART: "d&WXdXWF.5QAjgfv7.4LskOFXj", + ENVIRONMENT: "PbGoe2MV.tS7WKnZ7", + SCHOOL: "d&WXdXWF", + STATISTICS: "d&WXdXWF.qs0Xlaxq.jNm15RLB", + SKILLS_TRAINING: "l7DsPDlm.ISEXeZt&.&1WpYE&n", + ALGEBRA: "d&WXdXWF.qs0Xlaxq.0t5msbL5", + GEOMETRY: "d&WXdXWF.qs0Xlaxq.lb7ELcK5", + DIVERSITY: "PbGoe2MV.EHcbjuKq", + FINANCIAL_LITERACY: "PbGoe2MV.HGIc9sZq", + PUBLIC_HEALTH: "PbGoe2MV.kivAZaeX", + INDUSTRY_AND_SECTOR_SPECIFIC: "l7DsPDlm.ISEXeZt&.pRvOzJTE", + MEDIA_LITERACY: "PbGoe2MV.UOTL#KIV", + READING_AND_WRITING: "d&WXdXWF.kHKJ&PbV", + LANGUAGE_LEARNING: "d&WXdXWF.JDUfJNXc", + BASIC_SKILLS: "nX2&DRtz", + PROFESSIONAL_SKILLS: "l7DsPDlm.#N2VymZo", + ARITHMETIC: "d&WXdXWF.qs0Xlaxq.nG96nHDc", +}; diff --git a/js/labels/index.js b/js/labels/index.js new file mode 100644 index 0000000..b47f36e --- /dev/null +++ b/js/labels/index.js @@ -0,0 +1,18 @@ +// -*- coding: utf-8 -*- +// Generated by scripts/generate_labels.py + +import Needs from "./Needs"; +import AccessibilityCategories from "./AccessibilityCategories"; +import ResourceType from "./ResourceType"; +import Levels from "./Levels"; +import Subjects from "./Subjects"; +import LearningActivities from "./LearningActivities"; + +export default { + Needs: Needs, + AccessibilityCategories: AccessibilityCategories, + ResourceType: ResourceType, + Levels: Levels, + Subjects: Subjects, + LearningActivities: LearningActivities, +}; diff --git a/js/package.json b/js/package.json new file mode 100644 index 0000000..61cf082 --- /dev/null +++ b/js/package.json @@ -0,0 +1,31 @@ +{ + "author": "Learning Equality", + "bugs": { + "url": "https://github.com/learningequality/le-utils/issues" + }, + "description": "A package that exposes constants commonly used across the Kolibri Ecosystem", + "directories": { + "src": "js" + }, + "files": [ + "*.js", + "**/*.js" + ], + "homepage": "https://github.com/learningequality/le-utils#readme", + "keywords": [ + "kolibri", + "constants", + "content" + ], + "license": "MIT", + "main": "index.js", + "name": "kolibri-constants", + "repository": { + "type": "git", + "url": "git+https://github.com/learningequality/le-utils.git" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "version": "0.1.32" +} \ No newline at end of file diff --git a/le_utils/constants/labels/__init__.py b/le_utils/constants/labels/__init__.py new file mode 100644 index 0000000..f2fad37 --- /dev/null +++ b/le_utils/constants/labels/__init__.py @@ -0,0 +1,5 @@ +""" +The constants defined in the submodules of this module are intended +only to provide additional user metadata about content, and have no impact +on their functional roles in any Kolibri tools or platforms. +""" diff --git a/le_utils/constants/labels/accessibility_categories.py b/le_utils/constants/labels/accessibility_categories.py new file mode 100644 index 0000000..851512f --- /dev/null +++ b/le_utils/constants/labels/accessibility_categories.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# AccessibilityCategories + +AUDIO_DESCRIPTION = "LNqKSN9j" +ALT_TEXT = "Lb0tb9VC" +CAPTIONS_SUBTITLES = "WnIhbgkY" +HIGH_CONTRAST = "uF4CI2wP" +TAGGED_PDF = "Kxx#meDW" +SIGN_LANGUAGE = "Dr4cVXkc" + +choices = ( + (AUDIO_DESCRIPTION, "Audio Description"), + (ALT_TEXT, "Alt Text"), + (CAPTIONS_SUBTITLES, "Captions Subtitles"), + (HIGH_CONTRAST, "High Contrast"), + (TAGGED_PDF, "Tagged Pdf"), + (SIGN_LANGUAGE, "Sign Language"), +) + +ACCESSIBILITYCATEGORIESLIST = [ + AUDIO_DESCRIPTION, + ALT_TEXT, + CAPTIONS_SUBTITLES, + HIGH_CONTRAST, + TAGGED_PDF, + SIGN_LANGUAGE, +] diff --git a/le_utils/constants/labels/learning_activities.py b/le_utils/constants/labels/learning_activities.py new file mode 100644 index 0000000..5d41769 --- /dev/null +++ b/le_utils/constants/labels/learning_activities.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# LearningActivities + +READ = "wA01urpi" +CREATE = "UXADWcXZ" +PRACTICE = "VwRCom7G" +WATCH = "UD5UGM0z" +REFLECT = "3dSeJhqs" +EXPLORE = "#j8L0eq3" +LISTEN = "mkA1R3NU" + +choices = ( + (READ, "Read"), + (CREATE, "Create"), + (PRACTICE, "Practice"), + (WATCH, "Watch"), + (REFLECT, "Reflect"), + (EXPLORE, "Explore"), + (LISTEN, "Listen"), +) + +LEARNINGACTIVITIESLIST = [ + READ, + CREATE, + PRACTICE, + WATCH, + REFLECT, + EXPLORE, + LISTEN, +] diff --git a/le_utils/constants/labels/levels.py b/le_utils/constants/labels/levels.py new file mode 100644 index 0000000..3307e05 --- /dev/null +++ b/le_utils/constants/labels/levels.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# Levels + +UPPER_SECONDARY = "ZEjiwvOb" +WORK_SKILLS = "Z#97dvst" +LOWER_PRIMARY = "wnarlxKo" +LOWER_SECONDARY = "eLt0Mbu4" +UPPER_PRIMARY = "BkGYi3lD" +PRESCHOOL = "FOhG0ib" +BASIC_SKILLS = "H64ZOHfi" +PROFESSIONAL = "ZrgBU73s" +TERTIARY = "FYxwbxts" + +choices = ( + (UPPER_SECONDARY, "Upper Secondary"), + (WORK_SKILLS, "Work Skills"), + (LOWER_PRIMARY, "Lower Primary"), + (LOWER_SECONDARY, "Lower Secondary"), + (UPPER_PRIMARY, "Upper Primary"), + (PRESCHOOL, "Preschool"), + (BASIC_SKILLS, "Basic Skills"), + (PROFESSIONAL, "Professional"), + (TERTIARY, "Tertiary"), +) + +LEVELSLIST = [ + UPPER_SECONDARY, + WORK_SKILLS, + LOWER_PRIMARY, + LOWER_SECONDARY, + UPPER_PRIMARY, + PRESCHOOL, + BASIC_SKILLS, + PROFESSIONAL, + TERTIARY, +] diff --git a/le_utils/constants/labels/needs.py b/le_utils/constants/labels/needs.py new file mode 100644 index 0000000..adb4c5c --- /dev/null +++ b/le_utils/constants/labels/needs.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# Needs + +PRIOR_KNOWLEDGE = "sccgQZDd" +MATERIALS = "Hsw9k7Bz" +FOR_BEGINNERS = "sccgQZDd.sAQsauuo" +PAPER_PENCIL = "Hsw9k7Bz.OFIbUAK9" +OTHER_SUPPLIES = "Hsw9k7Bz.#lLv#LB7" +INTERNET = "Hsw9k7Bz.G4h2UBuK" +SPECIAL_SOFTWARE = "Hsw9k7Bz.dbXQw755" +PEOPLE = "lsoCk5Uy" +PEERS = "lsoCk5Uy.MKIzZKDO" +TEACHER = "lsoCk5Uy.H&MVs7S#" + +choices = ( + (PRIOR_KNOWLEDGE, "Prior Knowledge"), + (MATERIALS, "Materials"), + (FOR_BEGINNERS, "For Beginners"), + (PAPER_PENCIL, "Paper Pencil"), + (OTHER_SUPPLIES, "Other Supplies"), + (INTERNET, "Internet"), + (SPECIAL_SOFTWARE, "Special Software"), + (PEOPLE, "People"), + (PEERS, "Peers"), + (TEACHER, "Teacher"), +) + +NEEDSLIST = [ + PRIOR_KNOWLEDGE, + MATERIALS, + FOR_BEGINNERS, + PAPER_PENCIL, + OTHER_SUPPLIES, + INTERNET, + SPECIAL_SOFTWARE, + PEOPLE, + PEERS, + TEACHER, +] diff --git a/le_utils/constants/labels/resource_type.py b/le_utils/constants/labels/resource_type.py new file mode 100644 index 0000000..b12539d --- /dev/null +++ b/le_utils/constants/labels/resource_type.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# ResourceType + +MEDIA = "rReY3LOO" +TEXTBOOK = "LQYjqpA" +LESSON_PLAN = "OqyPqhxW" +GAME = "9dUN1LWT" +BOOK = "0Et83gje" +TUTORIAL = "WtHeUU1" +ACTIVITY = "J45AL9Nb" +LESSON = "xgFjFhrA" +GUIDE = "204TGB4U" +EXERCISE = "WEEETopZ" + +choices = ( + (MEDIA, "Media"), + (TEXTBOOK, "Textbook"), + (LESSON_PLAN, "Lesson Plan"), + (GAME, "Game"), + (BOOK, "Book"), + (TUTORIAL, "Tutorial"), + (ACTIVITY, "Activity"), + (LESSON, "Lesson"), + (GUIDE, "Guide"), + (EXERCISE, "Exercise"), +) + +RESOURCETYPELIST = [ + MEDIA, + TEXTBOOK, + LESSON_PLAN, + GAME, + BOOK, + TUTORIAL, + ACTIVITY, + LESSON, + GUIDE, + EXERCISE, +] diff --git a/le_utils/constants/labels/subjects.py b/le_utils/constants/labels/subjects.py new file mode 100644 index 0000000..590793b --- /dev/null +++ b/le_utils/constants/labels/subjects.py @@ -0,0 +1,183 @@ +# -*- coding: utf-8 -*- +# Generated by scripts/generate_labels.py +from __future__ import unicode_literals + +# Subjects + +LOGIC_AND_CRITICAL_THINKING = "nX2&DRtz.YMBXStib" +CALCULUS = "d&WXdXWF.qs0Xlaxq.8rJ57ht6" +NUMERACY = "nX2&DRtz.Tsyej9ta" +READING_COMPREHENSION = "d&WXdXWF.kHKJ&PbV.r7RxB#9t" +TECHNICAL_AND_VOCATIONAL_TRAINING = "l7DsPDlm.ISEXeZt&" +LEARNING_SKILLS = "nX2&DRtz.fP2j70bj" +PROGRAMMING = "d&WXdXWF.e#RTW9E#.CfnlTDZ#" +WRITING = "d&WXdXWF.kHKJ&PbV.KFJOCr&6" +ANTHROPOLOGY = "d&WXdXWF.K80UMYnW.ViBlbQR&" +LESSON_PLANS = "ziJ6PCuU.lOBPr5ix" +SOCIAL_SCIENCES = "d&WXdXWF.K80UMYnW" +LITERATURE = "d&WXdXWF.kHKJ&PbV.DJLBbaEk" +MATHEMATICS = "d&WXdXWF.qs0Xlaxq" +DAILY_LIFE = "PbGoe2MV" +CHEMISTRY = "d&WXdXWF.i1IdaNwr.#r5ocgid" +PHYSICS = "d&WXdXWF.i1IdaNwr.r#wbt#jF" +FOR_TEACHERS = "ziJ6PCuU" +ARTS = "d&WXdXWF.5QAjgfv7" +MENTAL_HEALTH = "PbGoe2MV.d8&gCo2N" +DANCE = "d&WXdXWF.5QAjgfv7.BUMJJBnS" +WORK = "l7DsPDlm" +SCIENCES = "d&WXdXWF.i1IdaNwr" +CIVIC_EDUCATION = "d&WXdXWF.K80UMYnW.F863vKiF" +TOOLS_AND_SOFTWARE_TRAINING = "l7DsPDlm.ISEXeZt&.1JfIbP&N" +ASTRONOMY = "d&WXdXWF.i1IdaNwr.mjSF4QlF" +EARTH_SCIENCE = "d&WXdXWF.i1IdaNwr.zbDzxDE7" +COMPUTER_SCIENCE = "d&WXdXWF.e#RTW9E#" +SOCIOLOGY = "d&WXdXWF.K80UMYnW.75WBu1ZS" +CURRENT_EVENTS = "PbGoe2MV.J7CU1IxN" +BIOLOGY = "d&WXdXWF.i1IdaNwr.uErN4PdS" +POLITICAL_SCIENCE = "d&WXdXWF.K80UMYnW.K72&pITr" +DRAMA = "d&WXdXWF.5QAjgfv7.XsWznP4o" +MUSIC = "d&WXdXWF.5QAjgfv7.u0aKjT4i" +MECHANICAL_ENGINEERING = "d&WXdXWF.e#RTW9E#.8ZoaPsVW" +DIGITAL_LITERACY = "nX2&DRtz.wZ3EAedB" +WEB_DESIGN = "d&WXdXWF.e#RTW9E#.P7s8FxQ8" +LITERACY = "nX2&DRtz.HLo9TbNq" +ENTREPRENEURSHIP = "PbGoe2MV.kyxTNsRS" +GUIDES = "ziJ6PCuU.RLfhp37t" +HISTORY = "d&WXdXWF.zWtcJ&F2" +VISUAL_ART = "d&WXdXWF.5QAjgfv7.4LskOFXj" +ENVIRONMENT = "PbGoe2MV.tS7WKnZ7" +SCHOOL = "d&WXdXWF" +STATISTICS = "d&WXdXWF.qs0Xlaxq.jNm15RLB" +SKILLS_TRAINING = "l7DsPDlm.ISEXeZt&.&1WpYE&n" +ALGEBRA = "d&WXdXWF.qs0Xlaxq.0t5msbL5" +GEOMETRY = "d&WXdXWF.qs0Xlaxq.lb7ELcK5" +DIVERSITY = "PbGoe2MV.EHcbjuKq" +FINANCIAL_LITERACY = "PbGoe2MV.HGIc9sZq" +PUBLIC_HEALTH = "PbGoe2MV.kivAZaeX" +INDUSTRY_AND_SECTOR_SPECIFIC = "l7DsPDlm.ISEXeZt&.pRvOzJTE" +MEDIA_LITERACY = "PbGoe2MV.UOTL#KIV" +READING_AND_WRITING = "d&WXdXWF.kHKJ&PbV" +LANGUAGE_LEARNING = "d&WXdXWF.JDUfJNXc" +BASIC_SKILLS = "nX2&DRtz" +PROFESSIONAL_SKILLS = "l7DsPDlm.#N2VymZo" +ARITHMETIC = "d&WXdXWF.qs0Xlaxq.nG96nHDc" + +choices = ( + (LOGIC_AND_CRITICAL_THINKING, "Logic And Critical Thinking"), + (CALCULUS, "Calculus"), + (NUMERACY, "Numeracy"), + (READING_COMPREHENSION, "Reading Comprehension"), + (TECHNICAL_AND_VOCATIONAL_TRAINING, "Technical And Vocational Training"), + (LEARNING_SKILLS, "Learning Skills"), + (PROGRAMMING, "Programming"), + (WRITING, "Writing"), + (ANTHROPOLOGY, "Anthropology"), + (LESSON_PLANS, "Lesson Plans"), + (SOCIAL_SCIENCES, "Social Sciences"), + (LITERATURE, "Literature"), + (MATHEMATICS, "Mathematics"), + (DAILY_LIFE, "Daily Life"), + (CHEMISTRY, "Chemistry"), + (PHYSICS, "Physics"), + (FOR_TEACHERS, "For Teachers"), + (ARTS, "Arts"), + (MENTAL_HEALTH, "Mental Health"), + (DANCE, "Dance"), + (WORK, "Work"), + (SCIENCES, "Sciences"), + (CIVIC_EDUCATION, "Civic Education"), + (TOOLS_AND_SOFTWARE_TRAINING, "Tools And Software Training"), + (ASTRONOMY, "Astronomy"), + (EARTH_SCIENCE, "Earth Science"), + (COMPUTER_SCIENCE, "Computer Science"), + (SOCIOLOGY, "Sociology"), + (CURRENT_EVENTS, "Current Events"), + (BIOLOGY, "Biology"), + (POLITICAL_SCIENCE, "Political Science"), + (DRAMA, "Drama"), + (MUSIC, "Music"), + (MECHANICAL_ENGINEERING, "Mechanical Engineering"), + (DIGITAL_LITERACY, "Digital Literacy"), + (WEB_DESIGN, "Web Design"), + (LITERACY, "Literacy"), + (ENTREPRENEURSHIP, "Entrepreneurship"), + (GUIDES, "Guides"), + (HISTORY, "History"), + (VISUAL_ART, "Visual Art"), + (ENVIRONMENT, "Environment"), + (SCHOOL, "School"), + (STATISTICS, "Statistics"), + (SKILLS_TRAINING, "Skills Training"), + (ALGEBRA, "Algebra"), + (GEOMETRY, "Geometry"), + (DIVERSITY, "Diversity"), + (FINANCIAL_LITERACY, "Financial Literacy"), + (PUBLIC_HEALTH, "Public Health"), + (INDUSTRY_AND_SECTOR_SPECIFIC, "Industry And Sector Specific"), + (MEDIA_LITERACY, "Media Literacy"), + (READING_AND_WRITING, "Reading And Writing"), + (LANGUAGE_LEARNING, "Language Learning"), + (BASIC_SKILLS, "Basic Skills"), + (PROFESSIONAL_SKILLS, "Professional Skills"), + (ARITHMETIC, "Arithmetic"), +) + +SUBJECTSLIST = [ + LOGIC_AND_CRITICAL_THINKING, + CALCULUS, + NUMERACY, + READING_COMPREHENSION, + TECHNICAL_AND_VOCATIONAL_TRAINING, + LEARNING_SKILLS, + PROGRAMMING, + WRITING, + ANTHROPOLOGY, + LESSON_PLANS, + SOCIAL_SCIENCES, + LITERATURE, + MATHEMATICS, + DAILY_LIFE, + CHEMISTRY, + PHYSICS, + FOR_TEACHERS, + ARTS, + MENTAL_HEALTH, + DANCE, + WORK, + SCIENCES, + CIVIC_EDUCATION, + TOOLS_AND_SOFTWARE_TRAINING, + ASTRONOMY, + EARTH_SCIENCE, + COMPUTER_SCIENCE, + SOCIOLOGY, + CURRENT_EVENTS, + BIOLOGY, + POLITICAL_SCIENCE, + DRAMA, + MUSIC, + MECHANICAL_ENGINEERING, + DIGITAL_LITERACY, + WEB_DESIGN, + LITERACY, + ENTREPRENEURSHIP, + GUIDES, + HISTORY, + VISUAL_ART, + ENVIRONMENT, + SCHOOL, + STATISTICS, + SKILLS_TRAINING, + ALGEBRA, + GEOMETRY, + DIVERSITY, + FINANCIAL_LITERACY, + PUBLIC_HEALTH, + INDUSTRY_AND_SECTOR_SPECIFIC, + MEDIA_LITERACY, + READING_AND_WRITING, + LANGUAGE_LEARNING, + BASIC_SKILLS, + PROFESSIONAL_SKILLS, + ARITHMETIC, +] diff --git a/scripts/generate_labels.py b/scripts/generate_labels.py new file mode 100644 index 0000000..6f38c52 --- /dev/null +++ b/scripts/generate_labels.py @@ -0,0 +1,199 @@ +""" +generate_labels +Builds or rebuilds the labels py files assigning ids to the labels +""" +from __future__ import unicode_literals + +import json +import os +import re +import string +from hashlib import md5 +from uuid import UUID +from uuid import uuid3 + +from pkg_resources import get_distribution + +try: + FileNotFoundError +except NameError: + FileNotFoundError = IOError + + +root_label = md5() +root_label.update("Kolibri labels") + +root_namespace = UUID(hex=root_label.hexdigest()) + +pascal_case_pattern = re.compile(r"(? 0 or not res: + res += CHARACTERS[(data & 0x3F)] + data >>= 6 + res.reverse() + return "".join(res) + + +def generate_identifier(namespace, label): + return uuid3(namespace, label.encode("utf-8")) + + +def generate_key(identifier, previous=None): + key = _from_uuid(identifier) + if previous is None: + return key + return "{}.{}".format(previous, key) + + +def handle_array(labels, namespace, previous=None): + output = {} + for label in labels: + identifier = generate_identifier(namespace, label) + output[label] = generate_key(identifier, previous) + return output + + +def handle_object(element, namespace, previous=None): + output = {} + for key, value in element.items(): + handler = handle_object if isinstance(value, dict) else handle_array + identifier = generate_identifier(namespace, key) + new_key = generate_key(identifier, previous) + output[key] = new_key + output.update(handler(value, namespace, new_key)) + return output + + +def read_labels_spec(): + labels_spec_file = os.path.join( + os.path.dirname(__file__), + "..", + "spec", + "labels.json", + ) + with open(labels_spec_file) as json_labels_spec_file: + return json.load(json_labels_spec_file) + + +def write_labels_src(labels_spec): + py_output_dir = os.path.join( + os.path.dirname(__file__), "..", "le_utils", "constants", "labels" + ) + + for label_type, labels in labels_spec.items(): + handler = handle_object if isinstance(labels, dict) else handle_array + namespace = generate_identifier(root_namespace, label_type) + output = handler(labels, namespace) + py_output_file = os.path.join( + py_output_dir, "{}.py".format(pascal_to_snake(label_type)) + ) + with open(py_output_file, "w") as f: + f.write("# -*- coding: utf-8 -*-\n") + f.write("# Generated by scripts/generate_labels.py\n") + f.write("from __future__ import unicode_literals\n") + f.write("\n") + f.write("# {}\n".format(label_type)) + f.write("\n") + for key, value in output.items(): + f.write('{} = "{}"\n'.format(key, value)) + f.write("\n") + f.write("choices = (\n") + for key in output.keys(): + f.write(' ({}, "{}"),\n'.format(key, key.replace("_", " ").title())) + f.write(")\n") + f.write("\n") + f.write("{}LIST = [\n".format(label_type.upper())) + for key in output.keys(): + f.write(" {},\n".format(key)) + f.write("]\n") + + js_output_file = os.path.join(js_labels_output_dir, "{}.js".format(label_type)) + with open(js_output_file, "w") as f: + f.write("// -*- coding: utf-8 -*-\n") + f.write("// Generated by scripts/generate_labels.py\n") + f.write("\n") + f.write("export default {\n") + for key, value in output.items(): + f.write(' {key}: "{value}",\n'.format(key=key, value=value)) + f.write("};\n") + + js_labels_index_file = os.path.join(js_labels_output_dir, "index.js") + + with open(js_labels_index_file, "w") as f: + f.write("// -*- coding: utf-8 -*-\n") + f.write("// Generated by scripts/generate_labels.py\n") + f.write("\n") + for label_type in labels_spec.keys(): + f.write('import {0} from "./{0}";\n'.format(label_type)) + f.write("\n") + f.write("export default {\n") + for label_type in labels_spec.keys(): + f.write(" {0}: {0},\n".format(label_type)) + f.write("};\n") + + +def create_js_index(labels_spec): + js_index_file = os.path.join(js_output_dir, "index.js") + + with open(js_index_file, "w") as f: + f.write("// -*- coding: utf-8 -*-\n") + f.write("// Generated by scripts/generate_labels.py\n") + f.write("\n") + for label_type in labels_spec.keys(): + f.write('import {0} from "./labels/{0}";\n'.format(label_type)) + f.write("\n") + f.write("export default {\n") + for label_type in labels_spec.keys(): + f.write(" {0}: {0},\n".format(label_type)) + f.write("};\n") + + +def set_package_json_version(): + python_version = get_distribution("le-utils").version + + package_json = os.path.join(js_output_dir, "package.json") + + with open(package_json, "r") as f: + package = json.load(f) + + package["version"] = python_version + + with open(package_json, "w") as f: + json.dump(package, f, indent=2, sort_keys=True) + + +if __name__ == "__main__": + labels_spec = read_labels_spec() + + write_labels_src(labels_spec) + + create_js_index(labels_spec) + + set_package_json_version() diff --git a/spec/labels.json b/spec/labels.json new file mode 100644 index 0000000..e0df364 --- /dev/null +++ b/spec/labels.json @@ -0,0 +1,129 @@ +{ + "Levels": [ + "PRESCHOOL", + "LOWER_PRIMARY", + "UPPER_PRIMARY", + "LOWER_SECONDARY", + "UPPER_SECONDARY", + "TERTIARY", + "PROFESSIONAL", + "BASIC_SKILLS", + "WORK_SKILLS" + ], + "ResourceType": [ + "LESSON", + "TUTORIAL", + "ACTIVITY", + "EXERCISE", + "MEDIA", + "BOOK", + "GAME", + "GUIDE", + "TEXTBOOK", + "LESSON_PLAN" + ], + "LearningActivities": [ + "CREATE", + "LISTEN", + "REFLECT", + "PRACTICE", + "READ", + "WATCH", + "EXPLORE" + ], + "AccessibilityCategories": [ + "SIGN_LANGUAGE", + "AUDIO_DESCRIPTION", + "TAGGED_PDF", + "ALT_TEXT", + "HIGH_CONTRAST", + "CAPTIONS_SUBTITLES" + ], + "Subjects": { + "SCHOOL": { + "MATHEMATICS": [ + "ARITHMETIC", + "ALGEBRA", + "GEOMETRY", + "CALCULUS", + "STATISTICS" + ], + "SCIENCES": [ + "BIOLOGY", + "CHEMISTRY", + "PHYSICS", + "EARTH_SCIENCE", + "ASTRONOMY" + ], + "READING_AND_WRITING": [ + "LITERATURE", + "READING_COMPREHENSION", + "WRITING", + "LOGIC_AND_CRITICAL_THINKING" + ], + "SOCIAL_SCIENCES": [ + "POLITICAL_SCIENCE", + "SOCIOLOGY", + "ANTHROPOLOGY", + "CIVIC_EDUCATION" + ], + "ARTS": [ + "VISUAL_ART", + "MUSIC", + "DANCE", + "DRAMA" + ], + "COMPUTER_SCIENCE": [ + "PROGRAMMING", + "MECHANICAL_ENGINEERING", + "WEB_DESIGN" + ], + "LANGUAGE_LEARNING": [], + "HISTORY": [] + }, + "BASIC_SKILLS": [ + "LITERACY", + "NUMERACY", + "DIGITAL_LITERACY", + "LOGIC_AND_CRITICAL_THINKING", + "LEARNING_SKILLS" + ], + "WORK": { + "PROFESSIONAL_SKILLS": [], + "TECHNICAL_AND_VOCATIONAL_TRAINING": [ + "TOOLS_AND_SOFTWARE_TRAINING", + "SKILLS_TRAINING", + "INDUSTRY_AND_SECTOR_SPECIFIC" + ] + }, + "DAILY_LIFE": [ + "PUBLIC_HEALTH", + "ENTREPRENEURSHIP", + "FINANCIAL_LITERACY", + "CURRENT_EVENTS", + "ENVIRONMENT", + "MEDIA_LITERACY", + "DIVERSITY", + "MENTAL_HEALTH" + ], + "FOR_TEACHERS": [ + "GUIDES", + "LESSON_PLANS" + ] + }, + "Needs": { + "PEOPLE": [ + "TEACHER", + "PEERS" + ], + "MATERIALS": [ + "PAPER_PENCIL", + "INTERNET", + "SPECIAL_SOFTWARE", + "OTHER_SUPPLIES" + ], + "PRIOR_KNOWLEDGE": [ + "FOR_BEGINNERS" + ] + } +}