Fix strings that should be raw.
This commit is contained in:
@@ -153,9 +153,9 @@ class CourseDetails(object):
|
||||
if not raw_video:
|
||||
return None
|
||||
|
||||
keystring_matcher = re.search('(?<=embed/)[a-zA-Z0-9_-]+', raw_video)
|
||||
keystring_matcher = re.search(r'(?<=embed/)[a-zA-Z0-9_-]+', raw_video)
|
||||
if keystring_matcher is None:
|
||||
keystring_matcher = re.search('<?=\d+:[a-zA-Z0-9_-]+', raw_video)
|
||||
keystring_matcher = re.search(r'<?=\d+:[a-zA-Z0-9_-]+', raw_video)
|
||||
|
||||
if keystring_matcher:
|
||||
return keystring_matcher.group(0)
|
||||
|
||||
@@ -26,7 +26,7 @@ class Command(BaseCommand):
|
||||
raise CommandError('Usage is set_staff {0}'.format(self.args))
|
||||
|
||||
for user in args:
|
||||
if re.match('[^@]+@[^@]+\.[^@]+', user):
|
||||
if re.match(r'[^@]+@[^@]+\.[^@]+', user):
|
||||
try:
|
||||
v = User.objects.get(email=user)
|
||||
except:
|
||||
|
||||
@@ -3,6 +3,7 @@ import feedparser
|
||||
import json
|
||||
import logging
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import urllib
|
||||
import uuid
|
||||
@@ -95,9 +96,8 @@ def course_from_id(course_id):
|
||||
course_loc = CourseDescriptor.id_to_location(course_id)
|
||||
return modulestore().get_instance(course_id, course_loc)
|
||||
|
||||
import re
|
||||
day_pattern = re.compile('\s\d+,\s')
|
||||
multimonth_pattern = re.compile('\s?\-\s?\S+\s')
|
||||
day_pattern = re.compile(r'\s\d+,\s')
|
||||
multimonth_pattern = re.compile(r'\s?\-\s?\S+\s')
|
||||
|
||||
|
||||
def get_date_for_press(publish_date):
|
||||
|
||||
@@ -21,7 +21,7 @@ from logging import getLogger
|
||||
logger = getLogger(__name__)
|
||||
|
||||
|
||||
@step(u'I wait (?:for )?"(\d+)" seconds?$')
|
||||
@step(r'I wait (?:for )?"(\d+)" seconds?$')
|
||||
def wait(step, seconds):
|
||||
world.wait(seconds)
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ class LoncapaProblem(object):
|
||||
self.input_state = state.get('input_state', {})
|
||||
|
||||
# Convert startouttext and endouttext to proper <text></text>
|
||||
problem_text = re.sub("startouttext\s*/", "text", problem_text)
|
||||
problem_text = re.sub("endouttext\s*/", "/text", problem_text)
|
||||
problem_text = re.sub(r"startouttext\s*/", "text", problem_text)
|
||||
problem_text = re.sub(r"endouttext\s*/", "/text", problem_text)
|
||||
self.problem_text = problem_text
|
||||
|
||||
# parse problem XML file into an element tree
|
||||
|
||||
@@ -26,7 +26,7 @@ class MathRenderer(object):
|
||||
tags = ['math']
|
||||
|
||||
def __init__(self, system, xml):
|
||||
'''
|
||||
r'''
|
||||
Render math using latex-like formatting.
|
||||
|
||||
Examples:
|
||||
@@ -41,7 +41,7 @@ class MathRenderer(object):
|
||||
self.system = system
|
||||
self.xml = xml
|
||||
|
||||
mathstr = re.sub('\$(.*)\$', r'[mathjaxinline]\1[/mathjaxinline]', xml.text)
|
||||
mathstr = re.sub(r'\$(.*)\$', r'[mathjaxinline]\1[/mathjaxinline]', xml.text)
|
||||
mtag = 'mathjax'
|
||||
if not r'\displaystyle' in mathstr:
|
||||
mtag += 'inline'
|
||||
|
||||
@@ -856,7 +856,7 @@ class ImageInput(InputTypeBase):
|
||||
"""
|
||||
if value is of the form [x,y] then parse it and send along coordinates of previous answer
|
||||
"""
|
||||
m = re.match('\[([0-9]+),([0-9]+)]',
|
||||
m = re.match(r'\[([0-9]+),([0-9]+)]',
|
||||
self.value.strip().replace(' ', ''))
|
||||
if m:
|
||||
# Note: we subtract 15 to compensate for the size of the dot on the screen.
|
||||
|
||||
@@ -1902,8 +1902,7 @@ class ImageResponse(LoncapaResponse):
|
||||
if not given: # No answer to parse. Mark as incorrect and move on
|
||||
continue
|
||||
# parse given answer
|
||||
m = re.match(
|
||||
'\[([0-9]+),([0-9]+)]', given.strip().replace(' ', ''))
|
||||
m = re.match(r'\[([0-9]+),([0-9]+)]', given.strip().replace(' ', ''))
|
||||
if not m:
|
||||
raise Exception('[capamodule.capa.responsetypes.imageinput] '
|
||||
'error grading %s (input=%s)' % (aid, given))
|
||||
@@ -1918,7 +1917,7 @@ class ImageResponse(LoncapaResponse):
|
||||
# parse expected answer
|
||||
# TODO: Compile regexp on file load
|
||||
m = re.match(
|
||||
'[\(\[]([0-9]+),([0-9]+)[\)\]]-[\(\[]([0-9]+),([0-9]+)[\)\]]',
|
||||
r'[\(\[]([0-9]+),([0-9]+)[\)\]]-[\(\[]([0-9]+),([0-9]+)[\)\]]',
|
||||
solution_rectangle.strip().replace(' ', ''))
|
||||
if not m:
|
||||
msg = 'Error in problem specification! cannot parse rectangle in %s' % (
|
||||
|
||||
@@ -50,7 +50,7 @@ class dot(sympy.operations.LatticeOp): # my dot product
|
||||
|
||||
|
||||
def _print_dot(self, expr):
|
||||
return '{((%s) \cdot (%s))}' % (expr.args[0], expr.args[1])
|
||||
return r'{((%s) \cdot (%s))}' % (expr.args[0], expr.args[1])
|
||||
|
||||
LatexPrinter._print_dot = _print_dot
|
||||
|
||||
@@ -202,7 +202,7 @@ class formula(object):
|
||||
return xml
|
||||
|
||||
def preprocess_pmathml(self, xml):
|
||||
'''
|
||||
r'''
|
||||
Pre-process presentation MathML from ASCIIMathML to make it more
|
||||
acceptable for SnuggleTeX, and also to accomodate some sympy
|
||||
conventions (eg hat(i) for \hat{i}).
|
||||
|
||||
@@ -38,7 +38,7 @@ log = logging.getLogger(__name__)
|
||||
# into the cms from xml
|
||||
def clean_out_mako_templating(xml_string):
|
||||
xml_string = xml_string.replace('%include', 'include')
|
||||
xml_string = re.sub("(?m)^\s*%.*$", '', xml_string)
|
||||
xml_string = re.sub(r"(?m)^\s*%.*$", '', xml_string)
|
||||
return xml_string
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ def test_stringify():
|
||||
|
||||
|
||||
def test_stringify_again():
|
||||
html = """<html name="Voltage Source Answer" >A voltage source is non-linear!
|
||||
html = r"""<html name="Voltage Source Answer" >A voltage source is non-linear!
|
||||
<div align="center">
|
||||
<img src="/static/images/circuits/voltage-source.png"/>
|
||||
\(V=V_C\)
|
||||
|
||||
@@ -49,7 +49,7 @@ def course_wiki_redirect(request, course_id):
|
||||
if not course_slug:
|
||||
log.exception("This course is improperly configured. The slug cannot be empty.")
|
||||
valid_slug = False
|
||||
if re.match('^[-\w\.]+$', course_slug) is None:
|
||||
if re.match(r'^[-\w\.]+$', course_slug) is None:
|
||||
log.exception("This course is improperly configured. The slug can only contain letters, numbers, periods or hyphens.")
|
||||
valid_slug = False
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ def foldit_ops(request):
|
||||
# To allow for fixes without breaking this, the regex should only
|
||||
# match unquoted strings,
|
||||
a = re.compile(r':([a-zA-Z]*),')
|
||||
puzzle_scores_json = re.sub(a, ':"\g<1>",', puzzle_scores_json)
|
||||
puzzle_scores_json = re.sub(a, r':"\g<1>",', puzzle_scores_json)
|
||||
puzzle_scores = json.loads(puzzle_scores_json)
|
||||
responses.append(save_scores(request.user, puzzle_scores))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user