${_("Classes Start")}
- % if isinstance(course_start_date, string_types): + % if isinstance(course_start_date, str): ${course_start_date} % else: <% @@ -191,7 +188,7 @@ from six import string_types${_("Classes End")}
- % if isinstance(course_end_date, string_types): + % if isinstance(course_end_date, str): ${course_end_date} % else: <% @@ -217,7 +214,7 @@ from six import string_types %endif % if pre_requisite_courses: - <% prc_target = reverse('about_course', args=[text_type(pre_requisite_courses[0]['key'])]) %> + <% prc_target = reverse('about_course', args=[str(pre_requisite_courses[0]['key'])]) %>${_("Prerequisites")}
diff --git a/lms/templates/courseware/course_about_sidebar_header.html b/lms/templates/courseware/course_about_sidebar_header.html index c15ae42e7d..b511fe7ce6 100644 --- a/lms/templates/courseware/course_about_sidebar_header.html +++ b/lms/templates/courseware/course_about_sidebar_header.html @@ -6,7 +6,6 @@ import six from django.utils.translation import ugettext as _ from django.urls import reverse from django.conf import settings -from six import text_type %>-
% if can_unenroll:
-
- <% course_refund_url = reverse('course_run_refund_status', args=[six.text_type(course_overview.id)]) %>
+ <% course_refund_url = reverse('course_run_refund_status', args=[str(course_overview.id)]) %>
+ <% prc_target = reverse('about_course', args=[str(course_requirements['courses'][0]['key'])]) %>
${Text(_("You must successfully complete {link_start}{prc_display}{link_end} before you begin this course.")).format( diff --git a/lms/templates/dashboard/_dashboard_entitlement_actions.html b/lms/templates/dashboard/_dashboard_entitlement_actions.html index 767d516541..280f1431b5 100644 --- a/lms/templates/dashboard/_dashboard_entitlement_actions.html +++ b/lms/templates/dashboard/_dashboard_entitlement_actions.html @@ -1,7 +1,6 @@ <%page args="course_overview, entitlement, dashboard_index, can_refund_entitlement, show_email_settings" expression_filter="h"/> <%! -import six from django.utils.translation import gettext as _ from django.urls import reverse %> @@ -39,7 +38,7 @@ dropdown_btn_id = "entitlement-actions-dropdown-btn-{}".format(dashboard_index) data-dropdown-button-selector="#${dropdown_btn_id}" data-course-name="${course_overview.display_name_with_default}" data-course-number="${course_overview.number}" - data-entitlement-api-endpoint="${reverse('entitlements_api:v1:enrollments', args=[six.text_type(entitlement.uuid)]) + '?is_refund=true'}"> + data-entitlement-api-endpoint="${reverse('entitlements_api:v1:enrollments', args=[str(entitlement.uuid)]) + '?is_refund=true'}"> ${_('Unenroll')} @@ -54,7 +53,7 @@ dropdown_btn_id = "entitlement-actions-dropdown-btn-{}".format(dashboard_index) data-course-id="${course_overview.id}" data-course-number="${course_overview.number}" data-dashboard-index="${dashboard_index}" - data-optout="${six.text_type(course_overview.id) in course_optouts}">${_('Email Settings')} + data-optout="${str(course_overview.id) in course_optouts}">${_('Email Settings')} % endif diff --git a/lms/templates/header/navbar-not-authenticated.html b/lms/templates/header/navbar-not-authenticated.html index 47aa9abd2c..c1e7200ed5 100644 --- a/lms/templates/header/navbar-not-authenticated.html +++ b/lms/templates/header/navbar-not-authenticated.html @@ -9,7 +9,6 @@ from django.conf import settings from django.urls import reverse from django.utils.translation import gettext as _ -from six import text_type from openedx.core.djangoapps.user_authn.toggles import should_redirect_to_authn_microfrontend %> diff --git a/lms/templates/main.html b/lms/templates/main.html index a723e1835f..1cbd04c1fa 100644 --- a/lms/templates/main.html +++ b/lms/templates/main.html @@ -14,7 +14,6 @@ <%namespace name='static' file='static_content.html'/> <% online_help_token = self.online_help_token() if hasattr(self, 'online_help_token') else None %> <%! -import six from lms.djangoapps.branding import api as branding_api from django.urls import reverse from django.utils.http import urlquote_plus @@ -93,7 +92,7 @@ from common.djangoapps.pipeline_mako import render_require_js_path_overrides <% rtl_css_file = self.attr.main_css.replace('.css', '-rtl.css') %> - + % else: % endif diff --git a/lms/templates/navigation/navbar-not-authenticated.html b/lms/templates/navigation/navbar-not-authenticated.html index a82a24e878..5a82a76ef0 100644 --- a/lms/templates/navigation/navbar-not-authenticated.html +++ b/lms/templates/navigation/navbar-not-authenticated.html @@ -7,7 +7,6 @@ <%! from django.urls import reverse from django.utils.translation import ugettext as _ -from six import text_type %>
-
diff --git a/lms/templates/public_video_share_embed.html b/lms/templates/public_video_share_embed.html
index 5246ef92a8..1da4c2da49 100644
--- a/lms/templates/public_video_share_embed.html
+++ b/lms/templates/public_video_share_embed.html
@@ -5,7 +5,6 @@
<%namespace name='static' file='static_content.html'/>
<%!
-import six
from lms.djangoapps.branding import api as branding_api
from django.utils.translation import gettext as _
from django.utils.translation import get_language_bidi
@@ -45,7 +44,7 @@ from openedx.core.djangolib.markup import HTML
<%
rtl_css_file = self.attr.main_css.replace('.css', '-rtl.css')
%>
-
+
% else:
% endif
diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html
index 849032b15b..a8ada96817 100644
--- a/lms/templates/staff_problem_info.html
+++ b/lms/templates/staff_problem_info.html
@@ -4,7 +4,6 @@
from django.utils.translation import gettext as _
from openedx.core.djangolib.markup import HTML
from openedx.core.djangolib.js_utils import js_escaped_string
-from six import text_type
%>
## The JS for this is defined in xqa_interface.html
@@ -100,7 +99,7 @@ ${block_content | n, decode.utf8}
- ${six.text_type(url["name"])}: ${six.text_type(url["description"])} +
- ${str(url["name"])}: ${str(url["description"])} % endfor
is_released = ${is_released} - location = ${text_type(location)} + location = ${str(location)} diff --git a/lms/templates/support/index.html b/lms/templates/support/index.html index 8435ab4f70..eeedea60ca 100644 --- a/lms/templates/support/index.html +++ b/lms/templates/support/index.html @@ -1,7 +1,6 @@ ## mako <%page expression_filter="h"/> <%! -import six from django.urls import reverse from django.utils.translation import gettext as _ %> @@ -18,7 +17,7 @@ ${_("Student Support")}${_('Module Fields')} ${_("Student Support")}
-
% for url in urls:
-
diff --git a/xmodule/capa/capa_problem.py b/xmodule/capa/capa_problem.py index d8b9b85c7b..072df22dbc 100644 --- a/xmodule/capa/capa_problem.py +++ b/xmodule/capa/capa_problem.py @@ -22,7 +22,6 @@ from copy import deepcopy from datetime import datetime from xml.sax.saxutils import unescape -import six from django.conf import settings from lxml import etree @@ -181,7 +180,7 @@ class LoncapaProblem(object): self.problem_text = problem_text # parse problem XML file into an element tree - if isinstance(problem_text, six.text_type): + if isinstance(problem_text, str): # etree chokes on Unicode XML with an encoding declaration problem_text = problem_text.encode('utf-8') self.tree = etree.XML(problem_text) @@ -658,7 +657,7 @@ class LoncapaProblem(object): self.find_answer_text(answer_id, answer) for answer in current_answer ) - elif isinstance(current_answer, six.string_types) and current_answer.startswith('choice_'): + elif isinstance(current_answer, str) and current_answer.startswith('choice_'): # Many problem (e.g. checkbox) report "choice_0" "choice_1" etc. # Here we transform it elems = self.tree.xpath('//*[@id="{answer_id}"]//*[@name="{choice_number}"]'.format( @@ -677,7 +676,7 @@ class LoncapaProblem(object): log.warning("Multiple answers found for answer id: %s and choice number: %s", answer_id, current_answer) answer_text = "Multiple answers found" - elif isinstance(current_answer, six.string_types): + elif isinstance(current_answer, str): # Already a string with the answer answer_text = current_answer @@ -808,7 +807,7 @@ class LoncapaProblem(object): """ includes = self.tree.findall('.//include') for inc in includes: - filename = inc.get('file') if six.PY3 else inc.get('file').decode('utf-8') + filename = inc.get('file') if filename is not None: try: # open using LoncapaSystem OSFS filesystem @@ -961,7 +960,7 @@ class LoncapaProblem(object): Used by get_html. """ - if not isinstance(problemtree.tag, six.string_types): + if not isinstance(problemtree.tag, str): # Comment and ProcessingInstruction nodes are not Elements, # and we're ok leaving those behind. # BTW: etree gives us no good way to distinguish these things diff --git a/xmodule/capa/inputtypes.py b/xmodule/capa/inputtypes.py index c3f67bc0b0..5decad4a2c 100644 --- a/xmodule/capa/inputtypes.py +++ b/xmodule/capa/inputtypes.py @@ -55,7 +55,6 @@ from calc.preview import latex_preview from chem import chemcalc from lxml import etree -from six import text_type from xmodule.capa.xqueue_interface import XQUEUE_TIMEOUT from openedx.core.djangolib.markup import HTML, Text @@ -85,7 +84,7 @@ class Status(object): } __slots__ = ('classname', '_status', 'display_name', 'display_tooltip') - def __init__(self, status, gettext_func=six.text_type): + def __init__(self, status, gettext_func=str): self.classname = self.css_classes.get(status, status) _ = gettext_func names = { @@ -110,7 +109,7 @@ class Status(object): ['incomplete', 'unanswered', 'unsubmitted'], _('Not yet answered.') ) ) - self.display_name = names.get(status, six.text_type(status)) + self.display_name = names.get(status, str(status)) self.display_tooltip = tooltips.get(status, '') self._status = status or '' @@ -255,7 +254,7 @@ class InputTypeBase(object): except Exception as err: # lint-amnesty, pylint: disable=broad-except # Something went wrong: add xml to message, but keep the traceback msg = "Error in xml '{x}': {err} ".format( - x=etree.tostring(xml), err=text_type(err)) + x=etree.tostring(xml), err=str(err)) six.reraise(Exception, Exception(msg), sys.exc_info()[2]) @classmethod @@ -427,10 +426,7 @@ class OptionInput(InputTypeBase): options = re.sub(r"([a-zA-Z])('|\\')([a-zA-Z])", r"\1'\3", options) options = re.sub(r"\\'", r"'", options) # replace already escaped single quotes # parse the set of possible options - if six.PY3: - lexer = shlex.shlex(options[1:-1]) - else: - lexer = shlex.shlex(options[1:-1].encode('utf-8')) + lexer = shlex.shlex(options[1:-1]) lexer.quotes = "'" # Allow options to be separated by whitespace as well as commas @@ -438,10 +434,7 @@ class OptionInput(InputTypeBase): # remove quotes # convert escaped single quotes (html encoded string) back to single quotes - if six.PY3: - tokens = [x[1:-1].replace("'", "'") for x in lexer] - else: - tokens = [x[1:-1].decode('utf-8').replace("'", "'") for x in lexer] + tokens = [x[1:-1].replace("'", "'") for x in lexer] # make list of (option_id, option_description), with description=id return [(t, t) for t in tokens] @@ -564,7 +557,7 @@ class ChoiceGroup(InputTypeBase): return choices def get_user_visible_answer(self, internal_answer): - if isinstance(internal_answer, six.string_types): + if isinstance(internal_answer, str): return self._choices_map[internal_answer] return [self._choices_map[i] for i in internal_answer] @@ -1571,7 +1564,7 @@ class AnnotationInput(InputTypeBase): d = {} comment_value = d.get('comment', '') - if not isinstance(comment_value, six.string_types): + if not isinstance(comment_value, str): comment_value = '' options_value = d.get('options', []) diff --git a/xmodule/capa/responsetypes.py b/xmodule/capa/responsetypes.py index 4be0eea1b5..73378e7c0a 100644 --- a/xmodule/capa/responsetypes.py +++ b/xmodule/capa/responsetypes.py @@ -33,7 +33,6 @@ from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful S from pyparsing import ParseException from pytz import UTC from shapely.geometry import MultiPoint, Point -from six import text_type from six.moves import map, range, zip import xmodule.capa.safe_exec as safe_exec @@ -177,14 +176,14 @@ class LoncapaResponse(six.with_metaclass(abc.ABCMeta, object)): for abox in inputfields: if abox.tag not in self.allowed_inputfields: msg = "%s: cannot have input field %s" % ( - six.text_type(self), abox.tag) + str(self), abox.tag) msg += "\nSee XML source line %s" % getattr( xml, 'sourceline', '[unavailable]') raise LoncapaProblemError(msg) if self.max_inputfields and len(inputfields) > self.max_inputfields: msg = "%s: cannot have more than %s input fields" % ( - six.text_type(self), self.max_inputfields) + str(self), self.max_inputfields) msg += "\nSee XML source line %s" % getattr( xml, 'sourceline', '[unavailable]') raise LoncapaProblemError(msg) @@ -192,7 +191,7 @@ class LoncapaResponse(six.with_metaclass(abc.ABCMeta, object)): for prop in self.required_attributes: if not xml.get(prop): msg = "Error in problem specification: %s missing required attribute %s" % ( - six.text_type(self), prop) + str(self), prop) msg += "\nSee XML source line %s" % getattr( xml, 'sourceline', '[unavailable]') raise LoncapaProblemError(msg) @@ -365,7 +364,7 @@ class LoncapaResponse(six.with_metaclass(abc.ABCMeta, object)): # This is the "feedback hint" event event_info = {} - event_info['module_id'] = text_type(self.capa_block.location) + event_info['module_id'] = str(self.capa_block.location) event_info['problem_part_id'] = self.id event_info['trigger_type'] = 'single' # maybe be overwritten by log_extra event_info['hint_label'] = label @@ -1458,7 +1457,7 @@ class OptionResponse(LoncapaResponse): for key, val in six.iteritems(self.context): # convert val into unicode because student answer always be a unicode string # even it is a list, dict etc. - if six.text_type(val) == student_answers[aid]: + if str(val) == student_answers[aid]: return '$' + key return None @@ -1606,10 +1605,10 @@ class NumericalResponse(LoncapaResponse): err.args[0] ) except ValueError as val_err: - if 'factorial' in text_type(val_err): # lint-amnesty, pylint: disable=no-else-raise + if 'factorial' in str(val_err): # lint-amnesty, pylint: disable=no-else-raise # This is thrown when fact() or factorial() is used in an answer # that evaluates on negative and/or non-integer inputs - # text_type(ve) will be: `factorial() only accepts integral values` or + # str(ve) will be: `factorial() only accepts integral values` or # `factorial() not defined for negative values` raise StudentInputError( # lint-amnesty, pylint: disable=raise-missing-from _("Factorial function evaluated outside its domain:" @@ -2039,7 +2038,7 @@ class StringResponse(LoncapaResponse): except Exception as err: msg = '[courseware.capa.responsetypes.stringresponse] {error}: {message}'.format( error=_('error'), - message=text_type(err) + message=str(err) ) log.error(msg, exc_info=True) raise ResponseError(msg) # lint-amnesty, pylint: disable=raise-missing-from @@ -2170,7 +2169,7 @@ class CustomResponse(LoncapaResponse): """ _ = self.capa_system.i18n.gettext - log.debug('%s: student_answers=%s', six.text_type(self), student_answers) + log.debug('%s: student_answers=%s', str(self), student_answers) # ordered list of answer id's # sort the responses on the bases of the problem's position number @@ -2284,7 +2283,7 @@ class CustomResponse(LoncapaResponse): def execute_check_function(self, idset, submission): # lint-amnesty, pylint: disable=missing-function-docstring, too-many-statements # exec the check function - if isinstance(self.code, six.string_types): # lint-amnesty, pylint: disable=too-many-nested-blocks + if isinstance(self.code, str): # lint-amnesty, pylint: disable=too-many-nested-blocks try: safe_exec.safe_exec( self.code, @@ -2512,7 +2511,7 @@ class CustomResponse(LoncapaResponse): # Notify student with a student input error _, _, traceback_obj = sys.exc_info() - raise ResponseError(text_type(err), traceback_obj) + raise ResponseError(str(err), traceback_obj) #----------------------------------------------------------------------------- @@ -2897,7 +2896,7 @@ class ExternalResponse(LoncapaResponse): # nodiff --git a/openedx/core/djangoapps/credit/signature.py b/openedx/core/djangoapps/credit/signature.py index a631e078a7..b95d9ffbfc 100644 --- a/openedx/core/djangoapps/credit/signature.py +++ b/openedx/core/djangoapps/credit/signature.py @@ -28,7 +28,7 @@ log = logging.getLogger(__name__) def _encode_secret(secret, provider_id): """ - Helper function for encoding text_type secrets into ascii. + Helper function for encoding string secrets into ascii. """ try: secret.encode('ascii') diff --git a/themes/stanford-style/lms/templates/register-form.html b/themes/stanford-style/lms/templates/register-form.html index ce3234f5fb..16228ad8ed 100644 --- a/themes/stanford-style/lms/templates/register-form.html +++ b/themes/stanford-style/lms/templates/register-form.html @@ -1,7 +1,6 @@ ## xss-lint: disable=mako-missing-default <%! from common.djangoapps import third_party_auth -import six from common.djangoapps.third_party_auth import pipeline, provider from django.utils.translation import ugettext as _ from django_countries import countries @@ -169,7 +168,7 @@ from common.djangoapps.student.models import UserProfile
stanza; get code from