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)
| 4953 | |
| 4954 | |
| 4955 | def _DropCommonSuffixes(filename): |
| 4956 | """Drops common suffixes like _test.cc or -inl.h from filename. |
| 4957 | |
| 4958 | For example: |
| 4959 | >>> _DropCommonSuffixes('foo/foo-inl.h') |
| 4960 | 'foo/foo' |
| 4961 | >>> _DropCommonSuffixes('foo/bar/foo.cc') |
| 4962 | 'foo/bar/foo' |
| 4963 | >>> _DropCommonSuffixes('foo/foo_internal.h') |
| 4964 | 'foo/foo' |
| 4965 | >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') |
| 4966 | 'foo/foo_unusualinternal' |
| 4967 | |
| 4968 | Args: |
| 4969 | filename: The input filename. |
| 4970 | |
| 4971 | Returns: |
| 4972 | The filename with the common suffix removed. |
| 4973 | """ |
| 4974 | for suffix in itertools.chain( |
| 4975 | ('%s.%s' % (test_suffix.lstrip('_'), ext) |
| 4976 | for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())), |
| 4977 | ('%s.%s' % (suffix, ext) |
| 4978 | for suffix, ext in itertools.product(['inl', 'imp', 'internal'], GetHeaderExtensions()))): |
| 4979 | if (filename.endswith(suffix) and len(filename) > len(suffix) and |
| 4980 | filename[-len(suffix) - 1] in ('-', '_')): |
| 4981 | return filename[:-len(suffix) - 1] |
| 4982 | return os.path.splitext(filename)[0] |
| 4983 | |
| 4984 | |
| 4985 | def _ClassifyInclude(fileinfo, include, used_angle_brackets, include_order="default"): |
no test coverage detected