From 2a7423a515181001c7a0f2c8b4f9f19c82aec95d Mon Sep 17 00:00:00 2001 From: Manuel Seelaus Date: Wed, 27 Dec 2017 18:00:02 -0700 Subject: filter out records with None in any field. --- scripts/hist_importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/hist_importer.py b/scripts/hist_importer.py index 84fada560..526a752e2 100755 --- a/scripts/hist_importer.py +++ b/scripts/hist_importer.py @@ -107,7 +107,7 @@ def clean(history): Args: history: List of records (datetime, url, title) from source database. """ - nulls = [record for record in history if record[0] is None] + nulls = [record for record in history if None in record] for null_datetime in nulls: history.remove(null_datetime) history = [list(record) for record in history] -- cgit v1.2.3-54-g00ecf From 9363bc3f24f0fd330afa7f94e956f2c9056996f1 Mon Sep 17 00:00:00 2001 From: Manuel Seelaus Date: Tue, 2 Jan 2018 20:06:29 -0700 Subject: replace empty titles with an empty string. https://github.com/qutebrowser/qutebrowser/pull/3445#issuecomment-354840724 --- scripts/hist_importer.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/hist_importer.py b/scripts/hist_importer.py index 526a752e2..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. """ + # 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_datetime in nulls: - history.remove(null_datetime) + for null_record in nulls: + history.remove(null_record) history = [list(record) for record in history] for record in history: record.append('0') -- cgit v1.2.3-54-g00ecf