[kupfer] data: Split directory source creation
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] data: Split directory source creation
- Date: Wed, 25 Nov 2009 00:01:02 +0000 (UTC)
commit 98760809ce2c972de5b5414359064407072e7455
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Nov 25 00:23:37 2009 +0100
data: Split directory source creation
Slight refactor splitting the setup_plugins function into two parts.
kupfer/data.py | 53 ++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index f45ca50..9985c22 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -818,16 +818,20 @@ class DataController (gobject.GObject, pretty.OutputMixin):
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)
+ def _get_directory_sources(self):
+ """
+ Return a tuple of S_sources, s_sources for
+ directory sources directly included and for
+ catalog inclusion respectively
+ """
+ from kupfer import settings
s_sources = []
S_sources = []
+ setctl = settings.GetSettingsController()
+ source_config = setctl.get_config
+
def dir_source(opt):
abs = os.path.abspath(os.path.expanduser(opt))
return objects.DirectorySource(abs)
@@ -836,8 +840,30 @@ class DataController (gobject.GObject, pretty.OutputMixin):
abs = os.path.abspath(os.path.expanduser(opt))
return objects.FileSource((abs,), depth)
+ 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))
+
+ return S_sources, s_sources
+
+ 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 = []
+
setctl = settings.GetSettingsController()
- source_config = setctl.get_config
text_sources = []
action_decorators = []
@@ -860,16 +886,9 @@ class DataController (gobject.GObject, pretty.OutputMixin):
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))
+ D_dirs, d_dirs = self._get_directory_sources()
+ S_sources.extend(D_dirs)
+ s_sources.extend(d_dirs)
if not S_sources and not s_sources:
pretty.print_info(__name__, "No sources found!")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]