MCPcopy
hub / github.com/django/django / _lazy_re_compile

Function _lazy_re_compile

django/utils/regex_helper.py:343–354  ·  view source on GitHub ↗

Lazily compile a regex with flags.

(regex, flags=0)

Source from the content-addressed store, hash-verified

341
342
343def _lazy_re_compile(regex, flags=0):
344 """Lazily compile a regex with flags."""
345
346 def _compile():
347 # Compile the regex if it was not passed pre-compiled.
348 if isinstance(regex, (str, bytes)):
349 return re.compile(regex, flags)
350 else:
351 assert not flags, "flags must be empty if regex is passed pre-compiled"
352 return regex
353
354 return SimpleLazyObject(_compile)

Callers 15

storage.pyFile · 0.90
search.pyFile · 0.90
geometry.pyFile · 0.90
RelateLookupClass · 0.90
utils.pyFile · 0.90
utils.pyFile · 0.90
text.pyFile · 0.90
dateformat.pyFile · 0.90
cache.pyFile · 0.90
dateparse.pyFile · 0.90
html.pyFile · 0.90
UrlizerClass · 0.90

Calls 1

SimpleLazyObjectClass · 0.90

Tested by

no test coverage detected