Style/misc fixes.
This commit is contained in:
parent
76bf8c0049
commit
c223f6c69d
@ -169,7 +169,7 @@ def qute_history(url):
|
|||||||
def history_iter(start_time, reverse=False):
|
def history_iter(start_time, reverse=False):
|
||||||
"""Iterate through the history and get items we're interested.
|
"""Iterate through the history and get items we're interested.
|
||||||
|
|
||||||
Keyword arguments:
|
Arguments:
|
||||||
reverse -- whether to reverse the history_dict before iterating.
|
reverse -- whether to reverse the history_dict before iterating.
|
||||||
start_time -- select history starting from this timestamp.
|
start_time -- select history starting from this timestamp.
|
||||||
"""
|
"""
|
||||||
@ -177,12 +177,12 @@ def qute_history(url):
|
|||||||
if reverse:
|
if reverse:
|
||||||
history = reversed(history)
|
history = reversed(history)
|
||||||
|
|
||||||
end_time = start_time - 86400.0 # end is 24hrs earlier than start
|
end_time = start_time - 24*60*60 # end is 24hrs earlier than start
|
||||||
|
|
||||||
for item in history:
|
for item in history:
|
||||||
# Abort/continue as early as possible
|
# Abort/continue as early as possible
|
||||||
item_newer = item.atime > start_time
|
item_newer = item.atime > start_time
|
||||||
item_older = item.atime < end_time
|
item_older = item.atime <= end_time
|
||||||
if reverse:
|
if reverse:
|
||||||
# history_dict is reversed, we are going back in history.
|
# history_dict is reversed, we are going back in history.
|
||||||
# so:
|
# so:
|
||||||
@ -202,12 +202,9 @@ def qute_history(url):
|
|||||||
if item_newer:
|
if item_newer:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Skip items not within start_time and end_time
|
|
||||||
# Skip redirects
|
# Skip redirects
|
||||||
# Skip qute:// links
|
# Skip qute:// links
|
||||||
is_in_window = item.atime > end_time and item.atime <= start_time
|
if item.redirect or item.url.scheme() == 'qute':
|
||||||
is_internal = item.url.scheme() == 'qute'
|
|
||||||
if item.redirect or is_internal or not is_in_window:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Use item's url as title if there's no title.
|
# Use item's url as title if there's no title.
|
||||||
@ -217,7 +214,7 @@ def qute_history(url):
|
|||||||
|
|
||||||
yield {"url": item_url, "title": item_title, "time": item_time}
|
yield {"url": item_url, "title": item_title, "time": item_time}
|
||||||
|
|
||||||
if QUrl(url).path() == '/data':
|
if url.path() == '/data':
|
||||||
# Use start_time in query or current time.
|
# Use start_time in query or current time.
|
||||||
start_time = QUrlQuery(url).queryItemValue("start_time")
|
start_time = QUrlQuery(url).queryItemValue("start_time")
|
||||||
start_time = float(start_time) if start_time else time.time()
|
start_time = float(start_time) if start_time else time.time()
|
||||||
|
@ -92,4 +92,4 @@ class TestHistoryHandler:
|
|||||||
fake_web_history._add_entry(entry)
|
fake_web_history._add_entry(entry)
|
||||||
|
|
||||||
url = QUrl("qute://history/data?start_time={}".format(self.now))
|
url = QUrl("qute://history/data?start_time={}".format(self.now))
|
||||||
_mimetype, data = benchmark(qutescheme.qute_history, url)
|
_mimetype, _data = benchmark(qutescheme.qute_history, url)
|
||||||
|
Loading…
Reference in New Issue
Block a user