MCPcopy Create free account
hub / github.com/apache/mesos / _DropCommonSuffixes

Function _DropCommonSuffixes

support/cpplint.py:4439–4463  ·  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' >>> _DropCommonSuffixes('foo/foo

(filename)

Source from the content-addressed store, hash-verified

4437
4438
4439def _DropCommonSuffixes(filename):
4440 """Drops common suffixes like _test.cc or -inl.h from filename.
4441
4442 For example:
4443 >>> _DropCommonSuffixes('foo/foo-inl.h')
4444 'foo/foo'
4445 >>> _DropCommonSuffixes('foo/bar/foo.cc')
4446 'foo/bar/foo'
4447 >>> _DropCommonSuffixes('foo/foo_internal.h')
4448 'foo/foo'
4449 >>> _DropCommonSuffixes('foo/foo_unusualinternal.h')
4450 'foo/foo_unusualinternal'
4451
4452 Args:
4453 filename: The input filename.
4454
4455 Returns:
4456 The filename with the common suffix removed.
4457 """
4458 for suffix in ('test.cc', 'regtest.cc', 'unittest.cc',
4459 'inl.h', 'impl.h', 'internal.h'):
4460 if (filename.endswith(suffix) and len(filename) > len(suffix) and
4461 filename[-len(suffix) - 1] in ('-', '_')):
4462 return filename[:-len(suffix) - 1]
4463 return os.path.splitext(filename)[0]
4464
4465
4466def _ClassifyInclude(fileinfo, include, is_system):

Callers 1

_ClassifyIncludeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected