Commit a28b02ae by Julian Arni

Pep8 and pylint fixes

parent fcd11d93
...@@ -32,10 +32,10 @@ class ImportTestCase(CourseTestCase): ...@@ -32,10 +32,10 @@ class ImportTestCase(CourseTestCase):
os.utime(name, None) os.utime(name, None)
# Create tar test files ----------------------------------------------- # Create tar test files -----------------------------------------------
# OK course: # OK course:
good_dir = tempfile.mkdtemp(dir=self.content_dir) good_dir = tempfile.mkdtemp(dir=self.content_dir)
os.makedirs(os.path.join(good_dir, "course")) os.makedirs(os.path.join(good_dir, "course"))
with open(os.path.join(good_dir, "course.xml") , "w+") as f: with open(os.path.join(good_dir, "course.xml"), "w+") as f:
f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>') f.write('<course url_name="2013_Spring" org="EDx" course="0.00x"/>')
with open(os.path.join(good_dir, "course", "2013_Spring.xml"), "w+") as f: with open(os.path.join(good_dir, "course", "2013_Spring.xml"), "w+") as f:
...@@ -44,7 +44,7 @@ class ImportTestCase(CourseTestCase): ...@@ -44,7 +44,7 @@ class ImportTestCase(CourseTestCase):
self.good_tar = os.path.join(self.content_dir, "good.tar.gz") self.good_tar = os.path.join(self.content_dir, "good.tar.gz")
with tarfile.open(self.good_tar, "w:gz") as gtar: with tarfile.open(self.good_tar, "w:gz") as gtar:
gtar.add(good_dir) gtar.add(good_dir)
# Bad course (no 'course.xml' file): # Bad course (no 'course.xml' file):
bad_dir = tempfile.mkdtemp(dir=self.content_dir) bad_dir = tempfile.mkdtemp(dir=self.content_dir)
touch(os.path.join(bad_dir, "bad.xml")) touch(os.path.join(bad_dir, "bad.xml"))
...@@ -62,11 +62,11 @@ class ImportTestCase(CourseTestCase): ...@@ -62,11 +62,11 @@ class ImportTestCase(CourseTestCase):
""" """
with open(self.bad_tar) as btar: with open(self.bad_tar) as btar:
resp = self.client.post( resp = self.client.post(
self.url, self.url,
{ {
"name": self.bad_tar, "name": self.bad_tar,
"course-data": [btar] "course-data": [btar]
}) })
self.assertEquals(resp.status_code, 415) self.assertEquals(resp.status_code, 415)
def test_with_coursexml(self): def test_with_coursexml(self):
...@@ -82,4 +82,3 @@ class ImportTestCase(CourseTestCase): ...@@ -82,4 +82,3 @@ class ImportTestCase(CourseTestCase):
"course-data": [gtar] "course-data": [gtar]
}) })
self.assert2XX(resp.status_code) self.assert2XX(resp.status_code)
...@@ -19,7 +19,6 @@ from django.core.files.temp import NamedTemporaryFile ...@@ -19,7 +19,6 @@ from django.core.files.temp import NamedTemporaryFile
from django.views.decorators.http import require_http_methods from django.views.decorators.http import require_http_methods
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from cache_toolbox.core import del_cached_content
from auth.authz import create_all_course_groups from auth.authz import create_all_course_groups
from xmodule.modulestore.xml_importer import import_from_xml from xmodule.modulestore.xml_importer import import_from_xml
...@@ -38,7 +37,7 @@ __all__ = ['import_course', 'generate_export_course', 'export_course'] ...@@ -38,7 +37,7 @@ __all__ = ['import_course', 'generate_export_course', 'export_course']
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
MAX_UP_LENGTH = 20000352 # Max chunk size for uploads MAX_UP_LENGTH = 20000352 # Max chunk size for uploads
# Regex to capture Content-Range header ranges. # Regex to capture Content-Range header ranges.
CONTENT_RE = re.compile(r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11})") CONTENT_RE = re.compile(r"(?P<start>\d{1,11})-(?P<stop>\d{1,11})/(?P<end>\d{1,11})")
...@@ -113,18 +112,18 @@ def import_course(request, org, course, name): ...@@ -113,18 +112,18 @@ def import_course(request, org, course, name):
if int(content_range['stop']) != int(content_range['end']) - 1: if int(content_range['stop']) != int(content_range['end']) - 1:
# More chunks coming # More chunks coming
return JsonResponse({ return JsonResponse({
"files": [{ "files": [{
"name": filename, "name": filename,
"size": size, "size": size,
"deleteUrl": "", "deleteUrl": "",
"deleteType": "", "deleteType": "",
"url": reverse('import_course', kwargs={ "url": reverse('import_course', kwargs={
'org': location.org, 'org': location.org,
'course': location.course, 'course': location.course,
'name': location.name 'name': location.name
}), }),
"thumbnailUrl": "" "thumbnailUrl": ""
}] }]
}) })
else: # This was the last chunk. else: # This was the last chunk.
...@@ -147,7 +146,7 @@ def import_course(request, org, course, name): ...@@ -147,7 +146,7 @@ def import_course(request, org, course, name):
def get_all_files(directory): def get_all_files(directory):
""" """
For each file in the directory, yield a 2-tuple of (file-name, For each file in the directory, yield a 2-tuple of (file-name,
directory-path) directory-path)
""" """
for dirpath, _dirnames, filenames in os.walk(directory): for dirpath, _dirnames, filenames in os.walk(directory):
for filename in filenames: for filename in filenames:
......
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