MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / LazyRegexCompiler

Class LazyRegexCompiler

mongoengine/base/utils.py:4–22  ·  view source on GitHub ↗

Descriptor to allow lazy compilation of regex

Source from the content-addressed store, hash-verified

2
3
4class LazyRegexCompiler:
5 """Descriptor to allow lazy compilation of regex"""
6
7 def __init__(self, pattern, flags=0):
8 self._pattern = pattern
9 self._flags = flags
10 self._compiled_regex = None
11
12 @property
13 def compiled_regex(self):
14 if self._compiled_regex is None:
15 self._compiled_regex = re.compile(self._pattern, self._flags)
16 return self._compiled_regex
17
18 def __get__(self, instance, owner):
19 return self.compiled_regex
20
21 def __set__(self, instance, value):
22 raise AttributeError("Can not set attribute LazyRegexCompiler")

Callers 3

URLFieldClass · 0.90
EmailFieldClass · 0.90
UserEmailClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…