|
39 | 39 |
|
40 | 40 | LOG = logging.getLogger(".")
|
41 | 41 |
|
42 |
| -from gi.repository import GLib |
43 |
| - |
44 | 42 | # -------------------------------------------------------------------------
|
45 | 43 | #
|
46 | 44 | # Gramps modules
|
|
97 | 95 | # Determine the user data and user configuration directories.
|
98 | 96 | #
|
99 | 97 | # -------------------------------------------------------------------------
|
100 |
| -if "GRAMPSHOME" in os.environ: |
101 |
| - USER_HOME = get_env_var("GRAMPSHOME") |
| 98 | +if "GRAMPSHOME_ISOLATED" in os.environ: |
| 99 | + USER_HOME = get_env_var("GRAMPSHOME_ISOLATED") |
102 | 100 | USER_DATA = os.path.join(USER_HOME, "gramps")
|
103 |
| - USER_CONFIG = USER_DATA |
104 |
| -elif "USERPROFILE" in os.environ: |
105 |
| - USER_HOME = get_env_var("USERPROFILE") |
106 |
| - if "APPDATA" in os.environ: |
107 |
| - USER_DATA = os.path.join(get_env_var("APPDATA"), "gramps") |
108 |
| - else: |
109 |
| - USER_DATA = os.path.join(USER_HOME, "AppData", "Roaming", "gramps") |
110 |
| - USER_CONFIG = USER_DATA |
111 |
| - # Migrate data from AppData\Local to AppData\Roaming on Windows. |
112 |
| - OLD_HOME = os.path.join(USER_HOME, "AppData", "Local", "gramps") |
113 |
| - if os.path.exists(OLD_HOME): |
114 |
| - if os.path.exists(USER_DATA): |
115 |
| - LOG.warning("Two Gramps application data directories exist.") |
116 |
| - else: |
117 |
| - shutil.move(OLD_HOME, USER_DATA) |
| 101 | + USER_CONFIG = os.path.join(USER_DATA, "config") |
| 102 | + USER_CACHE = os.path.join(USER_DATA, "cache") |
| 103 | + USER_PICTURES = os.path.join(USER_DATA, "pictures") |
118 | 104 | else:
|
119 |
| - USER_HOME = get_env_var("HOME") |
120 |
| - USER_DATA = os.path.join(GLib.get_user_data_dir(), "gramps") |
121 |
| - USER_CONFIG = os.path.join(GLib.get_user_config_dir(), "gramps") |
122 |
| - # Copy the database directory into the XDG directory. |
123 |
| - OLD_HOME = os.path.join(USER_HOME, ".gramps") |
124 |
| - if os.path.exists(OLD_HOME): |
125 |
| - if os.path.exists(USER_DATA) or os.path.exists(USER_CONFIG): |
126 |
| - LOG.warning("Two Gramps application data directories exist.") |
| 105 | + from gi.repository import GLib |
| 106 | + |
| 107 | + if "GRAMPSHOME" in os.environ: |
| 108 | + USER_HOME = get_env_var("GRAMPSHOME") |
| 109 | + USER_DATA = os.path.join(USER_HOME, "gramps") |
| 110 | + USER_CONFIG = USER_DATA |
| 111 | + elif "USERPROFILE" in os.environ: |
| 112 | + USER_HOME = get_env_var("USERPROFILE") |
| 113 | + if "APPDATA" in os.environ: |
| 114 | + USER_DATA = os.path.join(get_env_var("APPDATA"), "gramps") |
127 | 115 | else:
|
128 |
| - db_dir = os.path.join(OLD_HOME, "grampsdb") |
129 |
| - if os.path.exists(db_dir): |
130 |
| - shutil.copytree(db_dir, os.path.join(USER_DATA, "grampsdb")) |
131 |
| - |
132 |
| -USER_CACHE = os.path.join(GLib.get_user_cache_dir(), "gramps") |
133 |
| - |
134 |
| -if "SAFEMODE" in os.environ: |
135 |
| - USER_CONFIG = get_env_var("SAFEMODE") |
136 |
| - |
137 |
| -USER_PICTURES = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) |
138 |
| -if not USER_PICTURES: |
139 |
| - USER_PICTURES = USER_DATA |
| 116 | + USER_DATA = os.path.join(USER_HOME, "AppData", "Roaming", "gramps") |
| 117 | + USER_CONFIG = USER_DATA |
| 118 | + # Migrate data from AppData\Local to AppData\Roaming on Windows. |
| 119 | + OLD_HOME = os.path.join(USER_HOME, "AppData", "Local", "gramps") |
| 120 | + if os.path.exists(OLD_HOME): |
| 121 | + if os.path.exists(USER_DATA): |
| 122 | + LOG.warning("Two Gramps application data directories exist.") |
| 123 | + else: |
| 124 | + shutil.move(OLD_HOME, USER_DATA) |
| 125 | + else: |
| 126 | + USER_HOME = get_env_var("HOME") |
| 127 | + USER_DATA = os.path.join(GLib.get_user_data_dir(), "gramps") |
| 128 | + USER_CONFIG = os.path.join(GLib.get_user_config_dir(), "gramps") |
| 129 | + # Copy the database directory into the XDG directory. |
| 130 | + OLD_HOME = os.path.join(USER_HOME, ".gramps") |
| 131 | + if os.path.exists(OLD_HOME): |
| 132 | + if os.path.exists(USER_DATA) or os.path.exists(USER_CONFIG): |
| 133 | + LOG.warning("Two Gramps application data directories exist.") |
| 134 | + else: |
| 135 | + db_dir = os.path.join(OLD_HOME, "grampsdb") |
| 136 | + if os.path.exists(db_dir): |
| 137 | + shutil.copytree(db_dir, os.path.join(USER_DATA, "grampsdb")) |
| 138 | + |
| 139 | + USER_CACHE = os.path.join(GLib.get_user_cache_dir(), "gramps") |
| 140 | + |
| 141 | + if "SAFEMODE" in os.environ: |
| 142 | + USER_CONFIG = get_env_var("SAFEMODE") |
| 143 | + |
| 144 | + USER_PICTURES = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) |
| 145 | + if not USER_PICTURES: |
| 146 | + USER_PICTURES = USER_DATA |
140 | 147 |
|
141 | 148 | VERSION_DIR_NAME = "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])
|
142 | 149 | VERSION_DIR = os.path.join(USER_CONFIG, VERSION_DIR_NAME)
|
|
0 commit comments