summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-01-15 19:15:08 +0100
committerGitHub <noreply@github.com>2018-01-15 19:15:08 +0100
commit8fd6a2ff77b4a4897ed6c824a4b7dfd2eb6b8202 (patch)
treea00f1cb609de30e2294071e11858a65f2877d060
parentaf163eca098ac52609b1727a6a39ed8d77aab352 (diff)
parent9363bc3f24f0fd330afa7f94e956f2c9056996f1 (diff)
downloadqutebrowser-8fd6a2ff77b4a4897ed6c824a4b7dfd2eb6b8202.tar.gz
qutebrowser-8fd6a2ff77b4a4897ed6c824a4b7dfd2eb6b8202.zip
Merge pull request #3445 from seelaman/hist_import-cleaning
filter out records with None in any field.
-rwxr-xr-xscripts/hist_importer.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/scripts/hist_importer.py b/scripts/hist_importer.py
index 84fada560..7b594a580 100755
--- a/scripts/hist_importer.py
+++ b/scripts/hist_importer.py
@@ -100,16 +100,23 @@ def clean(history):
"""Clean up records from source database.
Receives a list of record and sanityze them in order for them to be
- properly imported to qutebrowser. Sanitation requires addiing a 4th
+ properly imported to qutebrowser. Sanitation requires adding a 4th
attribute 'redirect' which is filled with '0's, and also purging all
records that have a NULL/None datetime attribute.
Args:
history: List of records (datetime, url, title) from source database.
"""
- nulls = [record for record in history if record[0] is None]
- for null_datetime in nulls:
- history.remove(null_datetime)
+ # replace missing titles with an empty string
+ for index, record in enumerate(history):
+ if record[1] is None:
+ cleaned = list(record)
+ cleaned[1] = ''
+ history[index] = tuple(cleaned)
+
+ nulls = [record for record in history if None in record]
+ for null_record in nulls:
+ history.remove(null_record)
history = [list(record) for record in history]
for record in history:
record.append('0')