Does anyone has a workaround to get the current script path in the jython environment? For some reason __file__ is not available in the jython environment.
An example use case I have would be to dynamically load my yaml configs from within jython, with configuration files relative to the user script.
Eg: I typically store my configuration files in for more complex modules in jsr223/python/personal/configs/*.yaml
I’d like to do something like
conf_folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), ‘confs’, ‘%s.yaml’ % os.path.basename(__file__).replace(’.py’, ‘’))
with open(conf_folder, ‘r’) as f:
conf = yaml.load(f)
Right now I do the workaround where I store some basic stuff in the configuration.py (following the folder structure from the openhab helper libraries). I know it’s just a minor thing, but somehow I feel more comfortable with strictly splitting my library from the setup specific stuff and personally I like having all configuration options in helper files.