Commit e69955b4 by Don Mitchell

Pylint/pep8 fixes

parent 99bf6417
...@@ -10,7 +10,6 @@ from django.views.decorators.http import require_POST ...@@ -10,7 +10,6 @@ from django.views.decorators.http import require_POST
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from cache_toolbox.core import del_cached_content from cache_toolbox.core import del_cached_content
from auth.authz import create_all_course_groups
from xmodule.contentstore.django import contentstore from xmodule.contentstore.django import contentstore
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
......
...@@ -15,9 +15,9 @@ from PIL import Image ...@@ -15,9 +15,9 @@ from PIL import Image
class StaticContent(object): class StaticContent(object):
def __init__(self, loc, name, content_type, data, last_modified_at=None, thumbnail_location=None, import_path=None, 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.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.content_type = content_type
self._data = data self._data = data
self.length = length self.length = length
......
...@@ -24,15 +24,15 @@ class MongoContentStore(ContentStore): ...@@ -24,15 +24,15 @@ class MongoContentStore(ContentStore):
self.fs = gridfs.GridFS(_db, bucket) 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): 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 # 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, displayname=content.name, thumbnail_location=content.thumbnail_location,
import_path=content.import_path) as fp: import_path=content.import_path) as fp:
if hasattr(content.data, '__iter__'): if hasattr(content.data, '__iter__'):
...@@ -43,25 +43,25 @@ class MongoContentStore(ContentStore): ...@@ -43,25 +43,25 @@ class MongoContentStore(ContentStore):
return content return content
def delete(self, id): def delete(self, content_id):
if self.fs.exists({"_id": id}): if self.fs.exists({"_id": content_id}):
self.fs.delete(id) self.fs.delete(content_id)
def find(self, location, throw_on_not_found=True, as_stream=False): 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: try:
if as_stream: if as_stream:
fp = self.fs.get(id)
return StaticContentStream(location, fp.displayname, fp.content_type, fp, last_modified_at=fp.uploadDate, 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, thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None,
import_path=fp.import_path if hasattr(fp, 'import_path') else None, import_path=fp.import_path if hasattr(fp, 'import_path') else None,
length=fp.length) length=fp.length)
fp = self.fs.get(content_id)
else: else:
with self.fs.get(id) as fp:
return StaticContent(location, fp.displayname, fp.content_type, fp.read(), last_modified_at=fp.uploadDate, 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, thumbnail_location=fp.thumbnail_location if hasattr(fp, 'thumbnail_location') else None,
import_path=fp.import_path if hasattr(fp, 'import_path') else None, import_path=fp.import_path if hasattr(fp, 'import_path') else None,
length=fp.length) length=fp.length)
with self.fs.get(content_id) as fp:
except NoFile: except NoFile:
if throw_on_not_found: if throw_on_not_found:
raise NotFoundError() raise NotFoundError()
...@@ -69,9 +69,9 @@ class MongoContentStore(ContentStore): ...@@ -69,9 +69,9 @@ class MongoContentStore(ContentStore):
return None return None
def get_stream(self, location): def get_stream(self, location):
id = StaticContent.get_id_from_location(location) content_id = StaticContent.get_id_from_location(location)
try: try:
handle = self.fs.get(id) handle = self.fs.get(content_id)
except NoFile: except NoFile:
raise NotFoundError() raise NotFoundError()
......
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