MCPcopy Index your code
hub / github.com/cpplint/cpplint / _DropCommonSuffixes

Function _DropCommonSuffixes

cpplint.py:5577–5612  ·  view source on GitHub ↗

Drops common suffixes like _test.cc or -inl.h from filename. For example: >>> _DropCommonSuffixes('foo/foo-inl.h') 'foo/foo' >>> _DropCommonSuffixes('foo/bar/foo.cc') 'foo/bar/foo' >>> _DropCommonSuffixes('foo/foo_internal.h') 'foo/foo' >>> _DropCommonS

(filename)

Source from the content-addressed store, hash-verified

5575
5576
5577def _DropCommonSuffixes(filename):
5578 """Drops common suffixes like _test.cc or -inl.h from filename.
5579
5580 For example:
5581 >>> _DropCommonSuffixes('foo/foo-inl.h')
5582 'foo/foo'
5583 >>> _DropCommonSuffixes('foo/bar/foo.cc')
5584 'foo/bar/foo'
5585 >>> _DropCommonSuffixes('foo/foo_internal.h')
5586 'foo/foo'
5587 >>> _DropCommonSuffixes('foo/foo_unusualinternal.h')
5588 'foo/foo_unusualinternal'
5589
5590 Args:
5591 filename: The input filename.
5592
5593 Returns:
5594 The filename with the common suffix removed.
5595 """
5596 for suffix in itertools.chain(
5597 (
5598 f"{test_suffix.lstrip('_')}.{ext}"
5599 for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())
5600 ),
5601 (
5602 f"{suffix}.{ext}"
5603 for suffix, ext in itertools.product(["inl", "imp", "internal"], GetHeaderExtensions())
5604 ),
5605 ):
5606 if (
5607 filename.endswith(suffix)
5608 and len(filename) > len(suffix)
5609 and filename[-len(suffix) - 1] in ("-", "_")
5610 ):
5611 return filename[: -len(suffix) - 1]
5612 return os.path.splitext(filename)[0]
5613
5614
5615def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="default"):

Callers 1

_ClassifyIncludeFunction · 0.85

Calls 2

GetNonHeaderExtensionsFunction · 0.85
GetHeaderExtensionsFunction · 0.85

Tested by

no test coverage detected