[pitivi] Drop dependency on PyXDG, use GLib instead



commit 8159d2374a846a2cc1cf24131186e227f555d685
Author: Colin Walters <walters verbum org>
Date:   Wed Oct 30 18:19:45 2013 -0400

    Drop dependency on PyXDG, use GLib instead
    
    There's really no reason to depend on an external Python library when
    GLib has a perfectly good implementation already exposed via
    pygobject.
    
    Specifically I don't want to pull in pyxdg to gnome-continuous.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711184

 pitivi/check.py               |    7 -------
 pitivi/settings.py            |   20 ++++++--------------
 pitivi/timeline/previewers.py |    7 +++----
 3 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index a7c2caf..7b02b68 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -43,7 +43,6 @@ HARD_DEPS = {
     "gnonlin": "1.1.90",
     "Gst": "1.2.0",
     "Gtk": "3.8.0",
-    "xdg": None,  # "pyxdg", using static python bindings
     "numpy": None,  # using static python bindings
 
     # The following are not checked, but needed for the rest to work:
@@ -161,15 +160,9 @@ def check_hard_dependencies():
     satisfied, req, inst = _check_dependency("cairo", False)
     if not satisfied:
         missing_hard_deps["Cairo"] = (req, inst)
-    satisfied, req, inst = _check_dependency("xdg", False)
-    if not satisfied:
-        missing_hard_deps["PyXDG"] = (req, inst)
     satisfied, req, inst = _check_dependency("Gtk", True)
     if not satisfied:
         missing_hard_deps["GTK+"] = (req, inst)
-    satisfied, req, inst = _check_dependency("xdg", False)
-    if not satisfied:
-        missing_hard_deps["PyXDG"] = (req, inst)
     satisfied, req, inst = _check_dependency("numpy", False)
     if not satisfied:
         missing_hard_deps["NumPy"] = (req, inst)
diff --git a/pitivi/settings.py b/pitivi/settings.py
index ed84cc5..f6a02d4 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -21,8 +21,8 @@
 
 import os
 from ConfigParser import SafeConfigParser, ParsingError
-import xdg.BaseDirectory as xdg_dirs  # Freedesktop directories spec
 
+from gi.repository import GLib
 from pitivi.utils.signal import Signallable
 
 
@@ -86,25 +86,17 @@ def get_env_dirs(var, default):
 
 def xdg_config_home(autocreate=True):
     """Get the directory for storing the user's pitivi configuration"""
-    return get_dir(os.path.join(xdg_dirs.xdg_config_home, "pitivi"), autocreate)
+    return get_dir(os.path.join(GLib.get_user_config_dir(), "pitivi"), autocreate)
 
 
 def xdg_data_home(autocreate=True):
     """Get the directory for storing the user's data: presets, plugins, etc."""
-    return get_dir(os.path.join(xdg_dirs.xdg_data_home, "pitivi"), autocreate)
+    return get_dir(os.path.join(GLib.get_user_data_dir(), "pitivi"), autocreate)
 
 
 def xdg_cache_home(autocreate=True):
     """Get the user cache directory"""
-    return get_dir(os.path.join(xdg_dirs.xdg_cache_home, "pitivi"), autocreate)
-
-
-def xdg_data_dirs():
-    return get_env_dirs(xdg_dirs.xdg_data_dirs)
-
-
-def xdg_config_dirs():
-    return get_env_dirs(xdg_dirs.xdg_config_dirs)
+    return get_dir(os.path.join(GLib.get_user_cache_dir(), "pitivi"), autocreate)
 
 
 class ConfigError(Exception):
@@ -159,7 +151,7 @@ class GlobalSettings(Signallable):
     def _readSettingsFromConfigurationFile(self):
         # This reads the configuration from the user configuration file
         try:
-            conf_file_path = os.path.join(xdg_config_home(), "pitivi.conf")
+            conf_file_path = os.path.join(GLib.get_user_config_dir(), "pitivi.conf")
             self._config.read(conf_file_path)
         except ParsingError:
             return
@@ -217,7 +209,7 @@ class GlobalSettings(Signallable):
                 setattr(self, attrname, value)
 
     def _writeSettingsToConfigurationFile(self):
-        conf_file_path = os.path.join(xdg_config_home(), "pitivi.conf")
+        conf_file_path = os.path.join(GLib.get_user_config_dir(), "pitivi.conf")
 
         for (section, attrname, typ, key, env_var, value) in self.iterAllOptions():
             if not self._config.has_section(section):
diff --git a/pitivi/timeline/previewers.py b/pitivi/timeline/previewers.py
index 8cd55c1..889147a 100644
--- a/pitivi/timeline/previewers.py
+++ b/pitivi/timeline/previewers.py
@@ -31,11 +31,11 @@ import os
 import pickle
 import resource
 import sqlite3
-import xdg.BaseDirectory as xdg_dirs
 
 # Our C module optimizing waveforms rendering
 import renderer
 
+from pitivi.settings import xdg_cache_home
 from pitivi.utils.signal import Signallable
 from pitivi.utils.loggable import Loggable
 from pitivi.utils.timeline import Zoomable
@@ -594,8 +594,7 @@ class ThumbnailCache(Loggable):
         # TODO: replace with utils.misc.hash_file
         self._filehash = hash_file(Gst.uri_get_location(uri))
         self._filename = filename_from_uri(uri)
-        # TODO: replace with pitivi.settings.xdg_cache_home()
-        cache_dir = get_dir(os.path.join(xdg_dirs.xdg_cache_home, "pitivi"), autocreate)
+        cache_dir = get_dir(os.path.join(xdg_cache_home(), "pitivi"), autocreate)
         dbfile = os.path.join(get_dir(os.path.join(cache_dir, "thumbs")), self._filehash)
         self._db = sqlite3.connect(dbfile)
         self._cur = self._db.cursor()  # Use this for normal db operations
@@ -778,7 +777,7 @@ class AudioPreviewer(Clutter.Actor, PreviewGenerator, Zoomable, Loggable):
     def _startLevelsDiscovery(self):
         self.log('Preparing waveforms for "%s"' % filename_from_uri(self._uri))
         filename = hash_file(Gst.uri_get_location(self._uri)) + ".wave"
-        cache_dir = get_dir(os.path.join(xdg_dirs.xdg_cache_home, os.path.join("pitivi/waves")), autocreate)
+        cache_dir = get_dir(os.path.join(xdg_cache_home(), os.path.join("pitivi/waves")), autocreate)
         filename = cache_dir + "/" + filename
 
         if os.path.exists(filename):


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