Commit 72a19913 authored by Andrey Golovizin's avatar Andrey Golovizin

Get rid of ur'' strings

parent 0277d4f7
......@@ -73,13 +73,13 @@ class Backend(BaseBackend):
return escape(text)
def format_protected(self, text):
return ur'<span class="bibtex-protected">{}</span>'.format(text)
return r'<span class="bibtex-protected">{}</span>'.format(text)
def format_tag(self, tag, text):
return ur'<{0}>{1}</{0}>'.format(tag, text) if text else u''
return r'<{0}>{1}</{0}>'.format(tag, text) if text else u''
def format_href(self, url, text):
return ur'<a href="{0}">{1}</a>'.format(url, text) if text else u''
return r'<a href="{0}">{1}</a>'.format(url, text) if text else u''
def write_prologue(self):
encoding = self.encoding or pybtex.io.get_default_encoding()
......
......@@ -73,7 +73,7 @@ class Backend(BaseBackend):
if tag is None:
return u'{%s}' % text if text else u''
else:
return ur'\%s{%s}' % (tag, text) if text else u''
return r'\%s{%s}' % (tag, text) if text else u''
def format_href(self, url, text):
if not text:
......@@ -81,7 +81,7 @@ class Backend(BaseBackend):
elif text == self.format_str(url):
return u'\\url{%s}' % url
else:
return ur'\href{%s}{%s}' % (url, text) if text else u''
return r'\href{%s}{%s}' % (url, text) if text else u''
def format_protected(self, text):
"""
......
......@@ -110,10 +110,10 @@ class Backend(BaseBackend):
if tag is None:
return text
else:
return ur'{0}{1}{0}'.format(tag, text) if text else u''
return r'{0}{1}{0}'.format(tag, text) if text else u''
def format_href(self, url, text):
return ur'[%s](%s)' % (text, url) if text else u''
return r'[%s](%s)' % (text, url) if text else u''
def write_entry(self, key, label, text):
# Support http://www.michelf.com/projects/php-markdown/extra/#def-list
......
......@@ -45,7 +45,7 @@ def process_function(toks):
return FunctionLiteral(toks[0])
quote_or_comment = re.compile(ur'[%"]')
quote_or_comment = re.compile(r'[%"]')
def strip_comment(line):
"""Strip the commented part of the line."
......@@ -87,11 +87,11 @@ from pybtex.scanner import (
class BstParser(Scanner):
LBRACE = Literal(u'{')
RBRACE = Literal(u'}')
STRING = Pattern(ur'"[^\"]*"', 'string')
INTEGER = Pattern(ur'#-?\d+', 'integer')
NAME = Pattern(ur'[^#\"\{\}\s]+', 'name')
LBRACE = Literal('{')
RBRACE = Literal('}')
STRING = Pattern('"[^\"]*"', 'string')
INTEGER = Pattern(r'#-?\d+', 'integer')
NAME = Pattern(r'[^#\"\{\}\s]+', 'name')
COMMANDS = {
'ENTRY': 3,
......
......@@ -287,9 +287,9 @@ class UnbalancedBraceError(PybtexSyntaxError):
class NameFormatParser(Scanner):
LBRACE = Literal(u'{')
RBRACE = Literal(u'}')
TEXT = Pattern(ur'[^{}]+', 'text')
NON_LETTERS = Pattern(ur'[^{}\w]|\d+', 'non-letter characters', flags=re.IGNORECASE | re.UNICODE)
FORMAT_CHARS = Pattern(ur'[^\W\d_]+', 'format chars', flags=re.IGNORECASE | re.UNICODE)
TEXT = Pattern(r'[^{}]+', 'text')
NON_LETTERS = Pattern(r'[^{}\w]|\d+', 'non-letter characters', flags=re.IGNORECASE | re.UNICODE)
FORMAT_CHARS = Pattern(r'[^\W\d_]+', 'format chars', flags=re.IGNORECASE | re.UNICODE)
lineno = None
......
......@@ -111,10 +111,10 @@ class UndefinedMacro(PybtexSyntaxError):
class LowLevelParser(Scanner):
NAME = Pattern(ur'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)), 'a valid name')
KEY_PAREN = Pattern(ur'[^\s\,]+', 'entry key')
KEY_BRACE = Pattern(ur'[^\s\,}]+', 'entry key')
NUMBER = Pattern(ur'[{0}]+'.format(digits), 'a number')
NAME = Pattern(r'[{0}][{1}]*'.format(re.escape(NAME_CHARS), re.escape(NAME_CHARS + digits)), 'a valid name')
KEY_PAREN = Pattern(r'[^\s\,]+', 'entry key')
KEY_BRACE = Pattern(r'[^\s\,}]+', 'entry key')
NUMBER = Pattern(r'[{0}]+'.format(digits), 'a number')
LBRACE = Literal(u'{')
RBRACE = Literal(u'}')
LPAREN = Literal(u'(')
......
......@@ -57,8 +57,8 @@ class Scanner(object):
text = None
lineno = 1
pos = 0
WHITESPACE = Pattern(ur'\s+', 'whitespace')
NEWLINE = Pattern(ur'\n|(\r\n)|\r', 'newline')
WHITESPACE = Pattern(r'\s+', 'whitespace')
NEWLINE = Pattern(r'\n|(\r\n)|\r', 'newline')
def __init__(self, text, filename=None):
self.text = text
......
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