If this question is beyond the scope, please suggest where I can move it.
I have many python scripts (version 2.7) that call each other. To get an idea of ββwhat the script calls that I currently created a beautiful graphical interface tree that displays this.
The problem I ran into is analyzing the files. The simplest example of a script calling another script calls:
os.system('another.py')
This is trivial to parse, just take what's inside the parenthesis. Now I have come to evaluate variables. My current way of evaluating variables works as follows:
x = 'another'
dot = '.'
py = 'py'
os.system(x+dot+py)
listOfVars = getVarsBetweenParenthesis()
'''
Finds the value of a variable.
'''
def getVarValue(data, variable, stop):
match = ''
for line in data:
noString = line.replace(' ', '')
if variable+'=' in noString:
match = line.replace(variable+'=', '').strip()
if line == stop:
break
return match
, .
Call getVarValue to find value for every variable, then add these together .
:
x = os.getcwd()
script = 'x.py'
os.system(x+script)
, ( / ), .
python , , .
tokenize, , .
, , , .
( pythonic) script?