autosearch bugfix and debug output

This commit is contained in:
Florian Bruhin 2014-02-18 12:02:07 +01:00
parent 27d354633c
commit bbab0e7430
2 changed files with 6 additions and 2 deletions

View File

@ -29,7 +29,7 @@ show_completion = true
ignorecase = true ignorecase = true
wrapsearch = true wrapsearch = true
startpage = http://www.duckduckgo.com/ startpage = http://www.duckduckgo.com/
auto_search = fuzzy auto_search = naive
[tabbar] [tabbar]
# movable: bool, whether tabs should be movable # movable: bool, whether tabs should be movable

View File

@ -93,7 +93,6 @@ def is_about_url(url):
def is_url(url): def is_url(url):
"""Return True if url (QUrl) seems to be a valid URL.""" """Return True if url (QUrl) seems to be a valid URL."""
urlstr = urlstring(url) urlstr = urlstring(url)
logging.debug('Checking if "{}" is an URL'.format(urlstr))
try: try:
autosearch = config.config.getboolean('general', 'auto_search') autosearch = config.config.getboolean('general', 'auto_search')
@ -105,6 +104,9 @@ def is_url(url):
else: else:
autosearch = None autosearch = None
logging.debug('Checking if "{}" is an URL (autosearch={}).'.format(
urlstr, autosearch))
if autosearch is None: if autosearch is None:
# no autosearch, so everything is an URL. # no autosearch, so everything is an URL.
return True return True
@ -123,6 +125,8 @@ def is_url(url):
elif autosearch == 'naive': elif autosearch == 'naive':
logging.debug('Checking via naive check') logging.debug('Checking via naive check')
return _is_url_naive(url) return _is_url_naive(url)
else:
raise ValueError("Invalid autosearch value")
def _is_url_naive(url): def _is_url_naive(url):