Commit 6dab09f5 by Calen Pennington

PEP8 and Pylint fixes

parent 913c601a
......@@ -14,9 +14,11 @@ class ItemWriteConflictError(Exception):
class InsufficientSpecificationError(Exception):
pass
class OverSpecificationError(Exception):
pass
class InvalidLocationError(Exception):
pass
......@@ -28,6 +30,7 @@ class NoPathToItem(Exception):
class DuplicateItemError(Exception):
pass
class VersionConflictError(Exception):
"""
The caller asked for either draft or published head and gave a version which conflicted with it.
......
......@@ -2,6 +2,7 @@ import re
URL_RE = re.compile(r'^edx://(.+)$', re.IGNORECASE)
def parse_url(string):
"""
A url must begin with 'edx://' (case-insensitive match),
......@@ -33,8 +34,9 @@ def parse_url(string):
BLOCK_RE = re.compile(r'^\w+$', re.IGNORECASE)
def parse_block_ref(string):
"""
r"""
A block_ref is a string of word_chars.
<word_chars> matches one or more Unicode word characters; this includes most
......@@ -46,12 +48,13 @@ def parse_block_ref(string):
otherwise returns None.
"""
if len(string) > 0 and BLOCK_RE.match(string):
return {'block' : string}
return {'block': string}
return None
GUID_RE = re.compile(r'^(?P<version_guid>[A-F0-9]+)(#(?P<block>\w+))?$', re.IGNORECASE)
def parse_guid(string):
"""
A version_guid is a string of hex digits (0-F).
......@@ -68,8 +71,9 @@ def parse_guid(string):
COURSE_ID_RE = re.compile(r'^(?P<id>(\w+)(\.\w+\w*)*)(;(?P<revision>\w+))?(#(?P<block>\w+))?$', re.IGNORECASE)
def parse_course_id(string):
"""
r"""
A course_id has a main id component.
There may also be an optional revision (;published or ;draft).
......
from split import SplitMongoModuleStore
\ No newline at end of file
from split import SplitMongoModuleStore
from xmodule.modulestore.locator import DescriptionLocator
class DefinitionLazyLoader(object):
"""
A placeholder to put into an xblock in place of its definition which
......
......@@ -58,7 +58,7 @@ class SplitMongoKVS(KeyValueStore):
if isinstance(self._definition, DefinitionLazyLoader):
self._definition = self._definition.fetch()
if (key.field_name == 'data' and
not isinstance(self._definition.get('data'), dict)):
not isinstance(self._definition.get('data'), dict)):
return self._definition.get('data')
elif 'data' not in self._definition or key.field_name not in self._definition['data']:
raise KeyError()
......@@ -85,7 +85,7 @@ class SplitMongoKVS(KeyValueStore):
if isinstance(self._definition, DefinitionLazyLoader):
self._definition = self._definition.fetch()
if (key.field_name == 'data' and
not isinstance(self._definition.get('data'), dict)):
not isinstance(self._definition.get('data'), dict)):
self._definition.get('data')
else:
self._definition.setdefault('data', {})[key.field_name] = value
......@@ -111,7 +111,7 @@ class SplitMongoKVS(KeyValueStore):
if isinstance(self._definition, DefinitionLazyLoader):
self._definition = self._definition.fetch()
if (key.field_name == 'data' and
not isinstance(self._definition.get('data'), dict)):
not isinstance(self._definition.get('data'), dict)):
self._definition.setdefault('data', None)
else:
try:
......@@ -135,7 +135,7 @@ class SplitMongoKVS(KeyValueStore):
if isinstance(self._definition, DefinitionLazyLoader):
self._definition = self._definition.fetch()
if (key.field_name == 'data' and
not isinstance(self._definition.get('data'), dict)):
not isinstance(self._definition.get('data'), dict)):
return self._definition.get('data') is not None
else:
return key.field_name in self._definition.get('data', {})
......@@ -161,4 +161,3 @@ class SplitMongoKVS(KeyValueStore):
Get the metadata set by the ancestors (which own metadata may override or not)
"""
return self._inherited_metadata
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