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

Function strip_prefixes

src/summarycode/copyright_tallies.py:386–399  ·  view source on GitHub ↗

Return the `s` string with any of the string in the `prefixes` set striped from the left. Normalize and strip spaces. For example: >>> s = 'by AND for the Free Software Foundation' >>> strip_prefixes(s) == 'the Free Software Foundation' True

(s, prefixes=prefixes)

Source from the content-addressed store, hash-verified

384
385
386def strip_prefixes(s, prefixes=prefixes):
387 """
388 Return the `s` string with any of the string in the `prefixes` set
389 striped from the left. Normalize and strip spaces.
390
391 For example:
392 >>> s = 'by AND for the Free Software Foundation'
393 >>> strip_prefixes(s) == 'the Free Software Foundation'
394 True
395 """
396 s = s.split()
397 while s and s[0].lower().strip().strip('.,') in prefixes:
398 s = s[1:]
399 return ' '.join(s)
400
401
402# set of suffixes that can be stripped from a name

Callers

nothing calls this directly

Calls 2

splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected