[kupfer] data, main: Move plugin/source initalization to DataController
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] data, main: Move plugin/source initalization to DataController
- Date: Sun, 23 Aug 2009 11:28:35 +0000 (UTC)
commit c653685e2c19aecb013ad78b6bf6b6d06b1de9bb
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Sun Aug 23 02:21:50 2009 +0200
data, main: Move plugin/source initalization to DataController
First just move the plugin init code as it is into the DataController
kupfer/data.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
kupfer/main.py | 62 +-------------------------------------------------------
2 files changed, 60 insertions(+), 61 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index e158d15..40a675a 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -761,12 +761,71 @@ class DataController (gobject.GObject, pretty.OutputMixin):
def _load(self, sched):
"""Load data from persistent store"""
+ self._setup_plugins()
sc = GetSourceController()
sc.add(self.direct_sources, toplevel=True)
sc.add(self.other_sources, toplevel=False)
self.source_pane.source_rebase(sc.root)
learn.load()
+ def _setup_plugins(self):
+ from kupfer import settings, plugins
+ from kupfer.plugins import (load_plugin_sources, sources_attribute,
+ action_decorators_attribute, text_sources_attribute,
+ content_decorators_attribute,
+ initialize_plugin)
+
+ s_sources = []
+ S_sources = []
+
+ def dir_source(opt):
+ abs = os.path.abspath(os.path.expanduser(opt))
+ return objects.DirectorySource(abs)
+
+ def file_source(opt, depth=1):
+ abs = os.path.abspath(os.path.expanduser(opt))
+ return objects.FileSource((abs,), depth)
+
+ setctl = settings.GetSettingsController()
+ source_config = setctl.get_config
+
+ text_sources = []
+ action_decorators = []
+ content_decorators = []
+
+ for item in plugins.get_plugin_ids():
+ if not setctl.get_plugin_enabled(item):
+ continue
+ initialize_plugin(item)
+ text_sources.extend(load_plugin_sources(item, text_sources_attribute))
+ action_decorators.extend(load_plugin_sources(item,
+ action_decorators_attribute))
+ content_decorators.extend(load_plugin_sources(item,
+ content_decorators_attribute, instantiate=False))
+ if setctl.get_plugin_is_toplevel(item):
+ S_sources.extend(load_plugin_sources(item))
+ else:
+ s_sources.extend(load_plugin_sources(item))
+
+ dir_depth = source_config("DeepDirectories", "Depth")
+
+ for item in source_config("Directories", "Catalog"):
+ s_sources.append(dir_source(item))
+ for item in source_config("DeepDirectories","Catalog"):
+ s_sources.append(file_source(item, dir_depth))
+ for item in source_config("Directories", "Direct"):
+ S_sources.append(dir_source(item))
+ for item in source_config("DeepDirectories", "Direct"):
+ S_sources.append(file_source(item, dir_depth))
+
+ if not S_sources and not s_sources:
+ pretty.print_info(__name__, "No sources found!")
+
+ self.set_sources(S_sources, s_sources)
+ self.register_text_sources(text_sources)
+ self.register_action_decorators(action_decorators)
+ self.register_content_decorators(content_decorators)
+
def _finish(self, sched):
self.output_info("Saving data...")
learn.finish()
diff --git a/kupfer/main.py b/kupfer/main.py
index c82bfe5..4c3944b 100644
--- a/kupfer/main.py
+++ b/kupfer/main.py
@@ -125,73 +125,13 @@ def print_banner():
print banner.encode("ascii", "replace")
def main():
- import sys
- from os import path
-
- from . import browser, data
- from . import objects, plugin
- from . import pretty, plugins, settings
- from .plugins import (load_plugin_sources, sources_attribute,
- action_decorators_attribute, text_sources_attribute,
- content_decorators_attribute,
- initialize_plugin)
+ from . import browser, pretty
cli_opts = get_options()
print_banner()
if _debug:
pretty.debug = _debug
- s_sources = []
- S_sources = []
-
- def dir_source(opt):
- abs = path.abspath(path.expanduser(opt))
- return objects.DirectorySource(abs)
-
- def file_source(opt, depth=1):
- abs = path.abspath(path.expanduser(opt))
- return objects.FileSource((abs,), depth)
-
- setctl = settings.GetSettingsController()
- source_config = setctl.get_config
-
- text_sources = []
- action_decorators = []
- content_decorators = []
-
- for item in plugins.get_plugin_ids():
- if not setctl.get_plugin_enabled(item):
- continue
- initialize_plugin(item)
- text_sources.extend(load_plugin_sources(item, text_sources_attribute))
- action_decorators.extend(load_plugin_sources(item,
- action_decorators_attribute))
- content_decorators.extend(load_plugin_sources(item,
- content_decorators_attribute, instantiate=False))
- if setctl.get_plugin_is_toplevel(item):
- S_sources.extend(load_plugin_sources(item))
- else:
- s_sources.extend(load_plugin_sources(item))
-
- dir_depth = source_config("DeepDirectories", "Depth")
-
- for item in source_config("Directories", "Catalog"):
- s_sources.append(dir_source(item))
- for item in source_config("DeepDirectories","Catalog"):
- s_sources.append(file_source(item, dir_depth))
- for item in source_config("Directories", "Direct"):
- S_sources.append(dir_source(item))
- for item in source_config("DeepDirectories", "Direct"):
- S_sources.append(file_source(item, dir_depth))
-
- if not S_sources and not s_sources:
- print pretty.print_info(__name__, "No sources found!")
-
- dc = data.GetDataController()
- dc.set_sources(S_sources, s_sources)
- dc.register_text_sources(text_sources)
- dc.register_action_decorators(action_decorators)
- dc.register_content_decorators(content_decorators)
w = browser.WindowController()
quiet = ("--no-splash" in cli_opts)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]