Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# get the text over lap correct
if self.beg < other_filth.beg:
first = self
second = other_filth
else:
second = self
first = other_filth
end_offset = second.end - first.end
if end_offset > 0:
self.text = first.text + second.text[-end_offset:]
# update the beg/end strings
self.beg = min(self.beg, other_filth.beg)
self.end = max(self.end, other_filth.end)
if self.end - self.beg != len(self.text):
raise exceptions.FilthMergeError("text length isn't consistent")
# update the placeholder
self.filths.append(other_filth)
self._placeholder = '+'.join([filth.type for filth in self.filths])