Commit fff37828 by Chris Dodge

cleave xlint entry point in xml_importer.py to be separate from the import method

parent d2109536
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.xml_importer import perform_xlint
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
...@@ -25,4 +25,4 @@ class Command(BaseCommand): ...@@ -25,4 +25,4 @@ class Command(BaseCommand):
print "Importing. Data_dir={data}, course_dirs={courses}".format( print "Importing. Data_dir={data}, course_dirs={courses}".format(
data=data_dir, data=data_dir,
courses=course_dirs) courses=course_dirs)
import_from_xml(None, data_dir, course_dirs, load_error_modules=False, validate_only=True) perform_xlint(data_dir, course_dirs, load_error_modules=False)
...@@ -88,7 +88,7 @@ def verify_content_links(module, base_dir, static_content_store, link, remap_dic ...@@ -88,7 +88,7 @@ def verify_content_links(module, base_dir, static_content_store, link, remap_dic
def import_from_xml(store, data_dir, course_dirs=None, def import_from_xml(store, data_dir, course_dirs=None,
default_class='xmodule.raw_module.RawDescriptor', default_class='xmodule.raw_module.RawDescriptor',
load_error_modules=True, static_content_store=None, target_location_namespace=None, validate_only=False): load_error_modules=True, static_content_store=None, target_location_namespace=None):
""" """
Import the specified xml data_dir into the "store" modulestore, Import the specified xml data_dir into the "store" modulestore,
using org and course as the location org and course. using org and course as the location org and course.
...@@ -110,10 +110,6 @@ def import_from_xml(store, data_dir, course_dirs=None, ...@@ -110,10 +110,6 @@ def import_from_xml(store, data_dir, course_dirs=None,
load_error_modules=load_error_modules load_error_modules=load_error_modules
) )
if validate_only:
perform_xlint(data_dir, course_dirs, module_store)
return module_store, []
# NOTE: the XmlModuleStore does not implement get_items() which would be a preferable means # NOTE: the XmlModuleStore does not implement get_items() which would be a preferable means
# to enumerate the entire collection of course modules. It will be left as a TBD to implement that # to enumerate the entire collection of course modules. It will be left as a TBD to implement that
# method on XmlModuleStore. # method on XmlModuleStore.
...@@ -243,10 +239,19 @@ def validate_data_source_paths(data_dir, course_dir): ...@@ -243,10 +239,19 @@ def validate_data_source_paths(data_dir, course_dir):
return err_cnt, warn_cnt return err_cnt, warn_cnt
def perform_xlint(data_dir, course_dirs,module_store): def perform_xlint(data_dir, course_dirs,
default_class='xmodule.raw_module.RawDescriptor',
load_error_modules=True):
err_cnt = 0 err_cnt = 0
warn_cnt = 0 warn_cnt = 0
module_store = XMLModuleStore(
data_dir,
default_class=default_class,
course_dirs=course_dirs,
load_error_modules=load_error_modules
)
# check all data source path information # check all data source path information
for course_dir in course_dirs: for course_dir in course_dirs:
_err_cnt, _warn_cnt = validate_data_source_paths(path(data_dir), course_dir) _err_cnt, _warn_cnt = validate_data_source_paths(path(data_dir), course_dir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment