Commit d1672e31 by Sarina Canelake

Opaque-keys: fix pylint violations

parent c535a6b9
......@@ -21,7 +21,7 @@ from xmodule.modulestore.django import modulestore
from xmodule.contentstore.content import StaticContent
from xmodule.tabs import PDFTextbookTabs
from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError, InsufficientSpecificationError
from xmodule.modulestore.exceptions import ItemNotFoundError, InvalidLocationError
from opaque_keys import InvalidKeyError
from xmodule.modulestore.locations import Location, SlashSeparatedCourseKey
......
......@@ -30,7 +30,6 @@ from xmodule.modulestore.xml_exporter import export_to_xml
from .access import has_course_access
from .access import has_course_access
from extract_tar import safetar_extractall
from student import auth
from student.roles import CourseInstructorRole, CourseStaffRole, GlobalStaff
......
......@@ -13,7 +13,6 @@ import csv
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandError
from opaque_keys import InvalidKeyError
from student.models import anonymous_id_for_user
from xmodule.modulestore.locations import SlashSeparatedCourseKey
......
##
## A script to create some dummy users
"""
A script to create some dummy users
"""
from django.core.management.base import BaseCommand
from student.models import CourseEnrollment
from opaque_keys import InvalidKeyError
from xmodule.modulestore.keys import CourseKey
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from student.views import _do_create_account, get_random_post_override
def create(n, course_key):
"""Create n users, enrolling them in course_key if it's not None"""
for i in range(n):
(user, user_profile, _) = _do_create_account(get_random_post_override())
def create(num, course_key):
"""Create num users, enrolling them in course_key if it's not None"""
for idx in range(num):
(user, user_profile, __) = _do_create_account(get_random_post_override())
if course_key is not None:
CourseEnrollment.enroll(user, course_key)
......@@ -31,7 +33,7 @@ Examples:
print Command.help
return
n = int(args[0])
num = int(args[0])
if len(args) == 2:
try:
......@@ -41,4 +43,4 @@ Examples:
else:
course_key = None
create(n, course_key)
create(num, course_key)
"""
Management command to generate a list of grades for
all students that are enrolled in a course.
"""
from courseware import grades, courses
from certificates.models import GeneratedCertificate
from django.test.client import RequestFactory
......
......@@ -7,7 +7,6 @@ from abc import ABCMeta, abstractmethod
from django.contrib.auth.models import User
from student.models import CourseAccessRole
from xmodule_django.models import CourseKeyField
class AccessRole(object):
......
......@@ -10,7 +10,6 @@ import urllib
from xmodule.modulestore.exceptions import InvalidLocationError, ItemNotFoundError
from xmodule.modulestore.locator import BlockUsageLocator, CourseLocator
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.modulestore.keys import UsageKey
class LocMapperStore(object):
......
......@@ -11,7 +11,6 @@ from bulk_email.models import CourseEmailTemplate, COURSE_EMAIL_MESSAGE_BODY_TAG
from opaque_keys import InvalidKeyError
from xmodule.modulestore import XML_MODULESTORE_TYPE
from xmodule.modulestore.django import modulestore
from opaque_keys import InvalidKeyError
from xmodule.modulestore.keys import CourseKey
from xmodule.modulestore.locations import SlashSeparatedCourseKey
......
"""
Management command which sets or gets the certificate whitelist for a given
user/course
"""
from django.core.management.base import BaseCommand, CommandError
from optparse import make_option
from opaque_keys import InvalidKeyError
......@@ -56,7 +60,7 @@ class Command(BaseCommand):
try:
course = CourseKey.from_string(course_id)
except InvalidKeyError:
log.warning("Course id %s could not be parsed as a CourseKey; falling back to SSCK.from_dep_str", course_id)
print("Course id {} could not be parsed as a CourseKey; falling back to SSCK.from_dep_str".format(course_id))
course = SlashSeparatedCourseKey.from_deprecated_string(course_id)
if options['add'] and options['del']:
......
"""
Management command to find all students that need certificates for
courses that have finished, and put their cert requests on the queue.
"""
from django.core.management.base import BaseCommand, CommandError
from certificates.models import certificate_status_for_student
from certificates.queue import XQueueCertInterface
......@@ -73,7 +77,7 @@ class Command(BaseCommand):
try:
course = CourseKey.from_string(options['course'])
except InvalidKeyError:
log.warning("Course id %s could not be parsed as a CourseKey; falling back to SSCK.from_dep_str", course_id)
print("Course id {} could not be parsed as a CourseKey; falling back to SSCK.from_dep_str".format(options['course']))
course = SlashSeparatedCourseKey.from_deprecated_string(options['course'])
ended_courses = [course]
else:
......
......@@ -113,7 +113,12 @@ class StudentModuleHistory(models.Model):
max_grade = models.FloatField(null=True, blank=True)
@receiver(post_save, sender=StudentModule)
def save_history(sender, instance, **kwargs): # pylint: disable=no-self-argument
def save_history(sender, instance, **kwargs): # pylint: disable=no-self-argument, unused-argument
"""
Checks the instance's module_type, and creates & saves a
StudentModuleHistory entry if the module_type is one that
we save.
"""
if instance.module_type in StudentModuleHistory.HISTORY_SAVING_TYPES:
history_entry = StudentModuleHistory(student_module=instance,
version=None,
......
......@@ -22,7 +22,6 @@ from xmodule.video_module.transcripts_utils import (
TranscriptException,
TranscriptsGenerationException,
)
from xmodule.modulestore.mongo.base import MongoModuleStore
from xmodule.modulestore.locations import AssetLocation
SRT_content = textwrap.dedent("""
......
......@@ -47,7 +47,6 @@ from opaque_keys import InvalidKeyError
from microsite_configuration import microsite
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.modulestore.keys import UsageKey
log = logging.getLogger("edx.courseware")
......
"""
Management command to seed default permissions and roles.
"""
from django.core.management.base import BaseCommand, CommandError
from django_comment_common.utils import seed_permissions_roles
from xmodule.modulestore.locations import SlashSeparatedCourseKey
......
#!/usr/bin/python
#
# django management command: dump grades to csv files
# for use by batch processes
"""
django management command: dump grades to csv files
for use by batch processes
"""
from instructor.offline_gradecalc import offline_grade_calculation
from courseware.courses import get_course_by_id
from xmodule.modulestore.django import modulestore
......@@ -37,7 +37,7 @@ class Command(BaseCommand):
except InvalidKeyError:
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try:
course = get_course_by_id(course_key)
_course = get_course_by_id(course_key)
except Exception as err:
print "-----------------------------------------------------------------------------"
print "Sorry, cannot find course with id {}".format(course_id)
......
#!/usr/bin/python
#
# django management command: dump grades to csv files
# for use by batch processes
"""
django management command: dump grades to csv files
for use by batch processes
"""
import csv
from instructor.views.legacy import get_student_grade_summary_data
......@@ -52,7 +52,9 @@ class Command(BaseCommand):
try:
course = get_course_by_id(course_key)
except Exception as err:
# Ok with catching general exception here because this is run as a management command
# and the exception is exposed right away to the user.
except Exception as err: # pylint: disable=broad-except
print "-----------------------------------------------------------------------------"
print "Sorry, cannot find course with id {}".format(course_id)
print "Got exception {}".format(err)
......
......@@ -6,7 +6,6 @@ from django.core.management.base import BaseCommand
from optparse import make_option
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.keys import UsageKey
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild
from xmodule.open_ended_grading_classes.open_ended_module import OpenEndedModule
......
......@@ -9,7 +9,6 @@ from optparse import make_option
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.keys import UsageKey
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.open_ended_grading_classes.openendedchild import OpenEndedChild
......
# ======== Offline calculation of grades =============================================================================
#
# Computing grades of a large number of students can take a long time. These routines allow grades to
# be computed offline, by a batch process (eg cronjob).
#
# The grades are stored in the OfflineComputedGrade table of the courseware model.
"""
======== Offline calculation of grades =============================================================
Computing grades of a large number of students can take a long time. These routines allow grades to
be computed offline, by a batch process (eg cronjob).
The grades are stored in the OfflineComputedGrade table of the courseware model.
"""
import json
import time
......@@ -49,7 +50,7 @@ def offline_grade_calculation(course_key):
gradeset = grades.grade(student, request, course, keep_raw_scores=True)
gs = enc.encode(gradeset)
ocg, created = models.OfflineComputedGrade.objects.get_or_create(user=student, course_id=course_key)
ocg, _created = models.OfflineComputedGrade.objects.get_or_create(user=student, course_id=course_key)
ocg.gradeset = gs
ocg.save()
print "%s done" % student # print statement used because this is run by a management command
......
......@@ -13,7 +13,6 @@ from nose.tools import raises
from mock import Mock, patch
from django.conf import settings
from django.test.utils import override_settings
from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpRequest, HttpResponse
from django_comment_common.models import FORUM_ROLE_COMMUNITY_TA, Role
......
......@@ -9,7 +9,6 @@ from courseware.models import StudentModule
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings
from django.test.client import RequestFactory
from student.tests.factories import UserFactory
from xmodule.modulestore.tests.factories import CourseFactory
from courseware.tests.modulestore_config import TEST_DATA_MIXED_MODULESTORE
......@@ -27,7 +26,6 @@ from xmodule.modulestore.locations import SlashSeparatedCourseKey
from submissions import api as sub_api
from student.models import anonymous_id_for_user
from .test_tools import msk_from_problem_urlname
class TestSettableEnrollmentState(TestCase):
......
......@@ -11,7 +11,6 @@ from courseware.tests.tests import TEST_DATA_MIXED_MODULESTORE
from capa.tests.response_xml_factory import StringResponseXMLFactory
from courseware.tests.factories import StudentModuleFactory
from xmodule.modulestore import Location
from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.modulestore.django import modulestore
......
......@@ -16,7 +16,6 @@ from courseware.models import StudentModule
from submissions import api as sub_api
from student.models import anonymous_id_for_user
from .test_tools import msk_from_problem_urlname
@override_settings(MODULESTORE=TEST_DATA_MIXED_MODULESTORE)
......
......@@ -148,7 +148,7 @@ def create(request, course_key):
return ApiResponse(http_response=response, data=None)
def read(request, course_key, note_id):
def read(request, course_key, note_id): # pylint: disable=unused-argument (course_key)
'''
Returns a single annotation object.
'''
......@@ -163,7 +163,7 @@ def read(request, course_key, note_id):
return ApiResponse(http_response=HttpResponse(), data=note.as_dict())
def update(request, course_key, note_id):
def update(request, course_key, note_id): # pylint: disable=unused-argument (course_key)
'''
Updates an annotation object and returns a 303 with the read location.
'''
......@@ -247,7 +247,7 @@ def search(request, course_key):
return ApiResponse(http_response=HttpResponse(), data=result)
def root(request, course_key):
def root(request, course_key): # pylint: disable=unused-argument (course_key, request)
'''
Returns version information about the API.
'''
......
......@@ -7,7 +7,6 @@ import json
from courseware.models import StudentModule
from track.models import TrackingLog
from psychometrics.models import PsychometricData
from xmodule.modulestore.keys import UsageKey
from django.conf import settings
from django.core.management.base import BaseCommand
......
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