b.lazy_regex : module documentation

Part of bzrlib

Lazily compiled regex objects.

This module defines a class which creates proxy objects for regex compilation. This allows overriding re.compile() to return lazily compiled objects.

We do this rather than just providing a new interface so that it will also be used by existing Python modules that create regexs.

Class LazyRegex A proxy around a real regex, which won't be compiled until accessed.
Function lazy_compile Create a proxy object which will compile the regex on demand.
Function install_lazy_compile Make lazy_compile the default compile mode for regex compilation.
Function reset_compile Restore the original function to re.compile().
def lazy_compile(*args, **kwargs):
Create a proxy object which will compile the regex on demand.
Returnsa LazyRegex proxy object.
def install_lazy_compile():
Make lazy_compile the default compile mode for regex compilation.

This overrides re.compile with lazy_compile. To restore the original functionality, call reset_compile().

def reset_compile():
Restore the original function to re.compile().

It is safe to call reset_compile() multiple times, it will always restore re.compile() to the value that existed at import time. Though the first call will reset back to the original (it doesn't track nesting level)

API Documentation for Bazaar, generated by pydoctor at 2019-04-24 00:18:01.