[orca] Fix for bug #628569 - Orca preferences are not getting saved permanently if a $HOME/.orca exists



commit 1f50935a12e6b3c104fc855301ded00b9bc4451a
Author: Alejandro Leiva <aleiva emergya es>
Date:   Mon Sep 13 12:19:47 2010 +0200

    Fix for bug #628569 - Orca preferences are not getting saved permanently if a $HOME/.orca exists

 src/orca/orca.py |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/src/orca/orca.py b/src/orca/orca.py
index 9309684..a4cb691 100644
--- a/src/orca/orca.py
+++ b/src/orca/orca.py
@@ -2164,20 +2164,25 @@ def main():
     from xdg.BaseDirectory import xdg_data_home
     userPrefsDir = os.path.join(xdg_data_home, "orca")
     oldUserPrefsDir = os.path.join(os.environ["HOME"], ".orca")
-    if os.path.exists(oldUserPrefsDir):
-        try:
-            shutil.copytree(oldUserPrefsDir, userPrefsDir)
-        except:
-            for name in os.listdir(oldUserPrefsDir):
-                srcPath = os.path.join(oldUserPrefsDir, name)
-                dstPath = os.path.join(userPrefsDir, name)
-                if os.path.isfile(srcPath):
-                    shutil.copy(srcPath, dstPath)
-                elif os.path.isdir(srcPath):
-                    if not os.path.isdir(dstPath):
-                        os.mkdir(dstPath)
-    settings.userPrefsDir = userPrefsDir
 
+    if not os.path.exists(userPrefsDir):
+        os.mkdir(userPrefsDir)
+
+    for baseDirName, dirNames, fileNames in os.walk(oldUserPrefsDir):
+
+        for dirName in dirNames:
+            dstDir = os.path.join(userPrefsDir, dirName)
+            if not os.path.exists(dstDir):
+                os.mkdir(dstDir)
+
+        for fileName in fileNames:
+            srcFile = os.path.join(baseDirName, fileName)
+            relPath = os.path.relpath(baseDirName, oldUserPrefsDir)
+            dstFile = os.path.join(os.path.join(userPrefsDir, relPath), fileName)
+            if not os.path.exists(dstFile):
+                shutil.copy(srcFile, dstFile)
+
+    settings.userPrefsDir = userPrefsDir
 
     # Do not run Orca if accessibility has not been enabled.
     # We do allow, however, one to force Orca to run via the



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