[Clippy-commits] SF.net SVN: clippy:[11] clippy
Status: Pre-Alpha
Brought to you by:
edheldil
|
From: <edh...@us...> - 2010-03-05 10:07:38
|
Revision: 11
http://clippy.svn.sourceforge.net/clippy/?rev=11&view=rev
Author: edheldil
Date: 2010-03-05 10:07:27 +0000 (Fri, 05 Mar 2010)
Log Message:
-----------
More work on config refactoring
Modified Paths:
--------------
clippy/config.py
clippy/loader.py
clippy/repository.py
clippy/ui/assistant/app.py
clippy/ui/assistant/win_main.py
Modified: clippy/config.py
===================================================================
--- clippy/config.py 2010-01-21 22:30:46 UTC (rev 10)
+++ clippy/config.py 2010-03-05 10:07:27 UTC (rev 11)
@@ -63,7 +63,7 @@
def set (self, key, value):
# Setting unknown keys is not allowed.,keys have to be added first
# FIXME: meaningful exception?
- self.config[key]
+ #self.config[key]
self.config[key] = value
# FIXME: set key in userconfig and make it dirty
Modified: clippy/loader.py
===================================================================
--- clippy/loader.py 2010-01-21 22:30:46 UTC (rev 10)
+++ clippy/loader.py 2010-03-05 10:07:27 UTC (rev 11)
@@ -2,8 +2,13 @@
# vim: set ts=4 sw=4 expandtab:
import os.path
+import sys
+import traceback
+from clippy import config
+from clippy import repository
+
def registerRepository (id, klass):
Loader.registerRepository (id, klass)
@@ -25,6 +30,7 @@
self.loadRepositoryDefinitions (repo_dir, None)
except:
print "Skipping ", repo_dir
+ traceback.print_exc ()
pass
def importRepositoryClasses (self, dir):
@@ -44,13 +50,13 @@
# FIXME: this prevents developer to supply their
# own config class. Rather pass config class factory as an argument to this function
- config = config.Config ()
- config.read (os.path.join (dir, file))
- config = config.config # FIXME: ugly
+ cfg = config.ConfigFile ()
+ cfg.read (os.path.join (dir, file))
+ cfg = cfg.config # FIXME: ugly
- id = config['id']
+ id = cfg['id']
# FIXME: check that id is unique?
- self.registerRepository (id, None, config)
+ self.registerRepository (id, None, cfg)
#yield True
#yield False
@@ -83,7 +89,7 @@
def setupRepositoryClass (self, id):
if not id:
- print >>sys.stderr, "Skipping repo"
+ print >>sys.stderr, "Skipping repo: no id"
return None
klass, config = self.repository_map[id]
@@ -96,15 +102,16 @@
try:
klass_id = config['class']
except KeyError:
- print >>sys.stderr, "Skipping repo"
+ print >>sys.stderr, "Skipping repo: no class"
return None
klass = self.setupRepositoryClass (klass_id)
- if isinstance (Repository, klass):
+ if issubclass (klass, repository.Repository):
self.repository_map[id][0] = klass
return klass
else:
- print >>sys.stderr, "Skipping repo"
+ print "klass:", klass
+ print >>sys.stderr, "Skipping repo: klass no inst"
@@ -118,7 +125,7 @@
self.setupRepositoryConfig (id, id)
base = self.config.get ('repo.' + id + '.class')
if base:
- self.setupRepositoryConfig (app, id, base)
+ self.setupRepositoryConfig (id, base)
def getRepositories (self):
return self.repository_map
Modified: clippy/repository.py
===================================================================
--- clippy/repository.py 2010-01-21 22:30:46 UTC (rev 10)
+++ clippy/repository.py 2010-03-05 10:07:27 UTC (rev 11)
@@ -58,6 +58,11 @@
return self.config.get ('repo.' + self.id + '.' + key)
def setConfig (self, key, value):
+ # FIXME: this is ugly, because the keys are set either
+ # globally, which screws other instances of the class,
+ # or locally, which means that app.config is not
+ # universal and omniscient any more.
+ #self.objconfig.set (key, value)
self.config.set ('repo.' + self.id + '.' + key, value)
def getQueryParams (self):
Modified: clippy/ui/assistant/app.py
===================================================================
--- clippy/ui/assistant/app.py 2010-01-21 22:30:46 UTC (rev 10)
+++ clippy/ui/assistant/app.py 2010-03-05 10:07:27 UTC (rev 11)
@@ -67,7 +67,7 @@
# FIXME: maybe cli args and config should be called first
#print "Init Core"
- self.loader = loader.Loader ()
+ self.loader = loader.Loader (self.config)
self.loader.loadRepositories (utils.USER_REPO_DIR)
# Load Prepare UI for launch
@@ -137,7 +137,7 @@
def setup (self):
self.glade_file = os.path.expanduser (self.config.get ('ui.assistant.glade_file', self.GLADE_FILE))
-
+ self.loader.setupRepositories ()
#print "Loading UI"
self.wtree = gtk.glade.XML (self.glade_file)
@@ -164,7 +164,7 @@
x, y = window.get_position ()
w, h = window.get_size ()
geometry = "%dx%d+%d+%d" %(w, h, x, y)
- self.config.set ('ui.%s.geometry'%window_name, geometry)
+ self.config.set ('ui.assistant.%s.geometry'%window_name, geometry)
# FIXME: account for fullscreen
def progress_fn (self, msg, percent):
@@ -262,7 +262,7 @@
column = gtk.TreeViewColumn ("Value", text_renderer, text = 1)
tree.append_column (column)
- self.restore_geometry (self, 'win_metadata')
+ app.restore_geometry (self, 'win_metadata')
def update (self, meta):
Modified: clippy/ui/assistant/win_main.py
===================================================================
--- clippy/ui/assistant/win_main.py 2010-01-21 22:30:46 UTC (rev 10)
+++ clippy/ui/assistant/win_main.py 2010-03-05 10:07:27 UTC (rev 11)
@@ -270,7 +270,7 @@
for id in app.loader.getRepositories ():
klass, config = app.loader.getRepositoryClass (id)
if klass.getCaps () & caps_mask:
- repo = klass (id, config)
+ repo = app.loader.getRepository (id)
else:
continue
model.append ([repo])
@@ -278,6 +278,7 @@
tree.thaw_child_notify ()
tree.get_selection ().select_path (0)
tree.grab_focus ()
+ self.handle_tree_repos_cursor_changed (tree)
def update_item_list (self):
@@ -312,7 +313,7 @@
for item in items_src:
item['_origin'] = 'src'
except Exception, e:
- print "Can't get target items:", e
+ print "Can't get source items:", e
# FIXME: this part should be in core
@@ -362,6 +363,9 @@
if self.get_current_page () == self.PAGE_ITEMS:
tree = self['tree_items']
+ else:
+ # FIXME: better would be to open repo's metadata window
+ return
selection = tree.get_selection ()
model, iter = selection.get_selected ()
@@ -615,6 +619,7 @@
print "TARGETS"
if app.repo_target is None:
self.update_repo_list (self.PAGE_TARGETS)
+ print app.repo_target
elif page == self.PAGE_SOURCES:
print "SOURCES"
if app.repo_source is None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|