Exemple #1
0
from pypy.rlib.rsre.rsre_char import MAGIC, CODESIZE, getlower, set_unicode_db


@unwrap_spec(char_ord=int, flags=int)
def w_getlower(space, char_ord, flags):
    return space.wrap(getlower(char_ord, flags))


def w_getcodesize(space):
    return space.wrap(CODESIZE)


# use the same version of unicodedb as the standard objspace
import pypy.objspace.std.unicodeobject

set_unicode_db(pypy.objspace.std.unicodeobject.unicodedb)

# ____________________________________________________________
#
# Additional methods on the classes XxxMatchContext


class __extend__(rsre_core.AbstractMatchContext):
    __metaclass__ = extendabletype

    def _w_slice(self, space, start, end):
        raise NotImplementedError

    def _w_string(self, space):
        raise NotImplementedError
Exemple #2
0
"""
Testing code.  This is not used in a PyPy translation.
It exports the same interface as the Python 're' module.
"""
import re, sys
from pypy.rlib.rsre import rsre_core, rsre_char
from pypy.rlib.rsre.test.test_match import get_code as _get_code
from pypy.module.unicodedata import unicodedb
rsre_char.set_unicode_db(unicodedb)


I = IGNORECASE = re.I   # ignore case
L = LOCALE     = re.L   # assume current 8-bit locale
U = UNICODE    = re.U   # assume unicode locale
M = MULTILINE  = re.M   # make anchors look for newline
S = DOTALL     = re.S   # make dot match newline
X = VERBOSE    = re.X   # ignore whitespace and comments


def match(pattern, string, flags=0):
    return compile(pattern, flags).match(string)

def search(pattern, string, flags=0):
    return compile(pattern, flags).search(string)

def findall(pattern, string, flags=0):
    return compile(pattern, flags).findall(string)

def finditer(pattern, string, flags=0):
    return compile(pattern, flags).finditer(string)
Exemple #3
0
#
# Constants and exposed functions

from pypy.rlib.rsre import rsre_core
from pypy.rlib.rsre.rsre_char import MAGIC, CODESIZE, getlower, set_unicode_db

@unwrap_spec(char_ord=int, flags=int)
def w_getlower(space, char_ord, flags):
    return space.wrap(getlower(char_ord, flags))

def w_getcodesize(space):
    return space.wrap(CODESIZE)

# use the same version of unicodedb as the standard objspace
import pypy.objspace.std.unicodeobject
set_unicode_db(pypy.objspace.std.unicodeobject.unicodedb)

# ____________________________________________________________
#
# Additional methods on the classes XxxMatchContext

class __extend__(rsre_core.AbstractMatchContext):
    __metaclass__ = extendabletype
    def _w_slice(self, space, start, end):
        raise NotImplementedError
    def _w_string(self, space):
        raise NotImplementedError

class __extend__(rsre_core.StrMatchContext):
    __metaclass__ = extendabletype
    def _w_slice(self, space, start, end):
Exemple #4
0
"""
Testing code.  This is not used in a PyPy translation.
It exports the same interface as the Python 're' module.
"""
import re, sys
from pypy.rlib.rsre import rsre_core, rsre_char
from pypy.rlib.rsre.test.test_match import get_code as _get_code
from pypy.module.unicodedata import unicodedb
rsre_char.set_unicode_db(unicodedb)

I = IGNORECASE = re.I  # ignore case
L = LOCALE = re.L  # assume current 8-bit locale
U = UNICODE = re.U  # assume unicode locale
M = MULTILINE = re.M  # make anchors look for newline
S = DOTALL = re.S  # make dot match newline
X = VERBOSE = re.X  # ignore whitespace and comments


def match(pattern, string, flags=0):
    return compile(pattern, flags).match(string)


def search(pattern, string, flags=0):
    return compile(pattern, flags).search(string)


def findall(pattern, string, flags=0):
    return compile(pattern, flags).findall(string)


def finditer(pattern, string, flags=0):
Exemple #5
0
def setup_module(mod):
    from pypy.module.unicodedata import unicodedb
    rsre_char.set_unicode_db(unicodedb)
Exemple #6
0
def setup_module(mod):
    from pypy.module.unicodedata import unicodedb
    rsre_char.set_unicode_db(unicodedb)