From aecc037e2da8847e47eda03ac06e1b24aefc2a76 Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Mon, 3 Mar 2014 16:52:38 -0500 Subject: [PATCH] pylint and pep8 fixes --- .../lib/xmodule/xmodule/modulestore/__init__.py | 2 +- common/lib/xmodule/xmodule/modulestore/mixed.py | 8 ++++---- .../modulestore/tests/persistent_factories.py | 4 ++-- .../modulestore/tests/test_mixed_modulestore.py | 15 +++++++++++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/__init__.py b/common/lib/xmodule/xmodule/modulestore/__init__.py index b67480ac75..e010948e05 100644 --- a/common/lib/xmodule/xmodule/modulestore/__init__.py +++ b/common/lib/xmodule/xmodule/modulestore/__init__.py @@ -451,7 +451,7 @@ class ModuleStoreWrite(ModuleStoreRead): pass @abstractmethod - def delete_item(self, location, user_id=None, delete_all_versions=False, delete_children=False, force=False): + def delete_item(self, location, user_id=None, **kwargs): """ Delete an item from persistence. Pass the user's unique id which the persistent store should save with the update if it has that ability. diff --git a/common/lib/xmodule/xmodule/modulestore/mixed.py b/common/lib/xmodule/xmodule/modulestore/mixed.py index d4d6e5f039..c937093cad 100644 --- a/common/lib/xmodule/xmodule/modulestore/mixed.py +++ b/common/lib/xmodule/xmodule/modulestore/mixed.py @@ -344,7 +344,7 @@ class MixedModuleStore(ModuleStoreWriteBase): parent.children.append(location.url()) store.update_item(parent) elif isinstance(store, SplitMongoModuleStore): - if isinstance(course_or_parent_loc, basestring): # course_id + if isinstance(course_or_parent_loc, basestring): # course_id course_or_parent_loc = loc_mapper().translate_location_to_course_locator( course_or_parent_loc, None ) @@ -377,15 +377,15 @@ class MixedModuleStore(ModuleStoreWriteBase): store = self._get_modulestore_for_courseid(course_id) return store.update_item(xblock, user_id) - def delete_item(self, location, user_id=None): + def delete_item(self, location, user_id=None, **kwargs): """ - Delete the given item from persistence. + Delete the given item from persistence. kwargs allow modulestore specific parameters. """ course_id = self._infer_course_id_try(location) if course_id is None: raise ItemNotFoundError(u"Cannot find modulestore for %s" % location) store = self._get_modulestore_for_courseid(course_id) - return store.delete_item(location, user_id=user_id) + return store.delete_item(location, user_id=user_id, **kwargs) def close_all_connections(self): """ diff --git a/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py b/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py index b5cce6be6c..77759d2431 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/persistent_factories.py @@ -58,8 +58,8 @@ class ItemFactory(SplitFactory): # pylint: disable=W0613 @classmethod def _create(cls, target_class, parent_location, category='chapter', - user_id='test_user', block_id=None, definition_locator=None, force=False, - continue_version=False, **kwargs): + user_id='test_user', block_id=None, definition_locator=None, force=False, + continue_version=False, **kwargs): """ passes *kwargs* as the new item's field values: diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index 80e627e49f..f60a250e7b 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -109,7 +109,11 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): patcher.start() self.addCleanup(patcher.stop) self.addTypeEqualityFunc(BlockUsageLocator, '_compareIgnoreVersion') + # define attrs which get set in initdb to quell pylint + self.import_chapter_location = self.store = self.fake_location = self.xml_chapter_location = None + self.course_locations = [] + # pylint: disable=invalid-name def _create_course(self, default, course_id): """ Create a course w/ one item in the persistence store using the given course & item location. @@ -147,8 +151,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): return Location(course_dict) self.course_locations = { - course_id: generate_location(course_id) - for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2] + course_id: generate_location(course_id) + for course_id in [self.MONGO_COURSEID, self.XML_COURSEID1, self.XML_COURSEID2] } self.fake_location = Location('i4x', 'foo', 'bar', 'vertical', 'baz') self.import_chapter_location = self.course_locations[self.MONGO_COURSEID].replace( @@ -184,8 +188,8 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): # try negative cases self.assertFalse(self.store.has_item( - self.XML_COURSEID1, - self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem') + self.XML_COURSEID1, + self.course_locations[self.XML_COURSEID1].replace(name='not_findable', category='problem') )) self.assertFalse(self.store.has_item(self.MONGO_COURSEID, self.fake_location)) @@ -323,10 +327,12 @@ class TestMixedModuleStore(LocMapperSetupSansDjango): self.assertEqual(len(parents), 1) self.assertEqual(parents[0], self.course_locations[self.XML_COURSEID1]) + #============================================================================================================= # General utils for not using django settings #============================================================================================================= + def load_function(path): """ Load a function by name. @@ -338,6 +344,7 @@ def load_function(path): return getattr(import_module(module_path), name) +# pylint: disable=unused-argument def create_modulestore_instance(engine, doc_store_config, options, i18n_service=None): """ This will return a new instance of a modulestore given an engine and options