Python re._compile() Examples

The following are code examples for showing how to use re._compile(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: oil   Author: oilshell   File: test_re.py    (license) View Source Project 5 votes vote down vote up
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile 
Example 2
Project: python2-tracer   Author: extremecoders-re   File: test_re.py    (license) View Source Project 5 votes vote down vote up
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile 
Example 3
Project: lang2program   Author: kelvinguu   File: profile_imports.py    (license) View Source Project 5 votes vote down vote up
def install():
    """Install the hooks for measuring import and regex compile time."""
    __builtins__['__import__'] = timed_import
    re._compile = timed_compile 
Example 4
Project: lang2program   Author: kelvinguu   File: profile_imports.py    (license) View Source Project 5 votes vote down vote up
def uninstall():
    """Remove the import and regex compile timing hooks."""
    __builtins__['__import__'] = _real_import
    re._compile = _real_compile 
Example 5
Project: lang2program   Author: kelvinguu   File: profile_imports.py    (license) View Source Project 5 votes vote down vote up
def install():
    """Install the hooks for measuring import and regex compile time."""
    __builtins__['__import__'] = timed_import
    re._compile = timed_compile 
Example 6
Project: lang2program   Author: kelvinguu   File: profile_imports.py    (license) View Source Project 5 votes vote down vote up
def uninstall():
    """Remove the import and regex compile timing hooks."""
    __builtins__['__import__'] = _real_import
    re._compile = _real_compile 
Example 7
Project: pefile.pypy   Author: cloudtracer   File: test_re.py    (license) View Source Project 5 votes vote down vote up
def test_pickling(self):
        import pickle
        self.pickle_test(pickle)
        import cPickle
        self.pickle_test(cPickle)
        # old pickles expect the _compile() reconstructor in sre module
        import_module("sre", deprecated=True)
        from sre import _compile
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile 
Example 8
Project: ouroboros   Author: pybee   File: test_re.py    (license) View Source Project 5 votes vote down vote up
def test_pickling(self):
        import pickle
        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            pickled = pickle.dumps(oldpat, proto)
            newpat = pickle.loads(pickled)
            self.assertEqual(newpat, oldpat)
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile 
Example 9
Project: kbe_server   Author: xiaohaoppy   File: test_re.py    (license) View Source Project 5 votes vote down vote up
def test_pickling(self):
        import pickle
        oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)', re.UNICODE)
        for proto in range(pickle.HIGHEST_PROTOCOL + 1):
            pickled = pickle.dumps(oldpat, proto)
            newpat = pickle.loads(pickled)
            self.assertEqual(newpat, oldpat)
        # current pickle expects the _compile() reconstructor in re module
        from re import _compile