Skip to content

Commit

Permalink
Fixed bugs and testing dif keras models
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhvani Patel committed Jul 18, 2017
1 parent 6d1e267 commit a800207
Show file tree
Hide file tree
Showing 12 changed files with 509 additions and 278 deletions.
Binary file modified __pycache__/toCheck.pypy-41.pyc
Binary file not shown.
176 changes: 174 additions & 2 deletions check_pypy_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,174 @@ def find_nth(haystack, needle, n):
n -= 1
return start

# Main method
def checkPyPySyntaxDel(src):
myFile = open("toCheckD.py", "w")
myFile.write(src)
myFile.close()
proc = subprocess.Popen(['pypy', '-m', 'py_compile', 'toCheckD.py'], stderr=subprocess.PIPE)
streamdata, err = proc.communicate()
rc = proc.returncode
if rc == 0:
# No errors, all good
if os.path.isfile("toCheckD.py") == True:
os.remove("toCheckD.py")
return None
else:
# Error, disect data for constructor
fileBegInd = find_nth(err, 'File ', 1)
fileEndInd = find_nth(err, ',', 1)
lineInd = find_nth(err, 'line ', 1)

nextLineInd = find_nth(err, '\n', 1)


add = err[lineInd+5:nextLineInd]
add = re.sub("[^0-9]", "", add)
if(add == ''):
add = '-1'
line = int(add)

textInd = find_nth(err, ' ', 1)
temp2 = err[textInd+4:]


nextLineIndTemp = find_nth(temp2, ' ', 1)
textAfter = err[textInd+4:nextLineIndTemp+textInd+3]

fileName = err[fileBegInd+6:fileEndInd-1]

colon = ':'

textBeforeInd = err.rfind(colon.encode())
textBefore = err[textBeforeInd+2:]
textBefore = textBefore.strip()

colonTwo = ':'

text = textBefore + colon.encode() + textAfter

cutoffInd = find_nth(err, '^', 1)
errorname = err[cutoffInd+2:textBeforeInd]

errorObj = CompileError(fileName, line, None, None, text, errorname)
if os.path.isfile("toCheckD.py") == True:
os.remove("toCheckD.py")
return [errorObj]


# Main method
def checkPyPySyntaxIns(src):
myFile = open("toCheckI.py", "w")
myFile.write(src)
myFile.close()
proc = subprocess.Popen(['pypy', '-m', 'py_compile', 'toCheckI.py'], stderr=subprocess.PIPE)
streamdata, err = proc.communicate()
rc = proc.returncode
if rc == 0:
# No errors, all good
if os.path.isfile("toCheckI.py") == True:
os.remove("toCheckI.py")
return None
else:
# Error, disect data for constructor
fileBegInd = find_nth(err, 'File ', 1)
fileEndInd = find_nth(err, ',', 1)
lineInd = find_nth(err, 'line ', 1)

nextLineInd = find_nth(err, '\n', 1)


add = err[lineInd+5:nextLineInd]
add = re.sub("[^0-9]", "", add)
if(add == ''):
add = '-1'
line = int(add)

textInd = find_nth(err, ' ', 1)
temp2 = err[textInd+4:]


nextLineIndTemp = find_nth(temp2, ' ', 1)
textAfter = err[textInd+4:nextLineIndTemp+textInd+3]

fileName = err[fileBegInd+6:fileEndInd-1]

colon = ':'

textBeforeInd = err.rfind(colon.encode())
textBefore = err[textBeforeInd+2:]
textBefore = textBefore.strip()

colonTwo = ':'

text = textBefore + colon.encode() + textAfter

cutoffInd = find_nth(err, '^', 1)
errorname = err[cutoffInd+2:textBeforeInd]

errorObj = CompileError(fileName, line, None, None, text, errorname)
if os.path.isfile("toCheckI.py") == True:
os.remove("toCheckI.py")
return [errorObj]

# Main method
def checkPyPySyntaxSub(src):
myFile = open("toCheckS.py", "w")
myFile.write(src)
myFile.close()
proc = subprocess.Popen(['pypy', '-m', 'py_compile', 'toCheckS.py'], stderr=subprocess.PIPE)
streamdata, err = proc.communicate()
rc = proc.returncode
if rc == 0:
# No errors, all good
if os.path.isfile("toCheckS.py") == True:
os.remove("toCheckS.py")
return None
else:
# Error, disect data for constructor
fileBegInd = find_nth(err, 'File ', 1)
fileEndInd = find_nth(err, ',', 1)
lineInd = find_nth(err, 'line ', 1)

nextLineInd = find_nth(err, '\n', 1)


add = err[lineInd+5:nextLineInd]
add = re.sub("[^0-9]", "", add)
if(add == ''):
add = '-1'
line = int(add)

textInd = find_nth(err, ' ', 1)
temp2 = err[textInd+4:]


nextLineIndTemp = find_nth(temp2, ' ', 1)
textAfter = err[textInd+4:nextLineIndTemp+textInd+3]

fileName = err[fileBegInd+6:fileEndInd-1]

colon = ':'

textBeforeInd = err.rfind(colon.encode())
textBefore = err[textBeforeInd+2:]
textBefore = textBefore.strip()

colonTwo = ':'

text = textBefore + colon.encode() + textAfter

cutoffInd = find_nth(err, '^', 1)
errorname = err[cutoffInd+2:textBeforeInd]

errorObj = CompileError(fileName, line, None, None, text, errorname)
if os.path.isfile("toCheckS.py") == True:
os.remove("toCheckS.py")
return [errorObj]



# Main method
def checkPyPySyntax(src):
myFile = open("toCheck.py", "w")
Expand All @@ -44,7 +212,8 @@ def checkPyPySyntax(src):
rc = proc.returncode
if rc == 0:
# No errors, all good
os.remove("toCheck.py")
if os.path.isfile("toCheck.py") == True:
os.remove("toCheck.py")
return None
else:
# Error, disect data for constructor
Expand All @@ -57,6 +226,8 @@ def checkPyPySyntax(src):

add = err[lineInd+5:nextLineInd]
add = re.sub("[^0-9]", "", add)
if(add == ''):
add = '-1'
line = int(add)

textInd = find_nth(err, ' ', 1)
Expand All @@ -82,6 +253,7 @@ def checkPyPySyntax(src):
errorname = err[cutoffInd+2:textBeforeInd]

errorObj = CompileError(fileName, line, None, None, text, errorname)
os.remove("toCheck.py")
if os.path.isfile("toCheck.py") == True:
os.remove("toCheck.py")
return [errorObj]

Binary file modified check_pypy_syntax.pyc
Binary file not shown.
Loading

0 comments on commit a800207

Please sign in to comment.