os.path.dirname(sys.argv[0]) is the path used to invoke the script, but it can be relative to whatever did the invoking. If it is relative, then I think it's relative to the initial value of os.getcwd().
So, a simple ;-)
os.path.normpath(os.path.join(os.getcwd(),os.path.dirname(sys.argv[0])))
should get you to the directory containing the script, given that if the sys.argv[0] turns out to be absolute, the normpath step will drop the os.getcwd() part, coming, as it would, before a '//'.
Hope that helps - all depends on os.getcwd() not being altered before you get it of course.
Cheers -Terry
On Thu, 31 Jan 2008 19:19:57 +0000 Joel Holdsworth <joel@...1709...> wrote:
Hi All,
I'm just working on a rendering extension, which needs to access a collection of source data files. Really I'd like to add a sub-directory to the extension scripts directory, but I'm having difficulty accessing the sub-directory, because when my script starts, it's working directory seems to be my home directory not the extension directory. So if I call the line
inkex.etree.parse( "my-sub-dir/data.svg" )
it only returns successfully if my-sub-dir is in my home directory. Does anyone have any suggestions how to access my data files from their installation directory?
Thanks Joel
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel