From ef90b2bade453f13385b034cec75afe7b08aa464 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 19 May 2003 13:55:34 +0000 Subject: [PATCH] Removed all the MD5 suck checking stuff. More status messages. git-svn-id: http://dom-editor.googlecode.com/svn/branches/Gtk2@493 ef21e15d-ca94-4315-9c45-0d95b1b2e117 --- Dome/GetArg.py | 1 - Dome/List.py | 10 ++++- Dome/Model.py | 6 ++- Dome/Namespaces.py | 2 +- Dome/Program.py | 5 +-- Dome/View.py | 110 +++++++++++++++++------------------------------------ 6 files changed, 50 insertions(+), 84 deletions(-) diff --git a/Dome/GetArg.py b/Dome/GetArg.py index 72a98fd..2ce8463 100644 --- a/Dome/GetArg.py +++ b/Dome/GetArg.py @@ -54,7 +54,6 @@ class GetArg(g.Dialog): self.add_button(g.STOCK_OK, g.RESPONSE_OK) def resp(widget, resp): - print "Rest", resp if resp == g.RESPONSE_OK: self.do_it() widget.destroy() diff --git a/Dome/List.py b/Dome/List.py index 5691904..29425f6 100644 --- a/Dome/List.py +++ b/Dome/List.py @@ -614,10 +614,16 @@ class ChainDisplay(g.EventBox): size = 6 x += 2 colour = 'yellow' + y = obj.y + if exit == 'fail': + x += 4 + y += 4 + else: + y += 5 pen = self.style.white_gc pen.set_rgb_fg_color(g.gdk.color_parse(colour)) - w.draw_rectangle(self.style.black_gc, False, x, obj.y + 5, size, size) - w.draw_rectangle(pen, True, x + 1, obj.y + 5 + 1, size - 1, size - 1) + w.draw_rectangle(self.style.black_gc, False, x, y, size, size) + w.draw_rectangle(pen, True, x + 1, y + 1, size - 1, size - 1) pen.set_rgb_fg_color(g.gdk.color_parse('white')) def destroyed(self, widget): diff --git a/Dome/Model.py b/Dome/Model.py index 2e9a620..34ac63a 100644 --- a/Dome/Model.py +++ b/Dome/Model.py @@ -39,7 +39,11 @@ class Model: if not doc and not root_program: from Ft.Xml.InputSource import InputSourceFactory isrc = InputSourceFactory() - doc = nonvalParse(isrc.fromUri(path)) + try: + doc = nonvalParse(isrc.fromUri(path)) + except: + import rox + rox.report_exception() if not doc: doc = implementation.createDocument(None, 'root', None) root = doc.documentElement diff --git a/Dome/Namespaces.py b/Dome/Namespaces.py index 23d9240..51763c3 100644 --- a/Dome/Namespaces.py +++ b/Dome/Namespaces.py @@ -97,7 +97,7 @@ class Namespaces(g.GenericTreeModel): while suggested_prefix + `x` in self.uri: x += 1 suggested_prefix += `x` self[suggested_prefix] = uri - print "Added", suggested_prefix, uri + #print "Added", suggested_prefix, uri return suggested_prefix def to_xml(self, doc): diff --git a/Dome/Program.py b/Dome/Program.py index dad8de3..c4799a8 100644 --- a/Dome/Program.py +++ b/Dome/Program.py @@ -51,10 +51,9 @@ def load(node, parent, ns): action[0] = 'map' elif action[0] == 'add_attrib': action[1] = "UNUSED" - elif action[0] == 'do_search' and len(action) > 2 and \ - action[2] != 'unused': + elif action[0] == 'do_search' and type(action[-1]) is dict: print "Converting search namespaces..." - for p, u in action[2].iteritems(): + for p, u in action[-1].iteritems(): print "Convert", p, u old = p if p.startswith('_'): p = None diff --git a/Dome/View.py b/Dome/View.py index c1b12fa..684c438 100644 --- a/Dome/View.py +++ b/Dome/View.py @@ -1298,86 +1298,44 @@ class View: """Load the resource specified by request and replace 'node' with the sucked data.""" uri = request.get_full_url() - if uri.startswith('file:///'): - print "Loading", uri - - assert not request.has_data() - stream = open(uri[7:]) - # (could read the mod time here...) - last_mod = None - else: - print "Sucking", uri - - if request.has_data(): - print "POSTING", request.get_data() - stream = urllib2.urlopen(request) - headers = stream.info().headers - last_mod = None - for x in headers: - if x.lower().startswith('last-modified:'): - last_mod = x[14:].strip() - break - - current_last_mod = node.getAttributeNS(None, 'last-modified') - if current_last_mod and last_mod: - if current_last_mod == last_mod: - self.model.set_attrib(node, 'modified', None) - print "not modified => not sucking!\n" - return node - - print "Fetching page contents..." - data = stream.read() - print "got data... tidying..." - - if data.startswith(' not parsing!" - return node - - if md5_only: - # This is a nasty hack left in for backwards compat. - self.model.set_attrib(node, 'md5_sum', new_md5) - return node - - print "parsing...", - + self.set_status("Fetching %s (connecting)..." % uri) try: - root = support.parse_data(data, uri) - except: - raise Beep - - new = self.model.import_with_ns(root.documentElement) - new.setAttributeNS(None, 'uri', uri) + if uri.startswith('file:///'): + assert not request.has_data() + stream = open(uri[7:]) + else: + if request.has_data(): print "POSTING", request.get_data() + stream = urllib2.urlopen(request) + headers = stream.info().headers + + self.set_status("Fetching %s (downloading)..." % uri) + data = stream.read() + self.set_status("Fetching %s (parsing)..." % uri) - if last_mod: - new.setAttributeNS(None, 'last-modified', last_mod) - new.setAttributeNS(None, 'modified', 'yes') - new.setAttributeNS(None, 'md5_sum', new_md5) + if not data.startswith('