From e69955b437de54a456b7509129ae79a72c4c736f Mon Sep 17 00:00:00 2001 From: Don Mitchell Date: Wed, 18 Sep 2013 11:39:12 -0400 Subject: [PATCH] Pylint/pep8 fixes --- cms/djangoapps/contentstore/views/assets.py | 1 - .../xmodule/xmodule/contentstore/content.py | 4 ++-- .../lib/xmodule/xmodule/contentstore/mongo.py | 24 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cms/djangoapps/contentstore/views/assets.py b/cms/djangoapps/contentstore/views/assets.py index b1fb148300..3d5704b869 100644 --- a/cms/djangoapps/contentstore/views/assets.py +++ b/cms/djangoapps/contentstore/views/assets.py @@ -10,7 +10,6 @@ from django.views.decorators.http import require_POST from mitxmako.shortcuts import render_to_response from cache_toolbox.core import del_cached_content -from auth.authz import create_all_course_groups from xmodule.contentstore.django import contentstore from xmodule.modulestore.django import modulestore diff --git a/common/lib/xmodule/xmodule/contentstore/content.py b/common/lib/xmodule/xmodule/contentstore/content.py index 69a2d6a5ef..bd3a403bb1 100644 --- a/common/lib/xmodule/xmodule/contentstore/content.py +++ b/common/lib/xmodule/xmodule/contentstore/content.py @@ -15,9 +15,9 @@ from PIL import Image class StaticContent(object): def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None, - length=None): + length=None, locked=False): self.location = loc - self.name = name # a display string which can be edited, and thus not part of the location which needs to be fixed + self.name = name # a display string which can be edited, and thus not part of the location which needs to be fixed self.content_type = content_type self._data = data self.length = length diff --git a/common/lib/xmodule/xmodule/contentstore/mongo.py b/common/lib/xmodule/xmodule/contentstore/mongo.py index 482ce585e6..78e8b65e1b 100644 --- a/common/lib/xmodule/xmodule/contentstore/mongo.py +++ b/common/lib/xmodule/xmodule/contentstore/mongo.py @@ -24,15 +24,15 @@ class MongoContentStore(ContentStore): self.fs = gridfs.GridFS(_db, bucket) - self.fs_files = _db[bucket + ".files"] # the underlying collection GridFS uses + self.fs_files = _db[bucket + ".files"] # the underlying collection GridFS uses def save(self, content): - id = content.get_id() + content_id = content.get_id() # Seems like with the GridFS we can't update existing ID's we have to do a delete/add pair - self.delete(id) + self.delete(content_id) - with self.fs.new_file(_id=id, filename=content.get_url_path(), content_type=content.content_type, + with self.fs.new_file(_id=content_id, filename=content.get_url_path(), content_type=content.content_type, displayname=content.name, thumbnail_location=content.thumbnail_location, import_path=content.import_path) as fp: if hasattr(content.data, '__iter__'): @@ -43,25 +43,25 @@ class MongoContentStore(ContentStore): return content - def delete(self, id): - if self.fs.exists({"_id": id}): - self.fs.delete(id) + def delete(self, content_id): + if self.fs.exists({"_id": content_id}): + self.fs.delete(content_id) def find(self, location, throw_on_not_found=True, as_stream=False): - id = StaticContent.get_id_from_location(location) + content_id = StaticContent.get_id_from_location(location) try: if as_stream: - fp = self.fs.get(id) return StaticContentStream(location, fp.displayname, fp.content_type, fp, last_modified_at=fp.uploadDate, thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None, import_path=fp.import_path if hasattr(fp, 'import_path') else None, length=fp.length) + fp = self.fs.get(content_id) else: - with self.fs.get(id) as fp: return StaticContent(location, fp.displayname, fp.content_type, fp.read(), last_modified_at=fp.uploadDate, thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None, import_path=fp.import_path if hasattr(fp, 'import_path') else None, length=fp.length) + with self.fs.get(content_id) as fp: except NoFile: if throw_on_not_found: raise NotFoundError() @@ -69,9 +69,9 @@ class MongoContentStore(ContentStore): return None def get_stream(self, location): - id = StaticContent.get_id_from_location(location) + content_id = StaticContent.get_id_from_location(location) try: - handle = self.fs.get(id) + handle = self.fs.get(content_id) except NoFile: raise NotFoundError()