Commit 6dab09f5 by Calen Pennington

PEP8 and Pylint fixes

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