def __init__(self): """ Creates a new tab widget, given the specified glade file and a list of widget names to extract to instance variables. """ # Mix the specified widgets with standard names in the # glade file by convention super(SubscriptionManagerTab, self).__init__() # self.builder = BuilderFileGui.from_file(glade_file) self.content.unparent() # In the allsubs tab, we don't show the treeview until it is populated if self.top_view is None: self.top_view = ga_Gtk.TreeView() # grid lines seem busted in rhel5, so we disable # in glade and turn on here for unbroken versions if ga_Gtk.check_version(self.MIN_GTK_MAJOR_GRID, self.MIN_GTK_MINOR_GRID, self.MIN_GTK_MICRO_GRID) is None: self.top_view.set_enable_tree_lines( ga_Gtk.TREE_VIEW_GRID_LINES_BOTH) self.store = self.get_store() self.top_view.set_model(self.store) selection = self.top_view.get_selection() selection.connect('changed', self._selection_callback)
def __init__(self): """ Creates a new tab widget, given the specified glade file and a list of widget names to extract to instance variables. """ # Mix the specified widgets with standard names in the # glade file by convention super(SubscriptionManagerTab, self).__init__() # self.builder = BuilderFileGui.from_file(glade_file) self.content.unparent() # In the allsubs tab, we don't show the treeview until it is populated if self.top_view is None: self.top_view = ga_Gtk.TreeView() # grid lines seem busted in rhel5, so we disable # in glade and turn on here for unbroken versions if ga_Gtk.check_version(self.MIN_GTK_MAJOR_GRID, self.MIN_GTK_MINOR_GRID, self.MIN_GTK_MICRO_GRID) is None: self.top_view.set_enable_tree_lines(ga_Gtk.TREE_VIEW_GRID_LINES_BOTH) self.store = self.get_store() self.top_view.set_model(self.store) selection = self.top_view.get_selection() selection.connect('changed', self._selection_callback)
class TestLinkify(unittest.TestCase): no_url = "this does not have a url" https_url = "https://www.redhat.com" http_url = "http://www.redhat.com" expected_http_url = """<a href="%s">%s</a>""" % (http_url, http_url) expected_https_url = """<a href="%s">%s</a>""" % (https_url, https_url) http_url_dash = "http://example.com/something-foo/blah_something/" expected_http_url_dash = """<a href="%s">%s</a>""" % (http_url_dash, http_url_dash) nested_space = """<small>http://www.redhat.com </small>""" nested = """<small>http://www.redhat.com</small>""" expected_nested = """<small><a href="%s">%s</a></small>""" % (http_url, http_url) expected_nested_space = """<small><a href="%s">%s</a> </small>""" % ( http_url, http_url) example_1 = """https://access.redhat.com/kb/docs/DOC-45563""" example_2 = """https://www.redhat.com/wapps/sso/rhn/lostPassword.html""" expected_example_1 = """<a href="%s">%s</a>""" % (example_1, example_1) expected_example_2 = """<a href="%s">%s</a>""" % (example_2, example_2) if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO): __test__ = False def test_no_url(self): ret = utils.linkify(self.no_url) self.assertEquals(ret, self.no_url) def test_https_url(self): ret = utils.linkify(self.https_url) self.assertEquals(ret, self.expected_https_url) def test_http_url(self): ret = utils.linkify(self.http_url) self.assertEquals(ret, self.expected_http_url) def test_http_nested_space(self): ret = utils.linkify(self.nested_space) self.assertEquals(ret, self.expected_nested_space) def test_nested(self): ret = utils.linkify(self.nested) self.assertEquals(ret, self.expected_nested) def test_dash(self): ret = utils.linkify(self.http_url_dash) self.assertEquals(ret, self.expected_http_url_dash) def test_example_1(self): ret = utils.linkify(self.example_1) self.assertEquals(ret, self.expected_example_1) def test_example_2(self): ret = utils.linkify(self.example_2) self.assertEquals(ret, self.expected_example_2)
def linkify(msg): """ Parse a string for any urls and wrap them in a hrefs, for use in a gtklabel. """ # http (non whitespace or . or # ? or () or - or / or ; url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""") if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO): return msg # dont linkify in firstboot if FIRSTBOOT: return msg def add_markup(mo): url = mo.group(0) return '<a href="%s">%s</a>' % (url, url) return url_regex.sub(add_markup, msg)
def linkify(msg): """ Parse a string for any urls and wrap them in a hrefs, for use in a gtklabel. """ # http (non whitespace or . or # ? or () or - or / or ; url_regex = re.compile("""https?://[\w\.\?\(\)\-\/]*""") if ga_Gtk.check_version(MIN_GTK_MAJOR, MIN_GTK_MINOR, MIN_GTK_MICRO): return msg # dont linkify in firstboot if FIRSTBOOT: return msg def add_markup(mo): url = mo.group(0) return '<a href="%s">%s</a>' % (url, url) return url_regex.sub(add_markup, msg)