GSI Object Oriented Online Offline (Go4)
GO4-6.3.0
python
go4py
internals
addthispath.py
Go to the documentation of this file.
1
2
import
sys, os, inspect
3
4
5
def
addthispath
():
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
go4py.internals.addthispath.addthispath
def addthispath()
Definition:
addthispath.py:5
Generated on Wed Jan 10 2024 15:04:18 for GSI Object Oriented Online Offline (Go4) by
1.8.13