MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / touch

Method touch

src/licensedcode/spans.py:384–400  ·  view source on GitHub ↗

Return True if self sequence is contiguous with other span without overlap. For example: >>> Span([5, 7]).touch(Span([5])) False >>> Span([5, 7]).touch(Span([5, 8])) False >>> Span([5, 7]).touch(Span([7, 8])) False >>> Span([5

(self, other)

Source from the content-addressed store, hash-verified

382 return self.start > other.end
383
384 def touch(self, other):
385 """
386 Return True if self sequence is contiguous with other span without overlap.
387
388 For example:
389 >>> Span([5, 7]).touch(Span([5]))
390 False
391 >>> Span([5, 7]).touch(Span([5, 8]))
392 False
393 >>> Span([5, 7]).touch(Span([7, 8]))
394 False
395 >>> Span([5, 7]).touch(Span([8, 9]))
396 True
397 >>> Span([8, 9]).touch(Span([5, 7]))
398 True
399 """
400 return self.start == other.end + 1 or self.end == other.start - 1
401
402 def distance_to(self, other):
403 """

Callers 1

distance_toMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected