diff --git a/common/lib/xmodule/xmodule/conditional_module.py b/common/lib/xmodule/xmodule/conditional_module.py index f9b47da7ea..d015136f50 100644 --- a/common/lib/xmodule/xmodule/conditional_module.py +++ b/common/lib/xmodule/xmodule/conditional_module.py @@ -221,8 +221,7 @@ class ConditionalDescriptor(ConditionalFields, SequenceDescriptor): show_tag_list = [] for child in xml_object: if child.tag == 'show': - location = ConditionalDescriptor.parse_sources( - child, system) + location = ConditionalDescriptor.parse_sources(child, system) children.extend(location) show_tag_list.extend(location) else: diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index e3386608dc..3029449ace 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -163,8 +163,8 @@ class Location(_LocationBase): def check_list(list_): def check(val, regexp): if val is not None and regexp.search(val) is not None: - log.debug('invalid characters val="%s", list_="%s"' % (val, list_)) - raise InvalidLocationError("Invalid characters in '%s'." % (val)) + log.debug('invalid characters val=%r, list_=%r', val, list_) + raise InvalidLocationError("Invalid characters in {!r}.".format(val)) list_ = list(list_) for val in list_[:4] + [list_[5]]: diff --git a/common/lib/xmodule/xmodule/modulestore/inheritance.py b/common/lib/xmodule/xmodule/modulestore/inheritance.py index 5839dd6d1c..d23a13af6f 100644 --- a/common/lib/xmodule/xmodule/modulestore/inheritance.py +++ b/common/lib/xmodule/xmodule/modulestore/inheritance.py @@ -7,20 +7,22 @@ from xblock.runtime import KeyValueStore class InheritanceMixin(XBlockMixin): - """Field definitions for inheritable fields""" + """Field definitions for inheritable fields.""" graded = Boolean( help="Whether this module contributes to the final course grade", + scope=Scope.settings, default=False, - scope=Scope.settings ) - start = Date( help="Start time when this module is visible", default=datetime(2030, 1, 1, tzinfo=UTC), scope=Scope.settings ) - due = Date(help="Date that this problem is due by", scope=Scope.settings) + due = Date( + help="Date that this problem is due by", + scope=Scope.settings, + ) extended_due = Date( help="Date that this problem is due by for a particular student. This " "can be set by an instructor, and will override the global due " @@ -29,31 +31,38 @@ class InheritanceMixin(XBlockMixin): default=None, scope=Scope.user_state, ) - giturl = String(help="url root for course data git repository", scope=Scope.settings) + giturl = String( + help="url root for course data git repository", + scope=Scope.settings, + ) xqa_key = String(help="DO NOT USE", scope=Scope.settings) graceperiod = Timedelta( help="Amount of time after the due date that submissions will be accepted", - scope=Scope.settings + scope=Scope.settings, ) showanswer = String( help="When to show the problem answer to the student", scope=Scope.settings, - default="finished" + default="finished", ) rerandomize = String( help="When to rerandomize the problem", + scope=Scope.settings, default="never", - scope=Scope.settings ) days_early_for_beta = Float( help="Number of days early to show content to beta users", + scope=Scope.settings, default=None, - scope=Scope.settings ) - static_asset_path = String(help="Path to use for static assets - overrides Studio c4x://", scope=Scope.settings, default='') + static_asset_path = String( + help="Path to use for static assets - overrides Studio c4x://", + scope=Scope.settings, + default='', + ) text_customization = Dict( help="String customization substitutions for particular locations", - scope=Scope.settings + scope=Scope.settings, ) use_latex_compiler = Boolean( help="Enable LaTeX templates?", diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index 1a92f961ec..04f15727a4 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -485,7 +485,8 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): } """ course = self._lookup_course(course_locator)['structure'] - return {'original_version': course['original_version'], + return { + 'original_version': course['original_version'], 'previous_version': course['previous_version'], 'edited_by': course['edited_by'], 'edited_on': course['edited_on'] @@ -1328,8 +1329,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): if depth is None or depth > 0: depth = depth - 1 if depth is not None else None for child in block_map[block_id]['fields'].get('children', []): - descendent_map = self.descendants(block_map, child, depth, - descendent_map) + descendent_map = self.descendants(block_map, child, depth, descendent_map) return descendent_map diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index 02df55569a..ec31fc5763 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -174,12 +174,17 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): # Didn't load properly. Fall back on loading as an error # descriptor. This should never error due to formatting. - msg = "Error loading from xml. " + unicode(err)[:200] - log.warning(msg) - # Normally, we don't want lots of exception traces in our logs from common - # content problems. But if you're debugging the xml loading code itself, - # uncomment the next line. - # log.exception(msg) + msg = "Error loading from xml. %s" + log.warning( + msg, + unicode(err)[:200], + # Normally, we don't want lots of exception traces in our logs from common + # content problems. But if you're debugging the xml loading code itself, + # uncomment the next line. + # exc_info=True + ) + + msg = msg % (unicode(err)[:200]) self.error_tracker(msg) err_msg = msg + "\n" + exc_info_to_str(sys.exc_info()) @@ -195,7 +200,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): xmlstore.modules[course_id][descriptor.location] = descriptor - if hasattr(descriptor, 'children'): + if descriptor.has_children: for child in descriptor.get_children(): parent_tracker.add_parent(child.location, descriptor.location) @@ -368,7 +373,8 @@ class XMLModuleStore(ModuleStoreReadBase): String representation - for debugging ''' return '' % ( - self.data_dir, len(self.courses), len(self.modules)) + self.data_dir, len(self.courses), len(self.modules) + ) def load_policy(self, policy_path, tracker): """ diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 95835a0ba4..ed80db2aae 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -660,8 +660,8 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor): metadata_translations = { 'is_graded': 'graded', 'attempts': 'max_attempts', - 'due_data' : 'due' - } + 'due_data': 'due' + } @property def non_editable_metadata_fields(self): diff --git a/common/lib/xmodule/xmodule/tests/test_import.py b/common/lib/xmodule/xmodule/tests/test_import.py index 3a192318a6..11615afd0a 100644 --- a/common/lib/xmodule/xmodule/tests/test_import.py +++ b/common/lib/xmodule/xmodule/tests/test_import.py @@ -119,13 +119,10 @@ class ImportTestCase(BaseCourseTestCase): tag_xml = descriptor.export_to_xml(resource_fs) re_import_descriptor = system.process_xml(tag_xml) - self.assertEqual(re_import_descriptor.__class__.__name__, - 'ErrorDescriptorWithMixins') + self.assertEqual(re_import_descriptor.__class__.__name__, 'ErrorDescriptorWithMixins') - self.assertEqual(descriptor.contents, - re_import_descriptor.contents) - self.assertEqual(descriptor.error_msg, - re_import_descriptor.error_msg) + self.assertEqual(descriptor.contents, re_import_descriptor.contents) + self.assertEqual(descriptor.error_msg, re_import_descriptor.error_msg) def test_fixed_xml_tag(self): """Make sure a tag that's been fixed exports as the original tag type""" diff --git a/common/lib/xmodule/xmodule/xml_module.py b/common/lib/xmodule/xmodule/xml_module.py index 47682b8ea2..e63d56da40 100644 --- a/common/lib/xmodule/xmodule/xml_module.py +++ b/common/lib/xmodule/xmodule/xml_module.py @@ -6,7 +6,7 @@ import sys from lxml import etree from xblock.fields import Dict, Scope, ScopeIds -from xmodule.x_module import (XModuleDescriptor, policy_key) +from xmodule.x_module import XModuleDescriptor, policy_key from xmodule.modulestore import Location from xmodule.modulestore.inheritance import own_metadata, InheritanceKeyValueStore from xmodule.modulestore.xml_exporter import EdxJSONEncoder @@ -153,8 +153,7 @@ class XmlDescriptor(XModuleDescriptor): xml_object: An etree Element """ - raise NotImplementedError( - "%s does not implement definition_from_xml" % cls.__name__) + raise NotImplementedError("%s does not implement definition_from_xml" % cls.__name__) @classmethod def clean_metadata_from_xml(cls, xml_object): diff --git a/common/test/data/simple/course.xml b/common/test/data/simple/course.xml index 529528ca0a..5cd6d54d29 100644 --- a/common/test/data/simple/course.xml +++ b/common/test/data/simple/course.xml @@ -6,7 +6,7 @@