GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
addthispath.py
Go to the documentation of this file.
2import sys, os, inspect
3
4
6 """
7 Adds the path of the script calling this function to the Python path
8 """
9 tmp = inspect.currentframe()
10 tmp = inspect.getouterframes(tmp)[1][1]
11 tmp = os.path.realpath(tmp)
12 tmp = os.path.dirname(tmp)
13 sys.path.append(tmp)
14
15
16# getouterframes(currentframe) returns a list with information for each
17# frame, starting from the current one with [0] and stepping outward.
18# We want to step out one frame to the calling script, hence [1].
19# Each entry is a tuple with [1] being the filename.
20
21# An alternative would be inspect.getsourcefile(f) with an f defined in
22# the calling script, e.g., f = lambda:0
23
24
25