Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
Fixing pep8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy committed Dec 11, 2014
1 parent d65d309 commit 36e77c7
Show file tree
Hide file tree
Showing 63 changed files with 524 additions and 463 deletions.
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/features/html-editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def use_code_editor(action):


def perform_action_in_plugin(action):
# Wait for the plugin window to open.
# Wait for the plugin window to open.
world.wait_for_visible('.mce-window')

# Trigger the action
Expand Down
4 changes: 3 additions & 1 deletion cms/djangoapps/contentstore/tests/test_core_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def get_id(self):


class CachingTestCase(TestCase):
# Tests for https://edx.lighthouseapp.com/projects/102637/tickets/112-updating-asset-does-not-refresh-the-cached-copy
"""
Tests for https://edx.lighthouseapp.com/projects/102637/tickets/112-updating-asset-does-not-refresh-the-cached-copy
"""
unicodeLocation = Location(u'c4x', u'mitX', u'800', u'run', u'thumbnail', u'monsters.jpg')
# Note that some of the parts are strings instead of unicode strings
nonUnicodeLocation = Location('c4x', u'mitX', u'800', u'run', 'thumbnail', 'monsters.jpg')
Expand Down
2 changes: 1 addition & 1 deletion cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def create_template_dict(name, cat, boilerplate_name=None, is_common=False):
# Set component types according to course policy file
if isinstance(course_advanced_keys, list):
for category in course_advanced_keys:
if category in advanced_component_types and not category in categories:
if category in advanced_component_types and category not in categories:
# boilerplates not supported for advanced components
try:
component_display_name = xblock_type_display_name(category, default_display_name=category)
Expand Down
6 changes: 3 additions & 3 deletions cms/djangoapps/contentstore/views/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ def textbooks_list_handler(request, course_key_string):
with store.bulk_operations(course_key):
course = _get_course_module(course_key, request.user)

if not "application/json" in request.META.get('HTTP_ACCEPT', 'text/html'):
if "application/json" not in request.META.get('HTTP_ACCEPT', 'text/html'):
# return HTML page
upload_asset_url = reverse_course_url('assets_handler', course_key)
textbook_url = reverse_course_url('textbooks_list_handler', course_key)
Expand All @@ -1050,7 +1050,7 @@ def textbooks_list_handler(request, course_key_string):

tids = set(t["id"] for t in textbooks if "id" in t)
for textbook in textbooks:
if not "id" in textbook:
if "id" not in textbook:
tid = assign_textbook_id(textbook, tids)
textbook["id"] = tid
tids.add(tid)
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def group_configurations_list_handler(request, course_key_string):
})
elif "application/json" in request.META.get('HTTP_ACCEPT'):
if request.method == 'POST':
# create a new group configuration for the course
# create a new group configuration for the course
try:
new_configuration = GroupConfiguration(request.body, course).get_user_partition()
except GroupConfigurationsValidationError as err:
Expand Down
5 changes: 3 additions & 2 deletions cms/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@

# Ignore deprecation warnings (so we don't clutter Jenkins builds/production)
# https://docs.python.org/2/library/warnings.html#the-warnings-filter
simplefilter('ignore') # Change to "default" to see the first instance of each hit
# or "error" to convert all into errors
simplefilter('ignore')
# Change to "default" to see the first instance of each hit
# or "error" to convert all into errors

################################# CELERY ######################################

Expand Down
5 changes: 3 additions & 2 deletions common/djangoapps/django_comment_common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ def __unicode__(self):
# pylint: disable=no-member
return self.name + " for " + (self.course_id.to_deprecated_string() if self.course_id else "all courses")

def inherit_permissions(self, role): # TODO the name of this method is a little bit confusing,
# since it's one-off and doesn't handle inheritance later
# TODO the name of this method is a little bit confusing,
# since it's one-off and doesn't handle inheritance later
def inherit_permissions(self, role):
if role.course_id and role.course_id != self.course_id:
logging.warning(
"%s cannot inherit permissions from %s due to course_id inconsistency",
Expand Down
40 changes: 20 additions & 20 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,50 +452,50 @@ def is_student_password_reuse_restricted(cls):
"""
Returns whether the configuration which limits password reuse has been turned on
"""
return settings.FEATURES['ADVANCED_SECURITY'] and \
settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE', 0
) > 0
min_diff_pw = settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DIFFERENT_STUDENT_PASSWORDS_BEFORE_REUSE', 0
)
return settings.FEATURES['ADVANCED_SECURITY'] and min_diff_pw > 0

