Remove duplicates from input
This commit is contained in:
parent
909a3c519b
commit
e3d578080b
1 changed files with 5 additions and 0 deletions
|
@ -18,6 +18,9 @@ class Multi():
|
||||||
self.patterns = patterns
|
self.patterns = patterns
|
||||||
self.files = files
|
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):
|
def print_matches(self):
|
||||||
|
|
||||||
for file in self.files:
|
for file in self.files:
|
||||||
|
@ -39,11 +42,13 @@ class Multi():
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(','))
|
newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(','))
|
||||||
|
newMulti.remove_duplicates()
|
||||||
newMulti.print_matches()
|
newMulti.print_matches()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
patterns = input("Enter patterns, separated by a comma: ")
|
patterns = input("Enter patterns, separated by a comma: ")
|
||||||
files = input("Enter files, separated by a comma: ")
|
files = input("Enter files, separated by a comma: ")
|
||||||
newMulti = Multi(patterns.split(','), files.split(','))
|
newMulti = Multi(patterns.split(','), files.split(','))
|
||||||
|
newMulti.remove_duplicates()
|
||||||
newMulti.print_matches()
|
newMulti.print_matches()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue