diff --git a/util/notegrep/m.py b/util/notegrep/m.py index 1361125..ff56c5e 100644 --- a/util/notegrep/m.py +++ b/util/notegrep/m.py @@ -18,6 +18,9 @@ class Multi(): self.patterns = patterns self.files = files + def remove_duplicates(self): + self.patterns, self.files = list(dict.fromkeys(self.patterns)), list(dict.fromkeys(self.files)) + def print_matches(self): for file in self.files: @@ -39,11 +42,13 @@ class Multi(): def main(): try: newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(',')) + newMulti.remove_duplicates() newMulti.print_matches() except IndexError: patterns = input("Enter patterns, separated by a comma: ") files = input("Enter files, separated by a comma: ") newMulti = Multi(patterns.split(','), files.split(',')) + newMulti.remove_duplicates() newMulti.print_matches()