[kupfer] plugin.{chromium,firefox}_support: Fix import style



commit 9141ad304ad753361b10d7e6ffccbe912297220d
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Oct 23 12:37:31 2009 +0200

    plugin.{chromium,firefox}_support: Fix import style
    
    Fix these modules to import 'os', not individual functions. Kupfer
    contains lots of coding style errors I'm sure, but right now I'm
    considering these things:
    
    * Import modules, not functions 'from kupfer import config' or 'from
      os import path' are both okay (but watch out since 'path' is a
      common variable name as well.
    * Importing classes from modules are okay, especially from
      kupfer.helplib or kupfer.objects
    * Importing functions only makes sense if the functions are called so
      often that the namespace lookup is an issue.

 kupfer/plugin/chromium_support.py |   13 +++++++------
 kupfer/plugin/firefox_support.py  |   14 +++++++-------
 2 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/kupfer/plugin/chromium_support.py b/kupfer/plugin/chromium_support.py
index 44f5d93..3c5dc68 100644
--- a/kupfer/plugin/chromium_support.py
+++ b/kupfer/plugin/chromium_support.py
@@ -1,21 +1,22 @@
 # -*- coding: UTF-8 -*-
 
 from __future__ import with_statement
+
+import os
+
 try:
 	import cjson
 	json_decoder = cjson.decode
 except ImportError:
 	import json
 	json_decoder = json.loads
-from os.path import join, expanduser, exists, basename
 
 def get_chromium_home_file(needed_file):
-    chromium_dir = expanduser("~/.config/chromium/Default/")
-    if not exists(chromium_dir):
-        # no break
-        return None
+	chromium_dir = os.path.expanduser("~/.config/chromium/Default/")
+	if not os.path.exists(chromium_dir):
+		return None
 
-    return join(chromium_dir, needed_file)
+	return os.path.join(chromium_dir, needed_file)
 
 def get_bookmarks(bookmarks_file):
 	# construct and configure the parser
diff --git a/kupfer/plugin/firefox_support.py b/kupfer/plugin/firefox_support.py
index 62141a0..15535ca 100644
--- a/kupfer/plugin/firefox_support.py
+++ b/kupfer/plugin/firefox_support.py
@@ -8,22 +8,22 @@ http://www.kylo.net/deli.py.txt
 Modifications released under GPL v2 (or any later)
 Ulrik Sverdrup <ulrik sverdrup gmail com>
 """
+import os
 
 from ConfigParser import RawConfigParser
 from HTMLParser import HTMLParser
-from os.path import join, expanduser, exists, basename
  
 def get_firefox_home_file(needed_file):
-    for firefox_dir in (expanduser(p) for p in ("~/.mozilla/firefox-3.5/",
-        "~/.mozilla/firefox/")):
-        if exists(firefox_dir):
+    for firefox_dir in (os.path.expanduser(p) for p in
+			("~/.mozilla/firefox-3.5/", "~/.mozilla/firefox/")):
+        if os.path.exists(firefox_dir):
             break
     else:
         # no break
         return None
     # here we leak firefox_dir
     config = RawConfigParser({"Default" : 0})
-    config.read(expanduser(join(firefox_dir, "profiles.ini")))
+    config.read(os.path.join(firefox_dir, "profiles.ini"))
     path = None
 
     for section in config.sections():
@@ -37,9 +37,9 @@ def get_firefox_home_file(needed_file):
         return ""
 
     if path.startswith("/"):
-        return join(path, needed_file)
+        return os.path.join(path, needed_file)
 
-    return join(firefox_dir, path, needed_file)
+    return os.path.join(firefox_dir, path, needed_file)
 
 
 class BookmarksParser(HTMLParser):



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