From 010ecb354a0921450afdff1f6cfc5f5754955fa7 Mon Sep 17 00:00:00 2001 From: 0x29a Date: Wed, 16 Nov 2022 13:00:49 +0100 Subject: [PATCH] refactor: remove lms/djangoapps/debug/management directory It contained only one management command, "dump_xml_courses", which didn't work since the late 2015. --- lms/djangoapps/debug/management/__init__.py | 0 .../debug/management/commands/__init__.py | 0 .../management/commands/dump_xml_courses.py | 56 ------------------- 3 files changed, 56 deletions(-) delete mode 100644 lms/djangoapps/debug/management/__init__.py delete mode 100644 lms/djangoapps/debug/management/commands/__init__.py delete mode 100644 lms/djangoapps/debug/management/commands/dump_xml_courses.py diff --git a/lms/djangoapps/debug/management/__init__.py b/lms/djangoapps/debug/management/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lms/djangoapps/debug/management/commands/__init__.py b/lms/djangoapps/debug/management/commands/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/lms/djangoapps/debug/management/commands/dump_xml_courses.py b/lms/djangoapps/debug/management/commands/dump_xml_courses.py deleted file mode 100644 index e72604c79d..0000000000 --- a/lms/djangoapps/debug/management/commands/dump_xml_courses.py +++ /dev/null @@ -1,56 +0,0 @@ -""" -Export all xml courses in a diffable format. - -This command loads all of the xml courses in the configured DATA_DIR. -For each of the courses, it loops through all of the modules, and dumps -each as a separate output file containing the json representation -of each of its fields (including those fields that are set as default values). -""" -import json - -from django.conf import settings -from django.core.management.base import BaseCommand, CommandError -from path import Path as path - -from xmodule.modulestore.xml import XMLModuleStore - - -class Command(BaseCommand): - """ - Django management command to export diffable representations of all xml courses - """ - help = '''Dump the in-memory representation of all xml courses in a diff-able format''' - args = '' - - def handle(self, *args, **options): - if len(args) != 1: - raise CommandError(f'Must called with arguments: {self.args}') - - xml_module_store = XMLModuleStore( - data_dir=settings.DATA_DIR, - default_class='xmodule.hidden_module.HiddenDescriptor', - load_error_modules=True, - xblock_mixins=settings.XBLOCK_MIXINS, - ) - - export_dir = path(args[0]) - - for course_id, course_modules in xml_module_store.modules.items(): - course_path = course_id.replace('/', '_') - for location, descriptor in course_modules.items(): - location_path = str(location).replace('/', '_') - data = {} - for field_name, field in descriptor.fields.items(): - try: - data[field_name] = field.read_json(descriptor) - except Exception as exc: # pylint: disable=broad-except - data[field_name] = { - '$type': str(type(exc)), - '$value': descriptor._field_data.get(descriptor, field_name) # pylint: disable=protected-access - } - - outdir = export_dir / course_path - outdir.makedirs_p() - with open(outdir / location_path + '.json', 'w') as outfile: - json.dump(data, outfile, sort_keys=True, indent=4) - print('', file=outfile)