From 8f172ca9977b70eb68472a17e40e3cc1db79b163 Mon Sep 17 00:00:00 2001 From: Luke Faraone Date: Fri, 20 Aug 2010 19:29:47 +0000 Subject: Use XDG Base Directory data dirs. --- (limited to 'turtleart.py') diff --git a/turtleart.py b/turtleart.py index fb384c1..7848320 100755 --- a/turtleart.py +++ b/turtleart.py @@ -37,6 +37,14 @@ except ImportError, e: print "Import Error: %s. Project upload is disabled." % (e) _UPLOAD_AVAILABLE = False +try: + # Try to use XDG Base Directory standard for config files + import xdg.BaseDirectory + CONFIG_HOME = os.path.join(xdg.BaseDirectory.xdg_config_home, 'turtleart') +except ImportError, e: + # Default to `.config` per the spec. + CONFIG_HOME = os.path.expanduser(os.path.join('~', '.config', 'turtleart')) + argv = sys.argv[:] # Workaround for import behavior of gst in tagplay sys.argv[1:] = [] # Execution of import gst cannot see '--help' or '-h' @@ -143,9 +151,9 @@ class TurtleMain(): win = gtk.Window(gtk.WINDOW_TOPLEVEL) try: - data_file = open('.turtleartrc', 'r') + data_file = open(os.path.join(CONFIG_HOME, 'turtleartrc'), 'r') except IOError: - data_file = open('.turtleartrc', 'a+') + data_file = open(os.path.join(CONFIG_HOME, 'turtleartrc'), 'a+') data_file.write(str(50) + '\n') data_file.write(str(50) + '\n') data_file.write(str(800) + '\n') -- cgit v0.9.1