Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if points is None:
pointed_word = '.%s.' % word
references = [0] * (len(pointed_word) + 1)
for i in range(len(pointed_word) - 1):
for j in range(
i + 1, min(i + self.maxlen, len(pointed_word)) + 1):
pattern = self.patterns.get(pointed_word[i:j])
if pattern:
offset, values = pattern
slice_ = slice(i + offset, i + offset + len(values))
references[slice_] = list(map(
max, values, references[slice_]))
points = [
DataInt(i - 1, reference=reference)
for i, reference in enumerate(references) if reference % 2]
self.cache[word] = points
return points
def __new__(cls, value, data=None, reference=None):
"""Create a new ``DataInt``.
Call with ``reference=dataint_object`` to use the data from another
``DataInt``.
"""
obj = int.__new__(cls, value)
if reference and isinstance(reference, DataInt):
obj.data = reference.data
else:
obj.data = data
return obj
def __call__(self, value):
self.index -= 1
value = int(value)
if value & 1:
return DataInt(value, (self.change, self.index, self.cut))
else:
return value