From e3d578080b1a36c58ef876184a367a3edde68222 Mon Sep 17 00:00:00 2001 From: dmarakom6 Date: Fri, 2 Jul 2021 18:43:27 +0300 Subject: [PATCH] Remove duplicates from input --- util/notegrep/m.py | 5 +++++ 1 file changed, 5 insertions(+) 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()