[gnome-games] Use xdg data directory for saved games



commit 10b4fc8c9062909958afd35b6200f8aeac22cb38
Author: William Jon McCann <jmccann redhat com>
Date:   Fri May 11 12:44:05 2012 -0400

    Use xdg data directory for saved games
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674875

 gnome-sudoku/src/lib/saver.py |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/saver.py b/gnome-sudoku/src/lib/saver.py
index b156afd..a792a05 100644
--- a/gnome-sudoku/src/lib/saver.py
+++ b/gnome-sudoku/src/lib/saver.py
@@ -123,11 +123,28 @@ class SudokuTracker:
     """
 
     def __init__ (self):
-        self.save_path = os.path.expanduser('~/.sudoku/saved')
-        self.finished_path = os.path.expanduser('~/.sudoku/finished')
+        self.save_path = os.path.join(defaults.DATA_DIR,"saved")
+        self.finished_path = os.path.join(defaults.DATA_DIR,"finished")
+        self.migrate_data()
         self.create_dir_safely(self.save_path)
         self.create_dir_safely(self.finished_path)
 
+    def migrate_data (self):
+        old_path = os.path.expanduser('~/.sudoku')
+        if os.path.exists(old_path) and (not os.path.exists(self.save_path) and not os.path.exists(self.finished_path)):
+            try:
+                os.rename(os.path.join(old_path,"saved"),self.save_path)
+            except:
+                pass
+            try:
+                os.rename(os.path.join(old_path,"finished"),self.finished_path)
+            except:
+                pass
+            try:
+                os.rmdir(old_path)
+            except:
+                pass
+
     def create_dir_safely (self, path):
         if not os.path.exists(path):
             try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]