예제 #1
0
    def test_get_urls(self):
        text = 'There a link in here: http://bauble.belizebotanic.org'
        urls = utils.get_urls(text)
        self.assert_(urls == [(None, 'http://bauble.belizebotanic.org')], urls)

        text = 'There a link in here: http://bauble.belizebotanic.org '\
               'and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(urls == [(None, 'http://bauble.belizebotanic.org')], urls)

        text = 'There is a link here: http://bauble.belizebotanic.org '\
               'and here: https://belizebotanic.org and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(urls == [(None, 'http://bauble.belizebotanic.org'),
                              (None, 'https://belizebotanic.org')], urls)

        text = 'There a labeled link in here: '\
               '[BBG]http://bauble.belizebotanic.org and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(urls == [('BBG', 'http://bauble.belizebotanic.org')],
                     urls)
예제 #2
0
    def test_get_urls(self):
        text = 'There a link in here: http://bauble.belizebotanic.org'
        urls = utils.get_urls(text)
        self.assert_(urls == [(None, 'http://bauble.belizebotanic.org')], urls)

        text = 'There a link in here: http://bauble.belizebotanic.org '\
               'and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(urls == [(None, 'http://bauble.belizebotanic.org')], urls)

        text = 'There is a link here: http://bauble.belizebotanic.org '\
               'and here: https://belizebotanic.org and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(
            urls == [(None, 'http://bauble.belizebotanic.org'),
                     (None, 'https://belizebotanic.org')], urls)

        text = 'There a labeled link in here: '\
               '[BBG]http://bauble.belizebotanic.org and some text afterwards.'
        urls = utils.get_urls(text)
        self.assert_(urls == [('BBG', 'http://bauble.belizebotanic.org')],
                     urls)
예제 #3
0
 def update(self, row):
     import pango
     map(self.dynamic_box.remove, self.dynamic_box.get_children())
     if self.notes:
         notes = getattr(row, self.notes)
         for note in notes:
             for label, url in utils.get_urls(note.note):
                 if not label:
                     label = url
                 label = gtk.Label(label)
                 label.set_ellipsize(pango.ELLIPSIZE_END)
                 button = gtk.LinkButton(uri=url)
                 button.add(label)
                 button.set_alignment(0, -1)
                 self.dynamic_box.pack_start(button, expand=False,fill=False)
         self.dynamic_box.show_all()
예제 #4
0
 def update(self, row):
     import pango
     map(self.dynamic_box.remove, self.dynamic_box.get_children())
     if self.notes:
         notes = getattr(row, self.notes)
         for note in notes:
             for label, url in utils.get_urls(note.note):
                 if not label:
                     label = url
                 label = gtk.Label(label)
                 label.set_ellipsize(pango.ELLIPSIZE_END)
                 button = gtk.LinkButton(uri=url)
                 button.add(label)
                 button.set_alignment(0, -1)
                 self.dynamic_box.pack_start(button,
                                             expand=False,
                                             fill=False)
         self.dynamic_box.show_all()
예제 #5
0
    def update(self, row):
        '''
        '''
        # TODO: don't really need a location expander, could just
        # use a label in the general section
        #loc = self.get_expander("Location")
        #loc.update(row.location)
        self.general.update(row)
        self.transfers.update(row)
        self.propagations.update(row)

        urls = filter(lambda x: x!=[], \
                          [utils.get_urls(note.note) for note in row.notes])
        if not urls:
            self.links.props.visible = False
            self.links._sep.props.visible = False
        else:
            self.links.props.visible = True
            self.links._sep.props.visible = True
            self.links.update(row)

        self.props.update(row)