Commit b6bd2932 by Ned Batchelder Committed by Calen Pennington

Clean up some pre-existing formatting.

parent 3faf7456
...@@ -221,8 +221,7 @@ class ConditionalDescriptor(ConditionalFields, SequenceDescriptor): ...@@ -221,8 +221,7 @@ class ConditionalDescriptor(ConditionalFields, SequenceDescriptor):
show_tag_list = [] show_tag_list = []
for child in xml_object: for child in xml_object:
if child.tag == 'show': if child.tag == 'show':
location = ConditionalDescriptor.parse_sources( location = ConditionalDescriptor.parse_sources(child, system)
child, system)
children.extend(location) children.extend(location)
show_tag_list.extend(location) show_tag_list.extend(location)
else: else:
......
...@@ -163,8 +163,8 @@ class Location(_LocationBase): ...@@ -163,8 +163,8 @@ class Location(_LocationBase):
def check_list(list_): def check_list(list_):
def check(val, regexp): def check(val, regexp):
if val is not None and regexp.search(val) is not None: if val is not None and regexp.search(val) is not None:
log.debug('invalid characters val="%s", list_="%s"' % (val, list_)) log.debug('invalid characters val=%r, list_=%r', val, list_)
raise InvalidLocationError("Invalid characters in '%s'." % (val)) raise InvalidLocationError("Invalid characters in {!r}.".format(val))
list_ = list(list_) list_ = list(list_)
for val in list_[:4] + [list_[5]]: for val in list_[:4] + [list_[5]]:
......
...@@ -7,20 +7,22 @@ from xblock.runtime import KeyValueStore ...@@ -7,20 +7,22 @@ from xblock.runtime import KeyValueStore
class InheritanceMixin(XBlockMixin): class InheritanceMixin(XBlockMixin):
"""Field definitions for inheritable fields""" """Field definitions for inheritable fields."""
graded = Boolean( graded = Boolean(
help="Whether this module contributes to the final course grade", help="Whether this module contributes to the final course grade",
scope=Scope.settings,
default=False, default=False,
scope=Scope.settings
) )
start = Date( start = Date(
help="Start time when this module is visible", help="Start time when this module is visible",
default=datetime(2030, 1, 1, tzinfo=UTC), default=datetime(2030, 1, 1, tzinfo=UTC),
scope=Scope.settings 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( extended_due = Date(
help="Date that this problem is due by for a particular student. This " 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 " "can be set by an instructor, and will override the global due "
...@@ -29,31 +31,38 @@ class InheritanceMixin(XBlockMixin): ...@@ -29,31 +31,38 @@ class InheritanceMixin(XBlockMixin):
default=None, default=None,
scope=Scope.user_state, 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) xqa_key = String(help="DO NOT USE", scope=Scope.settings)
graceperiod = Timedelta( graceperiod = Timedelta(
help="Amount of time after the due date that submissions will be accepted", help="Amount of time after the due date that submissions will be accepted",
scope=Scope.settings scope=Scope.settings,
) )
showanswer = String( showanswer = String(
help="When to show the problem answer to the student", help="When to show the problem answer to the student",
scope=Scope.settings, scope=Scope.settings,
default="finished" default="finished",
) )
rerandomize = String( rerandomize = String(
help="When to rerandomize the problem", help="When to rerandomize the problem",
scope=Scope.settings,
default="never", default="never",
scope=Scope.settings
) )
days_early_for_beta = Float( days_early_for_beta = Float(
help="Number of days early to show content to beta users", help="Number of days early to show content to beta users",
scope=Scope.settings,
default=None, 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( text_customization = Dict(
help="String customization substitutions for particular locations", help="String customization substitutions for particular locations",
scope=Scope.settings scope=Scope.settings,
) )
use_latex_compiler = Boolean( use_latex_compiler = Boolean(
help="Enable LaTeX templates?", help="Enable LaTeX templates?",
......
...@@ -485,7 +485,8 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ...@@ -485,7 +485,8 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
} }
""" """
course = self._lookup_course(course_locator)['structure'] course = self._lookup_course(course_locator)['structure']
return {'original_version': course['original_version'], return {
'original_version': course['original_version'],
'previous_version': course['previous_version'], 'previous_version': course['previous_version'],
'edited_by': course['edited_by'], 'edited_by': course['edited_by'],
'edited_on': course['edited_on'] 'edited_on': course['edited_on']
...@@ -1328,8 +1329,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase): ...@@ -1328,8 +1329,7 @@ class SplitMongoModuleStore(ModuleStoreWriteBase):
if depth is None or depth > 0: if depth is None or depth > 0:
depth = depth - 1 if depth is not None else None depth = depth - 1 if depth is not None else None
for child in block_map[block_id]['fields'].get('children', []): for child in block_map[block_id]['fields'].get('children', []):
descendent_map = self.descendants(block_map, child, depth, descendent_map = self.descendants(block_map, child, depth, descendent_map)
descendent_map)
return descendent_map return descendent_map
......
...@@ -174,12 +174,17 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): ...@@ -174,12 +174,17 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
# Didn't load properly. Fall back on loading as an error # Didn't load properly. Fall back on loading as an error
# descriptor. This should never error due to formatting. # descriptor. This should never error due to formatting.
msg = "Error loading from xml. " + unicode(err)[:200] msg = "Error loading from xml. %s"
log.warning(msg) log.warning(
# Normally, we don't want lots of exception traces in our logs from common msg,
# content problems. But if you're debugging the xml loading code itself, unicode(err)[:200],
# uncomment the next line. # Normally, we don't want lots of exception traces in our logs from common
# log.exception(msg) # 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) self.error_tracker(msg)
err_msg = msg + "\n" + exc_info_to_str(sys.exc_info()) err_msg = msg + "\n" + exc_info_to_str(sys.exc_info())
...@@ -195,7 +200,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): ...@@ -195,7 +200,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem):
xmlstore.modules[course_id][descriptor.location] = descriptor xmlstore.modules[course_id][descriptor.location] = descriptor
if hasattr(descriptor, 'children'): if descriptor.has_children:
for child in descriptor.get_children(): for child in descriptor.get_children():
parent_tracker.add_parent(child.location, descriptor.location) parent_tracker.add_parent(child.location, descriptor.location)
...@@ -368,7 +373,8 @@ class XMLModuleStore(ModuleStoreReadBase): ...@@ -368,7 +373,8 @@ class XMLModuleStore(ModuleStoreReadBase):
String representation - for debugging String representation - for debugging
''' '''
return '<XMLModuleStore data_dir=%r, %d courses, %d modules>' % ( return '<XMLModuleStore data_dir=%r, %d courses, %d modules>' % (
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): def load_policy(self, policy_path, tracker):
""" """
......
...@@ -660,8 +660,8 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor): ...@@ -660,8 +660,8 @@ class PeerGradingDescriptor(PeerGradingFields, RawDescriptor):
metadata_translations = { metadata_translations = {
'is_graded': 'graded', 'is_graded': 'graded',
'attempts': 'max_attempts', 'attempts': 'max_attempts',
'due_data' : 'due' 'due_data': 'due'
} }
@property @property
def non_editable_metadata_fields(self): def non_editable_metadata_fields(self):
......
...@@ -119,13 +119,10 @@ class ImportTestCase(BaseCourseTestCase): ...@@ -119,13 +119,10 @@ class ImportTestCase(BaseCourseTestCase):
tag_xml = descriptor.export_to_xml(resource_fs) tag_xml = descriptor.export_to_xml(resource_fs)
re_import_descriptor = system.process_xml(tag_xml) re_import_descriptor = system.process_xml(tag_xml)
self.assertEqual(re_import_descriptor.__class__.__name__, self.assertEqual(re_import_descriptor.__class__.__name__, 'ErrorDescriptorWithMixins')
'ErrorDescriptorWithMixins')
self.assertEqual(descriptor.contents, self.assertEqual(descriptor.contents, re_import_descriptor.contents)
re_import_descriptor.contents) self.assertEqual(descriptor.error_msg, re_import_descriptor.error_msg)
self.assertEqual(descriptor.error_msg,
re_import_descriptor.error_msg)
def test_fixed_xml_tag(self): def test_fixed_xml_tag(self):
"""Make sure a tag that's been fixed exports as the original tag type""" """Make sure a tag that's been fixed exports as the original tag type"""
......
...@@ -6,7 +6,7 @@ import sys ...@@ -6,7 +6,7 @@ import sys
from lxml import etree from lxml import etree
from xblock.fields import Dict, Scope, ScopeIds 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 import Location
from xmodule.modulestore.inheritance import own_metadata, InheritanceKeyValueStore from xmodule.modulestore.inheritance import own_metadata, InheritanceKeyValueStore
from xmodule.modulestore.xml_exporter import EdxJSONEncoder from xmodule.modulestore.xml_exporter import EdxJSONEncoder
...@@ -153,8 +153,7 @@ class XmlDescriptor(XModuleDescriptor): ...@@ -153,8 +153,7 @@ class XmlDescriptor(XModuleDescriptor):
xml_object: An etree Element xml_object: An etree Element
""" """
raise NotImplementedError( raise NotImplementedError("%s does not implement definition_from_xml" % cls.__name__)
"%s does not implement definition_from_xml" % cls.__name__)
@classmethod @classmethod
def clean_metadata_from_xml(cls, xml_object): def clean_metadata_from_xml(cls, xml_object):
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<video name="S0V1: Video Resources" youtube_id_0_75="EuzkdzfR0i8" youtube_id_1_0="1bK-WdDi6Qw" youtube_id_1_25="0v1VzoDVUTM" youtube_id_1_5="Bxk_-ZJb240"/> <video name="S0V1: Video Resources" youtube_id_0_75="EuzkdzfR0i8" youtube_id_1_0="1bK-WdDi6Qw" youtube_id_1_25="0v1VzoDVUTM" youtube_id_1_5="Bxk_-ZJb240"/>
</videosequence> </videosequence>
<section name="Lecture 2"> <section name="Lecture 2">
<sequential> <sequential>
<video youtube_id_1_0="TBvX7HzxexQ"/> <video youtube_id_1_0="TBvX7HzxexQ"/>
<problem name="L1 Problem 1" points="1" type="lecture" showanswer="attempted" filename="L1_Problem_1" rerandomize="never"/> <problem name="L1 Problem 1" points="1" type="lecture" showanswer="attempted" filename="L1_Problem_1" rerandomize="never"/>
</sequential> </sequential>
...@@ -20,12 +20,11 @@ ...@@ -20,12 +20,11 @@
</section> </section>
<video name="Lost Video" youtube_id_1_0="TBvX7HzxexQ"/> <video name="Lost Video" youtube_id_1_0="TBvX7HzxexQ"/>
<sequential format="Lecture Sequence" url_name='test_sequence'> <sequential format="Lecture Sequence" url_name='test_sequence'>
<vertical url_name='test_vertical'> <vertical url_name='test_vertical'>
<html url_name='test_html'> <html url_name='test_html'>
Foobar Foobar
</html> </html>
</vertical> </vertical>
</sequential> </sequential>
</chapter> </chapter>
</course> </course>
...@@ -110,7 +110,7 @@ def dump_module(module, destination=None, inherited=False, defaults=False): ...@@ -110,7 +110,7 @@ def dump_module(module, destination=None, inherited=False, defaults=False):
return False return False
elif field.scope != Scope.settings: elif field.scope != Scope.settings:
return False return False
elif defaults == True: elif defaults:
return True return True
else: else:
return field.values != field.default return field.values != field.default
......
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