@classmethod
def is_staff_password_reuse_restricted(cls):
"""
Returns whether the configuration which limits password reuse has been turned on
"""
return settings.FEATURES['ADVANCED_SECURITY'] and \
settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE', 0
) > 0
min_diff_pw = settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE', 0
)
return settings.FEATURES['ADVANCED_SECURITY'] and min_diff_pw > 0

@classmethod
def is_password_reset_frequency_restricted(cls):
"""
Returns whether the configuration which limits the password reset frequency has been turned on
"""
return settings.FEATURES['ADVANCED_SECURITY'] and \
settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS', None
)
min_days_between_reset = settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_TIME_IN_DAYS_BETWEEN_ALLOWED_RESETS'
)
return settings.FEATURES['ADVANCED_SECURITY'] and min_days_between_reset

@classmethod
def is_staff_forced_password_reset_enabled(cls):
"""
Returns whether the configuration which forces password resets to occur has been turned on
"""
return settings.FEATURES['ADVANCED_SECURITY'] and \
settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DAYS_FOR_STAFF_ACCOUNTS_PASSWORD_RESETS', None
)
min_days_between_reset = settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DAYS_FOR_STAFF_ACCOUNTS_PASSWORD_RESETS'
)
return settings.FEATURES['ADVANCED_SECURITY'] and min_days_between_reset

@classmethod
def is_student_forced_password_reset_enabled(cls):
"""
Returns whether the configuration which forces password resets to occur has been turned on
"""
return settings.FEATURES['ADVANCED_SECURITY'] and \
settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DAYS_FOR_STUDENT_ACCOUNTS_PASSWORD_RESETS', None
)
min_days_pw_reset = settings.ADVANCED_SECURITY_CONFIG.get(
'MIN_DAYS_FOR_STUDENT_ACCOUNTS_PASSWORD_RESETS'
)
return settings.FEATURES['ADVANCED_SECURITY'] and min_days_pw_reset

@classmethod
def should_user_reset_password_now(cls, user):
Expand Down
28 changes: 14 additions & 14 deletions common/djangoapps/student/tests/test_bulk_email_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def setUp(self):
self.url = reverse('dashboard')
# URL for email settings modal
self.email_modal_link = (
('<a href="#email-settings-modal" class="email-settings" rel="leanModal" '
'data-course-id="{0}/{1}/{2}" data-course-number="{1}" '
'data-optout="False">Email Settings</a>').format(
self.course.org,
self.course.number,
self.course.display_name.replace(' ', '_')
)
'<a href="#email-settings-modal" class="email-settings" rel="leanModal" '
'data-course-id="{org}/{num}/{name}" data-course-number="{num}" '
'data-optout="False">Email Settings</a>'
).format(
org=self.course.org,
num=self.course.number,
name=self.course.display_name.replace(' ', '_'),
)

def tearDown(self):
Expand Down Expand Up @@ -111,13 +111,13 @@ def setUp(self):

# URL for email settings modal
self.email_modal_link = (
('<a href="#email-settings-modal" class="email-settings" rel="leanModal" '
'data-course-id="{0}/{1}/{2}" data-course-number="{1}" '
'data-optout="False">Email Settings</a>').format(
'edX',
'toy',
'2012_Fall'
)
'<a href="#email-settings-modal" class="email-settings" rel="leanModal" '
'data-course-id="{org}/{num}/{name}" data-course-number="{num}" '
'data-optout="False">Email Settings</a>'
).format(
org='edX',
num='toy',
name='2012_Fall',
)

