Commit 7ada9569 by Sarina Canelake

Merge pull request #5918 from stvstnfrd/pep8/whitespace

Fix whitespace-related PEP8 issues
parents d02747ff bd4658e6
......@@ -3,7 +3,7 @@
# pylint: disable=C0111
from lettuce import world, step
from nose.tools import assert_true # pylint: disable=E0611
from nose.tools import assert_true # pylint: disable=E0611
from video_editor import RequestHandlerWithSessionId, success_upload_file
......
......@@ -11,8 +11,13 @@ def query_yes_no(question, default="yes"):
The "answer" return value is one of "yes" or "no".
"""
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
valid = {
"yes": True,
"y": True,
"ye": True,
"no": False,
"n": False,
}
if default is None:
prompt = " [y/n] "
elif default == "yes":
......
......@@ -151,7 +151,7 @@ def _preview_module_system(request, descriptor):
replace_urls=partial(static_replace.replace_static_urls, data_directory=None, course_id=course_id),
user=request.user,
can_execute_unsafe_code=(lambda: can_execute_unsafe_code(course_id)),
get_python_lib_zip=(lambda :get_python_lib_zip(contentstore, course_id)),
get_python_lib_zip=(lambda: get_python_lib_zip(contentstore, course_id)),
mixins=settings.XBLOCK_MIXINS,
course_id=course_id,
anonymous_student_id='student',
......
......@@ -377,7 +377,10 @@ def choose_transcripts(request):
if item.sub != html5_id: # update sub value
item.sub = html5_id
item.save_with_metadata(request.user)
response = {'status': 'Success', 'subs': item.sub}
response = {
'status': 'Success',
'subs': item.sub,
}
return JsonResponse(response)
......@@ -408,7 +411,10 @@ def replace_transcripts(request):
item.sub = youtube_id
item.save_with_metadata(request.user)
response = {'status': 'Success', 'subs': item.sub}
response = {
'status': 'Success',
'subs': item.sub,
}
return JsonResponse(response)
......
......@@ -736,7 +736,7 @@ ADVANCED_COMPONENT_TYPES = [
'done', # Lets students mark things as done. See https://github.com/pmitros/DoneXBlock
'audio', # Embed an audio file. See https://github.com/pmitros/AudioXBlock
'recommender', # Crowdsourced recommender. Prototype by dli&pmitros. Intended for roll-out in one place in one course.
'profile', # Prototype user profile XBlock. Used to test XBlock parameter passing. See https://github.com/pmitros/ProfileXBlock
'profile', # Prototype user profile XBlock. Used to test XBlock parameter passing. See https://github.com/pmitros/ProfileXBlock
'split_test',
'combinedopenended',
'peergrading',
......
......@@ -2,7 +2,7 @@
Specific overrides to the base prod settings to make development easier.
"""
from .aws import * # pylint: disable=wildcard-import, unused-wildcard-import
from .aws import * # pylint: disable=wildcard-import, unused-wildcard-import
# Don't use S3 in devstack, fall back to filesystem
del DEFAULT_FILE_STORAGE
......
......@@ -69,9 +69,9 @@ STATICFILES_DIRS += [
# If we don't add these settings, then Django templates that can't
# find pipelined assets will raise a ValueError.
# http://stackoverflow.com/questions/12816941/unit-testing-with-django-pipeline
STATICFILES_STORAGE='pipeline.storage.NonPackagingPipelineStorage'
STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage'
STATIC_URL = "/static/"
PIPELINE_ENABLED=False
PIPELINE_ENABLED = False
# Update module store settings per defaults for tests
update_module_store_settings(
......
......@@ -43,7 +43,7 @@ def platform_name():
@register.simple_tag(name="favicon_path")
def favicon_path(default=getattr(settings,'FAVICON_PATH', 'images/favicon.ico')):
def favicon_path(default=getattr(settings, 'FAVICON_PATH', 'images/favicon.ico')):
"""
Django template tag that outputs the configured favicon:
{% favicon_path %}
......
......@@ -105,7 +105,10 @@ class TestCourseListing(ModuleStoreTestCase):
course_location = SlashSeparatedCourseKey('testOrg', 'erroredCourse', 'RunBabyRun')
course = self._create_course_with_access_groups(course_location)
course_db_record = mongo_store._find_one(course.location)
course_db_record.setdefault('metadata', {}).get('tabs', []).append({"type": "wiko", "name": "Wiki" })
course_db_record.setdefault('metadata', {}).get('tabs', []).append({
"type": "wiko",
"name": "Wiki",
})
mongo_store.collection.update(
{'_id': course.location.to_deprecated_son()},
{'$set': {
......
......@@ -95,7 +95,9 @@ def initial_setup(server):
if browser_driver == 'chrome':
desired_capabilities = DesiredCapabilities.CHROME
desired_capabilities['loggingPrefs'] = { 'browser':'ALL' }
desired_capabilities['loggingPrefs'] = {
'browser': 'ALL',
}
elif browser_driver == 'firefox':
desired_capabilities = DesiredCapabilities.FIREFOX
else:
......@@ -239,7 +241,7 @@ def capture_console_log(scenario):
output_dir = '{}/log'.format(settings.TEST_ROOT)
file_name = '{}/{}.log'.format(output_dir, scenario.name.replace(' ', '_'))
with open (file_name, 'w') as output_file:
with open(file_name, 'w') as output_file:
for line in log:
output_file.write("{}{}".format(dumps(line), '\n'))
......
......@@ -123,8 +123,8 @@ class StubHttpRequestHandler(BaseHTTPRequestHandler, object):
# By default, `parse_qs` returns a list of values for each param
# For convenience, we replace lists of 1 element with just the element
return {
k:v[0] if len(v) == 1 else v
for k,v in urlparse.parse_qs(query).items()
key: value[0] if len(value) == 1 else value
for key, value in urlparse.parse_qs(query).items()
}
@lazy
......
......@@ -45,7 +45,7 @@ class StudentState(object):
@property
def num_pending(self):
return max(self.INITIAL_ESSAYS_AVAILABLE- self.num_graded, 0)
return max(self.INITIAL_ESSAYS_AVAILABLE - self.num_graded, 0)
@property
def num_required(self):
......
......@@ -25,7 +25,9 @@ class StubHttpServiceTest(unittest.TestCase):
'test_empty': '',
'test_int': 12345,
'test_float': 123.45,
'test_dict': { 'test_key': 'test_val' },
'test_dict': {
'test_key': 'test_val',
},
'test_empty_dict': {},
'test_unicode': u'\u2603 the snowman',
'test_none': None,
......
......@@ -35,7 +35,7 @@ class StubLtiServiceTest(unittest.TestCase):
'launch_presentation_return_url': '',
'lis_outcome_service_url': 'http://localhost:8001/test_callback',
'lis_result_sourcedid': '',
'resource_link_id':'',
'resource_link_id': '',
}
def test_invalid_request_url(self):
......
......@@ -214,6 +214,7 @@ class StubXQueueService(StubHttpService):
except for 'default' and 'register_submission_url' which have special meaning
"""
return {
key:val for key, val in self.config.iteritems()
key: value
for key, value in self.config.iteritems()
if key not in self.NON_QUEUE_CONFIG_KEYS
}.items()
......@@ -106,7 +106,7 @@ class TrackMiddleware(object):
for header_name, context_key in META_KEY_TO_CONTEXT_KEY.iteritems():
context[context_key] = request.META.get(header_name, '')
# Google Analytics uses the clientId to keep track of unique visitors. A GA cookie looks like
# Google Analytics uses the clientId to keep track of unique visitors. A GA cookie looks like
# this: _ga=GA1.2.1033501218.1368477899. The clientId is this part: 1033501218.1368477899.
google_analytics_cookie = request.COOKIES.get('_ga')
if google_analytics_cookie is None:
......
......@@ -21,7 +21,7 @@ random.Random = random_module.Random
sys.modules['random'] = random
"""
ASSUMED_IMPORTS=[
ASSUMED_IMPORTS = [
("numpy", "numpy"),
("math", "math"),
("scipy", "scipy"),
......
......@@ -14,7 +14,7 @@ dateformat = '%Y%m%d%H%M%S'
XQUEUE_METRIC_NAME = 'edxapp.xqueue'
# Wait time for response from Xqueue.
XQUEUE_TIMEOUT = 35 # seconds
XQUEUE_TIMEOUT = 35 # seconds
def make_hashkey(seed):
......
......@@ -21,7 +21,7 @@ or:
{ "molecule": "[100, 200]" },
]
}
values are (x,y) coordinates of centers of dragged images.
values are (x, y) coordinates of centers of dragged images.
"""
import json
......@@ -77,7 +77,7 @@ class PositionsCompare(list):
list or string::
"abc" - target
[10, 20] - list of integers
[[10,20], 200] list of list and integer
[[10, 20], 200] list of list and integer
"""
def __eq__(self, other):
......@@ -223,10 +223,10 @@ class DragAndDrop(object):
Examples:
- many draggables per position:
user ['1','2','2','2'] is 'anyof' equal to ['1', '2', '3']
user ['1', '2', '2', '2'] is 'anyof' equal to ['1', '2', '3']
- draggables can be placed in any order:
user ['1','2','3','4'] is 'anyof' equal to ['4', '2', '1', 3']
user ['1', '2', '3', '4'] is 'anyof' equal to ['4', '2', '1', 3']
'unordered_equal' is same as 'exact' but disregards on order
......@@ -235,7 +235,7 @@ class DragAndDrop(object):
Equality functon depends on type of element. They declared in
PositionsCompare class. For position like targets
ids ("t1", "t2", etc..) it is string equality function. For coordinate
positions ([1,2] or [[1,2], 15]) it is coordinate_positions_compare
positions ([1, 2] or [[1, 2], 15]) it is coordinate_positions_compare
function (see docstrings in PositionsCompare class)
Args:
......@@ -352,7 +352,7 @@ class DragAndDrop(object):
# correct_answer entries. If the draggable is mentioned in at least one
# correct_answer entry, the value is False.
# default to consider every user answer excess until proven otherwise.
self.excess_draggables = dict((users_draggable.keys()[0],True)
self.excess_draggables = dict((users_draggable.keys()[0], True)
for users_draggable in user_answer)
# Convert nested `user_answer` to flat format.
......@@ -414,8 +414,8 @@ def grade(user_input, correct_answer):
'rule': 'anyof'
},
{
'draggables': ['l1_c','l8_c'],
'targets': ['t5_c','t6_c'],
'draggables': ['l1_c', 'l8_c'],
'targets': ['t5_c', 't6_c'],
'rule': 'anyof'
}
]
......
......@@ -208,7 +208,7 @@ class CombinedOpenEndedFields(object):
"This field is only populated if the instructor changes tasks after "
"the module is created and students have attempted it (for example, if a self assessed problem is "
"changed to self and peer assessed)."),
scope = Scope.user_state
scope=Scope.user_state,
)
task_states = List(
help=_("List of state dictionaries of each task within this module."),
......
......@@ -773,7 +773,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
imsx_messageIdentifier = root.xpath("//def:imsx_messageIdentifier", namespaces=namespaces)[0].text or ''
sourcedId = root.xpath("//def:sourcedId", namespaces=namespaces)[0].text
score = root.xpath("//def:textString", namespaces=namespaces)[0].text
action = root.xpath("//def:imsx_POXBody", namespaces=namespaces)[0].getchildren()[0].tag.replace('{'+lti_spec_namespace+'}', '')
action = root.xpath("//def:imsx_POXBody", namespaces=namespaces)[0].getchildren()[0].tag.replace('{' + lti_spec_namespace + '}', '')
# Raise exception if score is not float or not in range 0.0-1.0 regarding spec.
score = float(score)
if not 0 <= score <= 1:
......
......@@ -88,7 +88,7 @@ def modulestore():
ModuleStoreNoSettings.modulestore = class_(
None, # contentstore
ModuleStoreNoSettings.MODULESTORE['DOC_STORE_CONFIG'],
branch_setting_func = lambda: ModuleStoreEnum.Branch.draft_preferred,
branch_setting_func=lambda: ModuleStoreEnum.Branch.draft_preferred,
**options
)
......
......@@ -236,7 +236,7 @@ class CombinedOpenEndedRubric(object):
rubric_categories[i]['options'][j]['grader_types'].append(grader_type)
#Grab the score and add it to the actual scores. J will be the score for the selected
#grader type
if len(actual_scores)<=i:
if len(actual_scores) <= i:
#Initialize a new list in the list of lists
actual_scores.append([j])
else:
......@@ -249,7 +249,7 @@ class CombinedOpenEndedRubric(object):
for (i, a) in enumerate(actual_scores):
if int(a) == max_scores[i]:
correct.append(1)
elif int(a)==0:
elif int(a) == 0:
correct.append(0)
else:
correct.append(.5)
......
......@@ -103,7 +103,7 @@ class PeerGradingService(GradingService):
self._record_result('get_problem_list', result)
dog_stats_api.histogram(
self._metric_name('get_problem_list.result.length'),
len(result.get('problem_list',[]))
len(result.get('problem_list', [])),
)
return result
......@@ -160,4 +160,11 @@ class MockPeerGradingService(object):
]}
def get_data_for_location(self, problem_location, student_id):
return {"version": 1, "count_graded": 3, "count_required": 3, "success": True, "student_sub_count": 1, 'submissions_available' : 0}
return {
"version": 1,
"count_graded": 3,
"count_required": 3,
"success": True,
"student_sub_count": 1,
'submissions_available': 0,
}
......@@ -198,7 +198,7 @@ class SelfAssessmentModule(openendedchild.OpenEndedChild):
'success': success,
'rubric_html': self.get_rubric_html(system),
'error': error_message,
'student_response': data['student_answer'].replace("\n","<br/>")
'student_response': data['student_answer'].replace("\n", "<br/>"),
}
def save_assessment(self, data, _system):
......
......@@ -26,7 +26,7 @@ log = logging.getLogger('edx.' + __name__)
# Make '_' a no-op so we can scrape strings
_ = lambda text: text
DEFAULT_GROUP_NAME = _(u'Group ID {group_id}')
DEFAULT_GROUP_NAME = _(u'Group ID {group_id}')
class SplitTestFields(object):
......
......@@ -89,7 +89,13 @@ def get_test_system(course_id=SlashSeparatedCourseKey('org', 'course', 'run')):
filestore=Mock(),
debug=True,
hostname="edx.org",
xqueue={'interface': None, 'callback_url': '/', 'default_queuename': 'testqueue', 'waittime': 10, 'construct_callback' : Mock(side_effect="/")},
xqueue={
'interface': None,
'callback_url': '/',
'default_queuename': 'testqueue',
'waittime': 10,
'construct_callback': Mock(side_effect="/"),
},
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
anonymous_student_id='student',
open_ended_grading_interface=open_ended_grading_interface,
......
......@@ -566,7 +566,7 @@ class VideoCdnTest(unittest.TestCase):
original_video_url = "http://www.original_video.com/original_video.mp4"
cdn_response_video_url = "http://www.cdn_video.com/cdn_video.mp4"
cdn_response_content = '{{"sources":["{cdn_url}"]}}'.format(cdn_url=cdn_response_video_url)
cdn_response.return_value=Mock(status_code=200, content=cdn_response_content)
cdn_response.return_value = Mock(status_code=200, content=cdn_response_content)
fake_cdn_url = 'http://fake_cdn.com/'
self.assertEqual(
get_video_from_cdn(fake_cdn_url, original_video_url),
......@@ -579,6 +579,6 @@ class VideoCdnTest(unittest.TestCase):
Test if no alternative video in CDN exists.
"""
original_video_url = "http://www.original_video.com/original_video.mp4"
cdn_response.return_value=Mock(status_code=404)
cdn_response.return_value = Mock(status_code=404)
fake_cdn_url = 'http://fake_cdn.com/'
self.assertIsNone(get_video_from_cdn(fake_cdn_url, original_video_url))
......@@ -132,7 +132,7 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
def get_transcripts_for_student(self):
"""Return transcript information necessary for rendering the XModule student view.
This is more or less a direct extraction from `get_html`.
This is more or less a direct extraction from `get_html`.
Returns:
Tuple of (track_url, transcript_language, sorted_languages)
......
......@@ -41,7 +41,7 @@ class AnnotationComponentPage(PageObject):
Return css selector for current active problem with sub_selector.
"""
return 'div[data-problem-id="{}"] {}'.format(
self.q(css='.vert-{}'.format(self.active_problem+1)).map(
self.q(css='.vert-{}'.format(self.active_problem + 1)).map(
lambda el: el.get_attribute('data-id')).results[0],
sub_selector,
)
......
......@@ -3,4 +3,4 @@ def seventeen():
def fortytwo(x):
return 42+x
return 42 + x
......@@ -7,5 +7,5 @@ def i_click_on_the_tab_and_check(step):
tab_text = tab_title['TabName']
title = tab_title['PageTitle']
world.click_link(tab_text)
world.wait_for(lambda _driver:title in world.browser.title)
world.wait_for(lambda _driver: title in world.browser.title)
assert(title in world.browser.title)
......@@ -62,4 +62,4 @@ def is_masquerading_as_student(user):
Return True if user is masquerading as a student, False otherwise
'''
masq = getattr(user, 'masquerade_as_student', False)
return masq==True
return masq is True
......@@ -79,7 +79,7 @@ class TestNavigation(ModuleStoreTestCase, LoginEnrollmentTestCase):
''' Check if the progress tab is active in the tab set '''
for line in response.content.split('\n'):
if tabname in line and 'active' in line:
raise AssertionError("assertTabInactive failed: "+tabname+" active")
raise AssertionError("assertTabInactive failed: " + tabname + " active")
return
def test_chrome_settings(self):
......
......@@ -45,7 +45,7 @@ class TestXss(ModuleStoreTestCase):
Build a request with the given action, call the instructor dashboard
view, and check that HTML code in a user's name is properly escaped.
"""
req = self._request_factory.post(
req = self._request_factory.post(
"dummy_url",
data={"action": action}
)
......
......@@ -67,7 +67,7 @@ class NotificationPrefViewTest(UrlResetMixin, TestCase):
request.user = self.user
response = ajax_status(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content), {"status":0})
self.assertEqual(json.loads(response.content), {"status": 0})
def test_ajax_status_get_1(self):
self.create_prefs()
......@@ -75,7 +75,7 @@ class NotificationPrefViewTest(UrlResetMixin, TestCase):
request.user = self.user
response = ajax_status(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.content), {"status":1})
self.assertEqual(json.loads(response.content), {"status": 1})
def test_ajax_status_post(self):
request = self.request_factory.post("dummy")
......
......@@ -149,7 +149,7 @@ def ajax_status(request):
key=NOTIFICATION_PREF_KEY
)
return HttpResponse(json.dumps({"status":len(qs)}), content_type="application/json")
return HttpResponse(json.dumps({"status": len(qs)}), content_type="application/json")
@require_GET
......
......@@ -321,7 +321,7 @@ def get_problem_list(request, course_id):
u'If not, please do so and return to this page.'
)
valid_problem_list = []
for i in xrange(0,len(problem_list)):
for i in xrange(0, len(problem_list)):
# Needed to ensure that the 'location' key can be accessed.
try:
problem_list[i] = json.loads(problem_list[i])
......
......@@ -288,7 +288,7 @@ def get_purchase_params(cart, callback_url=None, extra_data=None):
params['transaction_type'] = 'sale'
params['locale'] = 'en'
params['signed_date_time'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
params['signed_date_time'] = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')
params['signed_field_names'] = 'access_key,profile_id,amount,currency,transaction_type,reference_number,signed_date_time,locale,transaction_uuid,signed_field_names,unsigned_field_names,orderNumber'
params['unsigned_field_names'] = ''
params['transaction_uuid'] = uuid.uuid4().hex
......
......@@ -110,7 +110,7 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
if page is not None:
viewer_params += '&amp;page={}'.format(page)
if request.GET.get('viewer','') == 'true':
if request.GET.get('viewer', '') == 'true':
template = 'pdf_viewer.html'
else:
template = 'static_pdfbook.html'
......
......@@ -33,7 +33,7 @@ class AcceptanceTest(TestSuite):
@property
def cmd(self):
report_file = self.report_dir / "{}.xml".format(self.system)
report_file = self.report_dir / "{}.xml".format(self.system)
report_args = "--with-xunit --xunit-file {}".format(report_file)
cmd = (
......
......@@ -57,7 +57,7 @@ set -e
# Violations thresholds for failing the build
PYLINT_THRESHOLD=4725
PEP8_THRESHOLD=200
PEP8_THRESHOLD=150
source $HOME/jenkins_env
......
......@@ -119,7 +119,7 @@ class ReportMerge(object):
report_path = os.path.join(self.DESTINATION, output_file)
else:
report_filename = path.split('reports/')[1].split('/cover')[0].replace('/', '_')
report_path = os.path.join(self.DESTINATION, report_filename+'_coverage.html')
report_path = os.path.join(self.DESTINATION, report_filename + '_coverage.html')
# Write everything to single report file
with open(report_path, 'w') as report_file:
......
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