Skip to content

Tarantula updated #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions listTupleLogic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class listTupleLogic:

def __init__(self):
self.lists = {}
self.tuples = {}
self.startList = []
self.startTuple = []

def pushList(self, index):
self.startList.append(index)


def popList(self, index):
i = self.startList[len(self.startList)-1]
self.lists[i] = index
del self.startList[-1]


def pushTuple(self, index):
self.startTuple.append(index)


def popTuple(self, index):
i = self.startTuple[len(self.startTuple)-1]
self.tuples[i] = index
del self.startTuple[-1]
Binary file added listTupleLogic.pyc
Binary file not shown.
68 changes: 68 additions & 0 deletions parseArg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# How would I handle an input casewith list, tuple as input
import ast
from listTupleLogic import listTupleLogic


def appendArg(slice, collection, index, arguments):


if index >= len(slice):
return

if slice[index] == '[':
temp = collection.lists[index] # gives me index of ending parenthesis
result = ast.literal_eval(slice[index:temp+1]) # converts into a list
arguments.append(result)
index = temp + 2
return appendArg(slice, collection, index, arguments)

elif slice[index] == '(':
temp = collection.tuples[index]
result = ast.literal_eval(slice[index:temp+1])
arguments.append(result)
index = temp + 2
return appendArg(slice, collection, index, arguments)

else:
i = slice.find(',', index)
if i is not -1:
result = ast.literal_eval(slice[index:i])
index = i+1
arguments.append(result)
return appendArg(slice, collection, index, arguments)
else:
result = ast.literal_eval(slice[index:])
arguments.append(result)
return




def logic(str):
text = "".join(str.split())
reg = listTupleLogic()

for i in range(len(text)):
if text[i] == '[':
reg.pushList(i)

elif text[i] == ']':
reg.popList(i)

elif text[i] == '(':
reg.pushTuple(i)

elif text[i] == ')':
reg.popTuple(i)


return [reg, text]




def getArgs(str):
[a, text] = logic(str)
arguments = []
appendArg(text,a,0, arguments)
return arguments
Binary file added parseArg.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion tarantula.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import linecache
import os
from optparse import OptionParser
from parseArg import getArgs

class Line:
def __init__(self, score=0.0, rank=0, text= "", lineNo=0):
Expand Down Expand Up @@ -49,7 +50,9 @@ def importResultsFile():
line = file.readline()
# print line
try:
numbers = tuple([int(num) for num in line.split(',')])
numbers = tuple(getArgs(line))
if numbers == ():
break
tests.append(numbers)
except ValueError:
break
Expand Down