[kupfer] plugin.{chromium, zim}: Don't hardcode ~/.config, use config.get_config_path
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugin.{chromium, zim}: Don't hardcode ~/.config, use config.get_config_path
- Date: Sat, 31 Oct 2009 16:02:50 +0000 (UTC)
commit ad516a7389282ddf317de8a7052a741bfc7e3527
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sat Oct 31 16:50:52 2009 +0100
plugin.{chromium,zim}: Don't hardcode ~/.config, use config.get_config_path
Hardcoding ~/.config as the configuration directory defeats the point
of the XDG_CONFIG_HOME and related configuration variables.
kupfer/plugin/chromium.py | 5 ++---
kupfer/plugin/chromium_support.py | 9 +--------
kupfer/plugin/zim.py | 9 ++++++---
3 files changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/kupfer/plugin/chromium.py b/kupfer/plugin/chromium.py
index a75a0b5..2854978 100644
--- a/kupfer/plugin/chromium.py
+++ b/kupfer/plugin/chromium.py
@@ -2,7 +2,7 @@ import os
from kupfer.objects import Leaf, Action, Source, AppLeafContentMixin
from kupfer.objects import UrlLeaf
-from kupfer import plugin_support
+from kupfer import config, plugin_support
__kupfer_name__ = _("Chromium Bookmarks")
__kupfer_sources__ = ("BookmarksSource", )
@@ -28,8 +28,7 @@ class BookmarksSource (AppLeafContentMixin, Source):
yield UrlLeaf(book["url"], book["name"])
def get_items(self):
- from chromium_support import get_chromium_home_file
- fpath = get_chromium_home_file("Bookmarks")
+ fpath = config.get_config_file("Bookmarks", package="chromium/Default")
if fpath:
try:
return self._get_chromium_items(fpath)
diff --git a/kupfer/plugin/chromium_support.py b/kupfer/plugin/chromium_support.py
index 3c5dc68..09676b9 100644
--- a/kupfer/plugin/chromium_support.py
+++ b/kupfer/plugin/chromium_support.py
@@ -11,13 +11,6 @@ except ImportError:
import json
json_decoder = json.loads
-def get_chromium_home_file(needed_file):
- chromium_dir = os.path.expanduser("~/.config/chromium/Default/")
- if not os.path.exists(chromium_dir):
- return None
-
- return os.path.join(chromium_dir, needed_file)
-
def get_bookmarks(bookmarks_file):
# construct and configure the parser
if not bookmarks_file:
@@ -59,5 +52,5 @@ def get_bookmarks(bookmarks_file):
return bmap.values()
if __name__ == "__main__":
- fpath = get_chromium_home_file("Bookmarks")
+ fpath = os.path.expanduser("~/.config/chromium/Default/")
print "Parsed # bookmarks:", len(list(get_bookmarks(fpath)))
diff --git a/kupfer/plugin/zim.py b/kupfer/plugin/zim.py
index aa3569f..6a940f5 100644
--- a/kupfer/plugin/zim.py
+++ b/kupfer/plugin/zim.py
@@ -7,7 +7,7 @@ import glib
from kupfer.objects import (Leaf, Action, Source, TextLeaf,
FilesystemWatchMixin, TextSource, AppLeafContentMixin)
-from kupfer import utils, pretty, icons, plugin_support
+from kupfer import config, utils, pretty, icons, plugin_support
__kupfer_name__ = _("Zim")
__kupfer_sources__ = ("ZimPagesSource", )
@@ -144,7 +144,10 @@ def _get_zim_notebooks():
@notebook_path: Filesystem byte string
'''
# We assume the notebook description is UTF-8 encoded
- zim_notebooks_file = os.path.expanduser('~/.config/zim/notebooks.list')
+ zim_notebooks_file = config.get_config_file("notebooks.list", package="zim")
+ if not zim_notebooks_file:
+ pretty.print_error(__name__, "Zim notebooks.list not found")
+ return
try:
with open(zim_notebooks_file, 'r') as noteboks_file:
for line in noteboks_file.readlines():
@@ -155,7 +158,7 @@ def _get_zim_notebooks():
yield (notebook_name, notebook_path)
except IOError, err:
- pretty.print_error(err)
+ pretty.print_error(__name__, err)
class ZimNotebook (Leaf):
def get_gicon(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]