(self, urlmatch)
return url
Prepare a URL from a VTE match
Prepare a URL from a VTE match
Prepare a URL from a VTE match
def prepare_url(self, urlmatch):
        """Prepare a URL from a VTE match"""
        url = urlmatch[0]
        match = urlmatch[1]

        if match == self.matches['addr_only'] and url[0:3] == 'ftp':
            url = 'ftp://' + url
        elif match == self.matches['addr_only']:
            url = 'http://' + url
        elif match in list(self.matches.values()):
            # We have a match, but it's not a hard coded one, so it's a plugin
            try:
                registry = plugin.PluginRegistry()
                registry.load_plugins()
                plugins = registry.get_plugins_by_capability('url_handler')
                dbg("URL handler plugins: {}".format(plugins))

                for urlplugin in plugins:
                    if match == self.matches[urlplugin.handler_name]:
                        newurl = urlplugin.callback(url)
                        if newurl: # If the plugin returns None, it's a false match.
                            dbg('URL prepared by %s plugin' \
                                    % urlplugin.handler_name)
                            url = newurl
                        break
            except Exception as ex:
                err('Exception occurred preparing URL: %s, %s' % (type(ex).__name__, ex))

        return url
def prepare_url ( self , urlmatch ) : url = urlmatch [ 0 ] match = urlmatch [ 1 ] if match == self . matches [ 'addr_only' ] and url [ 0 : 3 ] == 'ftp' : url = 'ftp://' + url elif match == self . matches [ 'addr_only' ] : url = 'http://' + url elif match in list ( self . matches . values ( ) ) : # We have a match, but it's not a hard coded one, so it's a plugin try : registry = plugin . PluginRegistry ( ) registry . load_plugins ( ) plugins = registry . get_plugins_by_capability ( 'url_handler' ) dbg ( "URL handler plugins: {}" . format ( plugins ) ) for urlplugin in plugins : if match == self . matches [ urlplugin . handler_name ] : newurl = urlplugin . callback ( url ) if newurl : # If the plugin returns None, it's a false match. dbg ( 'URL prepared by %s plugin' % urlplugin . handler_name ) url = newurl break except Exception as ex : err ( 'Exception occurred preparing URL: %s, %s' % ( type ( ex ) . __name__ , ex ) ) return url