Python re._compile() Examples

The following are 11 code examples of re._compile(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module re , or try the search function .
Example #1
Source File: test_re.py    From ironpython2 with Apache License 2.0 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
Source File: test_re.py    From oss-ftp with MIT License 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
Source File: test_re.py    From Fluid-Designer with GNU General Public License v3.0 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 #4
Source File: test_re.py    From ironpython3 with Apache License 2.0 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 #5
Source File: profile_imports.py    From lang2program with Apache License 2.0 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
Source File: profile_imports.py    From lang2program with Apache License 2.0 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
Source File: profile_imports.py    From lang2program with Apache License 2.0 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 #8
Source File: profile_imports.py    From lang2program with Apache License 2.0 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 #9
Source File: test_re.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 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 #10
Source File: test_re.py    From CTFCrackTools-V2 with GNU General Public License v3.0 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 #11
Source File: test_re.py    From CTFCrackTools with GNU General Public License v3.0 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