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

Method __repr__

src/licensedcode/spans.py:157–175  ·  view source on GitHub ↗

Return a brief representation of this span by only listing contiguous spans and not all items. For example: >>> Span([1, 2, 3, 4, 5, 7, 8, 9, 10]) Span(1, 5)|Span(7, 10)

(self)

Source from the content-addressed store, hash-verified

155 return Span(self._set.difference(*[o._set for o in others]))
156
157 def __repr__(self):
158 """
159 Return a brief representation of this span by only listing contiguous
160 spans and not all items.
161
162 For example:
163 >>> Span([1, 2, 3, 4, 5, 7, 8, 9, 10])
164 Span(1, 5)|Span(7, 10)
165 """
166 subspans_repr = []
167 for subs in self.subspans():
168 ls = len(subs)
169 if not ls:
170 subspans_repr.append('Span()')
171 elif ls == 1:
172 subspans_repr.append('Span(%d)' % subs.start)
173 else:
174 subspans_repr.append('Span(%d, %d)' % (subs.start, subs.end))
175 return '|'.join(subspans_repr)
176
177 def __contains__(self, other):
178 """

Callers

nothing calls this directly

Calls 3

subspansMethod · 0.95
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected