@@ 4577-4604 (lines=28) @@ | ||
4574 | _RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') |
|
4575 | ||
4576 | ||
4577 | def _DropCommonSuffixes(filename): |
|
4578 | """Drops common suffixes like _test.cc or -inl.h from filename. |
|
4579 | ||
4580 | For example: |
|
4581 | >>> _DropCommonSuffixes('foo/foo-inl.h') |
|
4582 | 'foo/foo' |
|
4583 | >>> _DropCommonSuffixes('foo/bar/foo.cc') |
|
4584 | 'foo/bar/foo' |
|
4585 | >>> _DropCommonSuffixes('foo/foo_internal.h') |
|
4586 | 'foo/foo' |
|
4587 | >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') |
|
4588 | 'foo/foo_unusualinternal' |
|
4589 | ||
4590 | Args: |
|
4591 | filename: The input filename. |
|
4592 | ||
4593 | Returns: |
|
4594 | The filename with the common suffix removed. |
|
4595 | """ |
|
4596 | for suffix in itertools.chain( |
|
4597 | ('%s.%s' % (test_suffix.lstrip('_'), ext) |
|
4598 | for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())), |
|
4599 | ('%s.%s' % (suffix, ext) |
|
4600 | for suffix, ext in itertools.product(['inl', 'imp', 'internal'], GetHeaderExtensions()))): |
|
4601 | if (filename.endswith(suffix) and len(filename) > len(suffix) and |
|
4602 | filename[-len(suffix) - 1] in ('-', '_')): |
|
4603 | return filename[:-len(suffix) - 1] |
|
4604 | return os.path.splitext(filename)[0] |
|
4605 | ||
4606 | ||
4607 | def _ClassifyInclude(fileinfo, include, is_system): |
@@ 4577-4604 (lines=28) @@ | ||
4574 | _RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') |
|
4575 | ||
4576 | ||
4577 | def _DropCommonSuffixes(filename): |
|
4578 | """Drops common suffixes like _test.cc or -inl.h from filename. |
|
4579 | ||
4580 | For example: |
|
4581 | >>> _DropCommonSuffixes('foo/foo-inl.h') |
|
4582 | 'foo/foo' |
|
4583 | >>> _DropCommonSuffixes('foo/bar/foo.cc') |
|
4584 | 'foo/bar/foo' |
|
4585 | >>> _DropCommonSuffixes('foo/foo_internal.h') |
|
4586 | 'foo/foo' |
|
4587 | >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') |
|
4588 | 'foo/foo_unusualinternal' |
|
4589 | ||
4590 | Args: |
|
4591 | filename: The input filename. |
|
4592 | ||
4593 | Returns: |
|
4594 | The filename with the common suffix removed. |
|
4595 | """ |
|
4596 | for suffix in itertools.chain( |
|
4597 | ('%s.%s' % (test_suffix.lstrip('_'), ext) |
|
4598 | for test_suffix, ext in itertools.product(_test_suffixes, GetNonHeaderExtensions())), |
|
4599 | ('%s.%s' % (suffix, ext) |
|
4600 | for suffix, ext in itertools.product(['inl', 'imp', 'internal'], GetHeaderExtensions()))): |
|
4601 | if (filename.endswith(suffix) and len(filename) > len(suffix) and |
|
4602 | filename[-len(suffix) - 1] in ('-', '_')): |
|
4603 | return filename[:-len(suffix) - 1] |
|
4604 | return os.path.splitext(filename)[0] |
|
4605 | ||
4606 | ||
4607 | def _ClassifyInclude(fileinfo, include, is_system): |