Permalink
Browse files

Fix stupid naming and absent default handler crash

  • Loading branch information...
1 parent d98bf6a commit 2780bb9d0abbdcde31575fc7d2d3c218841865bf @themoken committed Feb 24, 2009
Showing with 17 additions and 18 deletions.
  1. +0 −5 canto/canto_html.py
  2. +5 −5 canto/cfg.py
  3. +1 −1 canto/gui.py
  4. +1 −1 canto/handlers.py
  5. +3 −3 canto/interface_draw.py
  6. +6 −2 canto/utility.py
  7. +1 −1 test/visual-tests.py
View
@@ -15,11 +15,6 @@
import htmlentitydefs
import re
-handlers = {
- "browser" : { "default" : ("firefox \"%u\"", 0, 0) },
- "image" : {}
-}
-
class CantoHTML(HTMLParser):
# Reset is used, instead of __init__ so a single
View
@@ -23,7 +23,7 @@
class Cfg:
def __init__(self, conf, log_file, feed_dir, script_dir):
self.handlers = {
- "browser" : { None : ("firefox \"%u\"", 0, 0) },
+ "link" : {},
"image" : {}
}
@@ -411,10 +411,10 @@ def parse(self, data = None):
print "Use of %s is deprecated! Use link_handler() instead." %\
attr
if attr == "browser":
- self.handlers["browser"][None] = (locals[attr], 0, 0)
+ self.handlers["link"][None] = (locals[attr], 0, 0)
elif attr == "text_browser":
- self.handlers["browser"][None] =\
- (self.handlers["browser"][None][0], 1, 0)
+ self.handlers["link"][None] =\
+ (self.handlers["link"][None][0], 1, 0)
# Wrap hooks in the exception handler
for hook in ["resize_hook","new_hook","select_hook","update_hook",\
@@ -503,7 +503,7 @@ def image_handler(self, path, **kwargs):
self.handler(self.handlers["image"], path, **kwargs)
def link_handler(self, path, **kwargs):
- self.handler(self.handlers["browser"], path, **kwargs)
+ self.handler(self.handlers["link"], path, **kwargs)
def add_tag(self, tags, **kwargs):
if "sorts" in kwargs:
View
@@ -411,7 +411,7 @@ def just_unread(self):
def goto(self) :
self.tags[self.sel.tag_idx].set_read(self.sel.idx)
self.draw_elements()
- utility.goto(("", self.sel["link"], "browser"), self.cfg)
+ utility.goto(("", self.sel["link"], "link"), self.cfg)
def help(self):
self.cfg.wait_for_pid = utility.silentfork("man canto", "", 1, 0)
View
@@ -19,7 +19,7 @@ def reset(self):
self.active = 0
self.link = ""
self.content = ""
- self.handler = "browser"
+ self.handler = "link"
def match(self, tag, attrs, open, ll):
if tag == "a":
@@ -85,7 +85,7 @@ def reader_foot(self, dict):
return [(u"%B└", u"", u"┘%C")]
def reader_link(self, idx, link):
- if link[2] == "browser":
+ if link[2] == "link":
color = u"%4"
elif link[2] == "image":
color = u"%7"
@@ -246,15 +246,15 @@ def reader(self, cfg, story, width, show_links, window):
if "enclosures" in story:
for e in story["enclosures"]:
enc_links.append((u"[%s]" % e["type"],
- e["href"], "browser"))
+ e["href"], "link"))
d = {"story" : story, "cfg" : cfg }
s = self.do_regex(s, self.reader_pre_rgx)
s,links = canto_html.convert(s)
s = self.do_regex(s, self.reader_post_rgx)
- links = [(u"main link", story["link"], "browser")] + links
+ links = [(u"main link", story["link"], "link")] + links
links += enc_links
l = s.split("\n")
View
@@ -197,8 +197,12 @@ def goto(link, cfg):
binary, text, fetch = cfg.handlers[handler][k]
break
else:
- # [None] is the default handler.
- binary, text, fetch = cfg.handlers[handler][None]
+ if None in cfg.handlers[handler]:
+ binary, text, fetch = cfg.handlers[handler][None]
+ else:
+ cfg.log("No default %s handler defined!" % handler)
+ return
+
# Escape all "s in the URL, to avoid malicious use
# of crafted feeds. Thanks to Andreas.
@@ -207,7 +207,7 @@ def runTest(self):
# Test LinkHandler
text, links = convert(u"""<a href="test">Blahblah</a>""")
- self.failUnless(links == [(u"%4Blahblah",u"test",u"browser")])
+ self.failUnless(links == [(u"%4Blahblah",u"test",u"link")])
# Test ImageHandler
text,links = convert(u"""<img src="myimage.jpg" />

0 comments on commit 2780bb9

Please sign in to comment.