@patch.dict(settings.FEATURES, {'ENABLE_INSTRUCTOR_EMAIL': True, 'REQUIRE_COURSE_EMAIL_AUTH': False})
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ def login_user(request, error=""): # pylint: disable-msg=too-many-statements,un
_("Use your {platform_name} username and password to log into {platform_name} below, "
"and then link your {platform_name} account with {provider_name} from your dashboard.").format(
platform_name=settings.PLATFORM_NAME, provider_name=requested_provider.NAME
)
)
+ "<br/><br/>" +
_("If you don't have an {platform_name} account yet, click <strong>Register Now</strong> at the top of the page.").format(
platform_name=settings.PLATFORM_NAME
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def store_uploaded_file(
uploaded_file = request.FILES[file_key]
try:
file_extension = os.path.splitext(uploaded_file.name)[1].lower()
if not file_extension in allowed_file_types:
if file_extension not in allowed_file_types:
file_types = "', '".join(allowed_file_types)
msg = ungettext(
"The file must end with the extension '{file_types}'.",
Expand Down
2 changes: 1 addition & 1 deletion common/lib/capa/capa/correctmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_npoints(self, answer_id):
return npoints
elif self.is_correct(answer_id):
return 1
# if not correct and no points have been assigned, return 0
# if not correct and no points have been assigned, return 0
return 0

def set_property(self, answer_id, property, value):
Expand Down
2 changes: 1 addition & 1 deletion common/lib/capa/capa/customrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, system, xml):

mathstr = re.sub(r'\$(.*)\$', r'[mathjaxinline]\1[/mathjaxinline]', xml.text)
mtag = 'mathjax'
if not r'\displaystyle' in mathstr:
if r'\displaystyle' not in mathstr:
mtag += 'inline'
else:
mathstr = mathstr.replace(r'\displaystyle', '')
Expand Down
1 change: 0 additions & 1 deletion common/lib/capa/capa/tests/test_customrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ def test_parsing(self):
self.check_parse('$abc', '$abc')
self.check_parse(r'$\displaystyle 2+2$', '[mathjax] 2+2[/mathjax]')


# NOTE: not testing get_html yet because I don't understand why it's doing what it's doing.
38 changes: 26 additions & 12 deletions common/lib/capa/capa/tests/test_input_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,17 +795,30 @@ class ChoiceTextGroupTemplateTest(TemplateTestCase):
'1_choiceinput_1_textinput_0': '0'}

def setUp(self):
choices = [('1_choiceinput_0bc',
[{'tail_text': '', 'type': 'text', 'value': '', 'contents': ''},
{'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_0_textinput_0'}]),
('1_choiceinput_1bc', [{'tail_text': '', 'type': 'text', 'value': '', 'contents': ''},
{'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_1_textinput_0'}])]
self.context = {'id': '1',
'choices': choices,
'status': Status('correct'),
'input_type': 'radio',
'label': 'choicetext label',
'value': self.VALUE_DICT}
choices = [
(
'1_choiceinput_0bc',
[
{'tail_text': '', 'type': 'text', 'value': '', 'contents': ''},
{'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_0_textinput_0'},
]
),
(
'1_choiceinput_1bc',
[
{'tail_text': '', 'type': 'text', 'value': '', 'contents': ''},
{'tail_text': '', 'type': 'textinput', 'value': '', 'contents': 'choiceinput_1_textinput_0'},
]
)
]
self.context = {
'id': '1',
'choices': choices,
'status': Status('correct'),
'input_type': 'radio',
'label': 'choicetext label',
'value': self.VALUE_DICT,
}

super(ChoiceTextGroupTemplateTest, self).setUp()

Expand Down Expand Up @@ -885,7 +898,8 @@ def test_problem_marked_unsubmitted(self):
{'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': {}},
{'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.EMPTY_DICT},
{'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.VALUE_DICT},
{'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.BOTH_CHOICE_CHECKBOX}]
{'status': Status('unsubmitted'), 'input_type': 'checkbox', 'value': self.BOTH_CHOICE_CHECKBOX},
]

self.context['status'] = Status('unanswered')

Expand Down
2 changes: 1 addition & 1 deletion common/lib/capa/capa/tests/test_responsetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ def test_hints(self):
case_sensitive=False,
hints=hints,
)
# We should get a hint for Wisconsin
# We should get a hint for Wisconsin
input_dict = {'1_2_1': 'Wisconsin'}
correct_map = problem.grade_answers(input_dict)
self.assertEquals(correct_map.get_hint('1_2_1'),
Expand Down
4 changes: 2 additions & 2 deletions common/lib/capa/capa/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_compare_with_tolerance(self):
self.assertTrue(result)
result = compare_with_tolerance(110.1, 100.0, '10.0', False)
self.assertFalse(result)
# Test relative tolerance (string)
# Test relative tolerance (string)
result = compare_with_tolerance(111.0, 100.0, '0.1', True)
self.assertTrue(result)
result = compare_with_tolerance(112.0, 100.0, '0.1', True)
Expand All @@ -46,7 +46,7 @@ def test_compare_with_tolerance(self):
self.assertTrue(result)
result = compare_with_tolerance(110.1, 100.0, 10.0, False)
self.assertFalse(result)
# Test relative tolerance (float)
# Test relative tolerance (float)
result = compare_with_tolerance(111.0, 100.0, 0.1, True)
self.assertTrue(result)
result = compare_with_tolerance(112.0, 100.0, 0.1, True)
Expand Down
2 changes: 1 addition & 1 deletion common/lib/sandbox-packages/verifiers/draganddrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def grade(self):
self.user_positions[index]['user'], flag=rule):
return False
if not rules_executed: # no correct rules for current group
# probably xml content mistake - wrong rules names
# probably xml content mistake - wrong rules names
return False

return True
Expand Down
Loading

0 comments on commit 36e77c7

Please sign in to comment.