-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Regina wants to add a feature that allows any file to be analyzed under the assumption that the file was text-based and that it was coded in Python.
if filepath[-6:].replace(" ","") == ".ipynb": # if file is ipython notebook
with open(filepath,"r") as r: # open and read file
nb = nbf.read(r,3)
for x in nb.worksheets:
for cell in x.cells:
if cell.cell_type == "markdown" or cell.cell_type == "heading":# if cell is markdown cell,put in arr info & type
self.arr.append([cell.source,"markdown"])
elif cell.cell_type =="code": # if cell is code cell
if not cell.language == 'python': # if language is not python, throw error
raise ValueError('Code must be in python!')
self.arr.append([cell.input,"code"]) # put in arr info & type, put in code info and position
self.code.append([cell.input.split("\n"),len(arr)])
# if not ipynb
else:
with open(filepath) as r:
self.arr.append([file.read(),"code"]) # put in arr its info and that it is code
self.code.append([file.readlines(),1]) # put in code its info