pep8/pylint violations fixes

This commit is contained in:
Chris Dodge
2013-05-14 10:53:10 -04:00
parent 5d2b8879f8
commit ef78c99f70
4 changed files with 31 additions and 37 deletions

View File

@@ -9,7 +9,7 @@ import re
from collections import namedtuple
from .exceptions import InvalidLocationError, InsufficientSpecificationError
from xmodule.errortracker import ErrorLog, make_error_tracker
from xmodule.errortracker import make_error_tracker
from bson.son import SON
log = logging.getLogger('mitx.' + 'modulestore')
@@ -64,7 +64,6 @@ class Location(_LocationBase):
"""
return re.sub('_+', '_', invalid.sub('_', value))
@staticmethod
def clean(value):
"""
@@ -72,7 +71,6 @@ class Location(_LocationBase):
"""
return Location._clean(value, INVALID_CHARS)
@staticmethod
def clean_keeping_underscores(value):
"""
@@ -82,7 +80,6 @@ class Location(_LocationBase):
"""
return INVALID_CHARS.sub('_', value)
@staticmethod
def clean_for_url_name(value):
"""
@@ -154,9 +151,7 @@ class Location(_LocationBase):
to mean wildcard selection.
"""
if (org is None and course is None and category is None and
name is None and revision is None):
if (org is None and course is None and category is None and name is None and revision is None):
location = loc_or_tag
else:
location = (loc_or_tag, org, course, category, name, revision)
@@ -191,7 +186,7 @@ class Location(_LocationBase):
match = MISSING_SLASH_URL_RE.match(location)
if match is None:
log.debug('location is instance of %s but no URL match' % basestring)
raise InvalidLocationError(location)
raise InvalidLocationError(location)
groups = match.groupdict()
check_dict(groups)
return _LocationBase.__new__(_cls, **groups)
@@ -233,7 +228,7 @@ class Location(_LocationBase):
html id attributes
"""
s = "-".join(str(v) for v in self.list()
if v is not None)
if v is not None)
return Location.clean_for_html(s)
def dict(self):
@@ -258,6 +253,12 @@ class Location(_LocationBase):
at the location URL hierachy"""
return "/".join([self.org, self.course, self.name])
def replace(self, **kwargs):
'''
Expose a public method for replacing location elements
'''
return self._replace(**kwargs)
class ModuleStore(object):
"""
@@ -382,12 +383,6 @@ class ModuleStore(object):
'''
raise NotImplementedError
def get_course(self, course_id):
'''
Look for a specific course id. Returns the course descriptor, or None if not found.
'''
raise NotImplementedError
def get_parent_locations(self, location, course_id):
'''Find all locations that are the parents of this location in this
course. Needed for path_to_location().
@@ -406,8 +401,7 @@ class ModuleStore(object):
courses = [
course
for course in self.get_courses()
if course.location.org == location.org
and course.location.course == location.course
if course.location.org == location.org and course.location.course == location.course
]
return courses

View File

@@ -13,11 +13,12 @@ def as_draft(location):
"""
return Location(location)._replace(revision=DRAFT)
def as_published(location):
"""
Returns the Location that is the published version for `location`
"""
return Location(location)._replace(revision=None)
return Location(location)._replace(revision=None)
def wrap_draft(item):

View File

@@ -3,7 +3,6 @@ from time import gmtime
from uuid import uuid4
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore
from xmodule.timeparse import stringify_time
from xmodule.modulestore.inheritance import own_metadata