Add documentation and comments.

This commit is contained in:
Don Mitchell
2013-09-24 16:30:24 -04:00
parent 8e7fc1537f
commit 20e4d585c8
2 changed files with 13 additions and 2 deletions

View File

@@ -104,7 +104,16 @@ class MongoContentStore(ContentStore):
with disk_fs.open(content.name, 'wb') as asset_file:
asset_file.write(content.data)
def export_all_for_course(self, course_location, output_directory, policy_file):
def export_all_for_course(self, course_location, output_directory, assets_policy_file):
"""
Export all of this course's assets to the output_directory. Export all of the assets'
attributes to the policy file.
:param course_location: the Location of type 'course'
:param output_directory: the directory under which to put all the asset files
:param assets_policy_file: the filename for the policy file which should be in the same
directory as the other policy files.
"""
policy = {}
assets = self.get_all_content_for_course(course_location)
@@ -115,7 +124,7 @@ class MongoContentStore(ContentStore):
if attr not in ['_id', 'md5', 'uploadDate', 'length', 'chunkSize']:
policy.setdefault(asset_location.url(), {})[attr] = value
with open(policy_file, 'w') as f:
with open(assets_policy_file, 'w') as f:
json.dump(policy, f)
def get_all_content_thumbnails_for_course(self, location):

View File

@@ -27,6 +27,8 @@ def import_static_content(modules, course_loc, course_data_path, static_content_
with open(course_data_path / 'policies/assets.json') as f:
policy = json.load(f)
except (IOError, ValueError) as err:
# xml backed courses won't have this file, only exported courses; so, its absence is not
# really an exception.
policy = {}
verbose = True