[kupfer] Create kupfer.core subpackage for Kupfer's internals



commit 4a2ed6d0f0b1c3ff9e9589d7405741c1b8ebd822
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Jan 7 17:25:02 2010 +0100

    Create kupfer.core subpackage for Kupfer's internals
    
    The kupfer.core subpackage contains most of the machine of Kupfer's
    data model (except the objects themselves).
    
    The kupfer.core subpackage should normally not be used by plugins at
    all.

 kupfer/browser.py               |    9 +++++----
 kupfer/{ => core}/data.py       |   15 +++++++--------
 kupfer/{ => core}/learn.py      |    4 ++--
 kupfer/{ => core}/plugins.py    |    3 ++-
 kupfer/{ => core}/qfurl.py      |    0
 kupfer/{ => core}/relevance.py  |    0
 kupfer/{ => core}/search.py     |    8 ++++----
 kupfer/{ => core}/settings.py   |    0
 kupfer/plugin/core/debug.py     |    9 +++++----
 kupfer/plugin/favorites.py      |    4 +++-
 kupfer/plugin/kupfer_plugins.py |    2 +-
 kupfer/plugin_support.py        |    3 ++-
 kupfer/preferences.py           |    3 ++-
 kupfer/puid.py                  |    3 +--
 14 files changed, 34 insertions(+), 29 deletions(-)
---
diff --git a/kupfer/browser.py b/kupfer/browser.py
index ece9740..a370e5b 100644
--- a/kupfer/browser.py
+++ b/kupfer/browser.py
@@ -12,11 +12,12 @@ import gtk
 import gio
 import gobject
 
-from kupfer import data, icons, scheduler, relevance
+from kupfer import listen, scheduler
+from kupfer.core import data, relevance, learn
+from kupfer import icons
 from kupfer import interface
 from kupfer import keybindings
 from kupfer import pretty
-from kupfer import learn
 
 
 _escape_table = {
@@ -1483,7 +1484,8 @@ class WindowController (pretty.OutputMixin):
 		callbacks etc).
 		"""
 		import signal
-		from kupfer import session, settings
+		from kupfer import session
+		from kupfer.core import settings
 
 		self.output_debug("in lazy_setup")
 
@@ -1518,7 +1520,6 @@ class WindowController (pretty.OutputMixin):
 
 	def main(self, quiet=False):
 		"""Start WindowController, present its window (if not @quiet)"""
-		from kupfer import listen, scheduler
 
 		try:
 			kserv = listen.Service()
diff --git a/kupfer/data.py b/kupfer/core/data.py
similarity index 99%
rename from kupfer/data.py
rename to kupfer/core/data.py
index 98cbf4d..1049e2b 100644
--- a/kupfer/data.py
+++ b/kupfer/core/data.py
@@ -10,13 +10,13 @@ import operator
 import gobject
 gobject.threads_init()
 
-from . import objects
-from . import search, learn
-from . import config, pretty, scheduler, task
+from kupfer import objects
+from kupfer import config, pretty, scheduler, task
 from kupfer import commandexec
 from kupfer import datatools
-
-from kupfer import qfurl
+from kupfer.core import search, learn
+from kupfer.core import settings
+from kupfer.core import qfurl
 
 # "Enums"
 # Which pane
@@ -819,7 +819,6 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		directory sources directly included and for
 		catalog inclusion respectively
 		"""
-		from kupfer import settings
 
 		s_sources = []
 		S_sources = []
@@ -852,8 +851,8 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		@S_sources are to be included directly in the catalog,
 		@s_souces as just as subitems
 		"""
-		from kupfer import settings, plugins
-		from kupfer.plugins import (load_plugin_sources, sources_attribute,
+		from kupfer.core import plugins
+		from kupfer.core.plugins import (load_plugin_sources, sources_attribute,
 				action_decorators_attribute, text_sources_attribute,
 				content_decorators_attribute,
 				initialize_plugin)
diff --git a/kupfer/learn.py b/kupfer/core/learn.py
similarity index 98%
rename from kupfer/learn.py
rename to kupfer/core/learn.py
index c371615..678f691 100644
--- a/kupfer/learn.py
+++ b/kupfer/core/learn.py
@@ -1,7 +1,7 @@
 import cPickle as pickle
 
-from . import pretty
-from . import config
+from kupfer import pretty
+from kupfer import config
 
 mnemonics_filename = "mnemonics.pickle"
 
diff --git a/kupfer/plugins.py b/kupfer/core/plugins.py
similarity index 99%
rename from kupfer/plugins.py
rename to kupfer/core/plugins.py
index 387891b..2baf498 100644
--- a/kupfer/plugins.py
+++ b/kupfer/core/plugins.py
@@ -1,5 +1,6 @@
 import sys
-from kupfer import pretty, config, settings
+from kupfer import pretty, config
+from kupfer.core import settings
 
 sources_attribute = "__kupfer_sources__"
 text_sources_attribute = "__kupfer_text_sources__"
diff --git a/kupfer/qfurl.py b/kupfer/core/qfurl.py
similarity index 100%
rename from kupfer/qfurl.py
rename to kupfer/core/qfurl.py
diff --git a/kupfer/relevance.py b/kupfer/core/relevance.py
similarity index 100%
rename from kupfer/relevance.py
rename to kupfer/core/relevance.py
diff --git a/kupfer/search.py b/kupfer/core/search.py
similarity index 93%
rename from kupfer/search.py
rename to kupfer/core/search.py
index 065a229..1a93fcd 100644
--- a/kupfer/search.py
+++ b/kupfer/core/search.py
@@ -1,7 +1,6 @@
 # -*- coding: UTF-8 -*-
 
-from kupfer import learn
-from kupfer.relevance import score
+from kupfer.core import learn, relevance
 
 def make_rankables(itr, rank=0):
 	return (Rankable(unicode(obj), obj, rank) for obj in itr)
@@ -58,15 +57,16 @@ def score_objects(rankables, key):
 
 	rank is added to previous rank,
 	if not @key, then all items are returned"""
