diff --git a/ardumont/check_for_dump_clash.py b/ardumont/check_for_dump_clash.py deleted file mode 100755 index 4e3077c..0000000 --- a/ardumont/check_for_dump_clash.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - -import click -import os -import sys - -from collections import defaultdict - - -def read(): - m = defaultdict(list) - for line in sys.stdin: - path = line.rstrip() - project_name = os.path.basename(os.path.dirname(path)) - m[project_name].append(path) - - for project_name, paths in m.items(): - if len(paths) > 1: - yield project_name, paths - - -@click.command( - help="""Dump code.google.com path for which a name clash exists in dumps - coming from apache-extras and eclipselabs...""") -def main(): - for project_name, paths in read(): - for path in paths: - if 'apache-extras' not in path and 'eclipselabs' not in path: - print(path) - - -if __name__ == '__main__': - main() diff --git a/ardumont/filter_path_clashes.py b/ardumont/filter_path_clashes.py new file mode 100755 index 0000000..a8311fe --- /dev/null +++ b/ardumont/filter_path_clashes.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 + +import click +import os +import sys + +from collections import defaultdict + + +def clash_from_stdin(): + m = defaultdict(list) + for line in sys.stdin: + path = line.rstrip() + project_name = os.path.basename(os.path.dirname(path)) + m[project_name].append(path) + + return m + + +def filter_clashed_paths(): + """Yields the list of path with clash in names. + + """ + clashes = clash_from_stdin() + for project_name, paths in clashes.items(): + if len(paths) > 1: + yield project_name, paths + + +def filter_unclashed_paths(): + """Yields the paths with no clash in names. + + """ + clashes = clash_from_stdin() + for project_name, paths in clashes.items(): + if len(paths) == 1: + yield project_name, paths + + +@click.command( + help="""Dump code.google.com paths for which a name clash exists (or no + clash) in dumps coming from apache-extras and + eclipselabs...""") +@click.option('--filter-clash/--no-filter-clash', is_flag=True, default=True) +def main(filter_clash): + fn = filter_clashed_paths if filter_clash else filter_unclashed_paths + for project_name, paths in fn(): + for path in paths: + print(project_name, path) + + +if __name__ == '__main__': + main()