Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, debug=False, **kwargs):
self.default_lexer = DjangoQLLexer()
self.tokens = self.default_lexer.tokens
kwargs['debug'] = debug
self.yacc = yacc.yacc(module=self, **kwargs)
from __future__ import unicode_literals
import re
from decimal import Decimal
import ply.yacc as yacc
from .ast import * # noqa
from .compat import binary_type, text_type
from .exceptions import DjangoQLParserError
from .lexer import DjangoQLLexer
unescape_pattern = re.compile(
'(' + DjangoQLLexer.re_escaped_char + '|' +
DjangoQLLexer.re_escaped_unicode + ')'
)
def unescape_repl(m):
contents = m.group(1)
if len(contents) == 2:
return contents[1]
else:
return contents.encode('utf8').decode('unicode_escape')
def unescape(value):
if isinstance(value, binary_type):
value = value.decode('utf8')
return re.sub(unescape_pattern, unescape_repl, value)
from __future__ import unicode_literals
import re
from decimal import Decimal
import ply.yacc as yacc
from .ast import * # noqa
from .compat import binary_type, text_type
from .exceptions import DjangoQLParserError
from .lexer import DjangoQLLexer
unescape_pattern = re.compile(
'(' + DjangoQLLexer.re_escaped_char + '|' +
DjangoQLLexer.re_escaped_unicode + ')'
)
def unescape_repl(m):
contents = m.group(1)
if len(contents) == 2:
return contents[1]
else:
return contents.encode('utf8').decode('unicode_escape')
def unescape(value):
if isinstance(value, binary_type):
value = value.decode('utf8')
return re.sub(unescape_pattern, unescape_repl, value)