+	_score = relevance.score
 	key = key.lower()
 	for rb in rankables:
 		# Rank object
-		rank = score(rb.value, key)*100
+		rank = _score(rb.value, key)*100
 		if rank < 90:
 			for alias in rb.aliases:
 				# consider aliases and change rb.value if alias is better
 				# aliases rank lower so that value is chosen when close
-				arank = score(alias, key)*95
+				arank = _score(alias, key)*95
 				if arank > rank:
 					rank = arank
 					rb.value = alias
diff --git a/kupfer/settings.py b/kupfer/core/settings.py
similarity index 100%
rename from kupfer/settings.py
rename to kupfer/core/settings.py
diff --git a/kupfer/plugin/core/debug.py b/kupfer/plugin/core/debug.py
index 28099ea..c89bf07 100644
--- a/kupfer/plugin/core/debug.py
+++ b/kupfer/plugin/core/debug.py
@@ -10,9 +10,6 @@ from kupfer.objects import ComposedLeaf
 from kupfer import objects
 from kupfer import pretty
 
-# NOTE: Core imports
-from kupfer import learn
-
 __kupfer_sources__ = ()
 __kupfer_contents__ = (
 		"ComposedSource",
@@ -67,7 +64,8 @@ class DebugInfo (Action):
 	def activate(self, leaf):
 		import itertools
 		import StringIO
-		from kupfer import qfurl
+		# NOTE: Core imports
+		from kupfer.core import qfurl
 		from kupfer import uiutils
 		from kupfer import puid
 
@@ -150,6 +148,9 @@ class Forget (Action):
 		Action.__init__(self, u"Forget")
 
 	def activate(self, leaf):
+		# NOTE: Core imports
+		from kupfer.core import learn
+
 		# FIXME: This is a large, total, utter HACK
 		if isinstance(leaf, ComposedLeaf):
 			for o in leaf.object:
diff --git a/kupfer/plugin/favorites.py b/kupfer/plugin/favorites.py
index 4a8246f..ac308c6 100644
--- a/kupfer/plugin/favorites.py
+++ b/kupfer/plugin/favorites.py
@@ -4,7 +4,9 @@ import weakref
 from kupfer.objects import Leaf, Source, Action, PicklingHelperMixin
 from kupfer import utils, objects, pretty
 from kupfer import puid
-from kupfer import learn
+
+# NOTE: core import
+from kupfer.core import learn
 
 __kupfer_name__ = _("Favorites")
 __kupfer_sources__ = ("FavoritesSource", )
diff --git a/kupfer/plugin/kupfer_plugins.py b/kupfer/plugin/kupfer_plugins.py
index 6b00b80..6c14db5 100644
--- a/kupfer/plugin/kupfer_plugins.py
+++ b/kupfer/plugin/kupfer_plugins.py
@@ -6,7 +6,7 @@ from kupfer import kupferui
 
 # Since this is a core plugin we break some rules
 # This module is normally out of bounds for plugins
-from kupfer import plugins, settings
+from kupfer.core import plugins, settings
 
 __kupfer_name__ = _("Kupfer Plugins")
 __kupfer_sources__ = ("KupferPlugins", )
diff --git a/kupfer/plugin_support.py b/kupfer/plugin_support.py
index c82b098..794f811 100644
--- a/kupfer/plugin_support.py
+++ b/kupfer/plugin_support.py
@@ -1,4 +1,5 @@
-from kupfer import pretty, settings
+from kupfer import pretty
+from kupfer.core import settings
 
 SETTING_PREFER_CATALOG = {
 	"key" : "kupfer_toplevel",
diff --git a/kupfer/preferences.py b/kupfer/preferences.py
index 63c02ed..1f0f1b2 100644
--- a/kupfer/preferences.py
+++ b/kupfer/preferences.py
@@ -9,7 +9,8 @@ from xdg import BaseDirectory as base
 from xdg import DesktopEntry as desktop
 
 
-from kupfer import config, plugins, pretty, settings, utils, icons
+from kupfer import config, pretty, utils, icons
+from kupfer.core import settings, plugins
 from kupfer import keybindings, version
 
 class PreferencesWindowController (pretty.OutputMixin):
diff --git a/kupfer/puid.py b/kupfer/puid.py
index 0754c68..497e5c2 100644
--- a/kupfer/puid.py
+++ b/kupfer/puid.py
@@ -11,9 +11,8 @@ try:
 except ImportError:
 	import pickle
 
-from kupfer import data
+from kupfer.core import data, qfurl
 from kupfer import pretty
-from kupfer import qfurl
 
 SERIALIZABLE_ATTRIBUTE = "serilizable"
 



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