I'm currently working on a sublime text 2 plugin and I'm having problems with opening files.
When I mean opening files, I don't mean opening files inside the sublime editor or anything. What I mean is for a Python module to programmatically open a file from the file system to read from it.
First of all, my plugin is based on cleanjs (github.com/captainbrosset/cleanjs/) a python command line tool I'm working on. The plugin itself is just another way of accessing cleanjs rather than from the command line. Therefore I can't rely on the normal SublimeText configuration system.
Say I have a structure like this:
Say both cleanjs_commandline.py and cleanjs_sublime.py need to read the file.txt using the configreader.py module.
configreader.py cannot make any assumption if it's being called in normal command line mode or through the sublime plugin.
In command line mode, a simple open("file.txt") works very well, but it fails completely when the it's executed from the sublime text plugin.
I guess this comes from the way sublime imports and run plugins of course, so the path looks different.
If I do some dirty if statements, I will be able to include the proper file anyway, but I was hoping there would be a nicer way of opening files easily, no matter where the .py module gets called from and how, just knowing the relative path of that file.
By the way, this is not only linked to Sublime, it does the same in Python depending on how I execute my program.
Thanks for your help!