Added permuteText
This commit is contained in:
@@ -22,3 +22,6 @@ sudo cp ./fuzzPattern/fuzzPatternCreate /usr/bin
|
||||
|
||||
echo "Installing fuzzPatternSearch..."
|
||||
sudo cp ./fuzzPattern/fuzzPatternSearch /usr/bin
|
||||
|
||||
echo "Installing permutateText.py"
|
||||
sudo cp ./permutateText/permutateText.py /usr/bin
|
||||
|
||||
45
permutateText/permutateText.py
Executable file
45
permutateText/permutateText.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#! /usr/bin/env python3
|
||||
import sys
|
||||
import time
|
||||
|
||||
filenames=[]
|
||||
fileHandles=[]
|
||||
currState=[]
|
||||
currRead=" "
|
||||
|
||||
def showState(state):
|
||||
finalStr=""
|
||||
for curr in state:
|
||||
finalStr+=curr
|
||||
return finalStr
|
||||
|
||||
if len(sys.argv)==1:
|
||||
print("Permutate Text")
|
||||
print("Usage:")
|
||||
print(sys.argv[0]+" textfile1 textfile2 ...")
|
||||
print("This will permutate all the combination of the strings in the nextfiles")
|
||||
sys.exit()
|
||||
else:
|
||||
for i in range(1,len(sys.argv)):
|
||||
filenames.append(sys.argv[i])
|
||||
|
||||
for i in range(len(filenames)):
|
||||
fileHandles.append(open(filenames[i]))
|
||||
currState.append("")
|
||||
|
||||
operator=0
|
||||
|
||||
while currRead!="" or operator!=-1:
|
||||
currRead=fileHandles[operator].readline()
|
||||
|
||||
if currRead != "":
|
||||
currState[operator]=currRead[:-1]
|
||||
|
||||
if operator==len(filenames)-1:
|
||||
print(showState(currState))
|
||||
elif operator<len(filenames)-1:
|
||||
operator+=1
|
||||
else:
|
||||
fileHandles[operator]=open(filenames[operator])
|
||||
operator-=1
|
||||
|
||||
3
permutateText/test1
Normal file
3
permutateText/test1
Normal file
@@ -0,0 +1,3 @@
|
||||
a
|
||||
b
|
||||
c
|
||||
3
permutateText/test2
Normal file
3
permutateText/test2
Normal file
@@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
||||
@@ -22,3 +22,6 @@ sudo rm /usr/bin/fuzzPatternCreate
|
||||
|
||||
echo "Deleting fuzzPatternSearch..."
|
||||
sudo rm /usr/bin/fuzzPatternSearch
|
||||
|
||||
echo "Deleting permutateText.py"
|
||||
sudo rm /usr/bin/permutateText.py
|
||||
|
||||
Reference in New Issue
Block a user