summaryrefslogtreecommitdiff
path: root/scripts/hist_importer.py
diff options
context:
space:
mode:
authorJosefson Fraga <josefson@users.noreply.github.com>2017-11-17 11:48:34 -0300
committerJosefson Fraga <josefson@users.noreply.github.com>2017-11-17 11:48:34 -0300
commit3131d3d3bc8acf7ba40029ffcfe59f2454d0bfbc (patch)
tree67156fbef726f17c783bd95da715ae051a22b10d /scripts/hist_importer.py
parent96599b96846aa108698946eb7d49ad7dc33581f0 (diff)
downloadqutebrowser-3131d3d3bc8acf7ba40029ffcfe59f2454d0bfbc.tar.gz
qutebrowser-3131d3d3bc8acf7ba40029ffcfe59f2454d0bfbc.zip
Flake8 warnings pointed by travis.
Diffstat (limited to 'scripts/hist_importer.py')
-rwxr-xr-xscripts/hist_importer.py33
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/hist_importer.py b/scripts/hist_importer.py
index f27b4e267..79c723c58 100755
--- a/scripts/hist_importer.py
+++ b/scripts/hist_importer.py
@@ -73,7 +73,15 @@ def open_db(data_base):
def extract(source, query):
- """Extracts (datetime,url,title) from source database."""
+ """Get records from source database.
+
+ Args:
+ source: File path to the source database where we want to extract the
+ data from.
+ query: The query string to be executed in order to retrieve relevant
+ attributes as (datetime, url, time) from the source database according
+ to the browser chosen.
+ """
try:
conn = open_db(source)
cursor = conn.cursor()
@@ -89,10 +97,15 @@ def extract(source, query):
def clean(history):
"""Clean up records from source database.
- Receives a list of records:(datetime,url,title). And clean all records
- in place, that has a NULL/None datetime attribute. Otherwise qutebrowser
- will throw errors. Also, will add a 4th attribute of '0' for the redirect
- field in history.sqlite in qutebrowser."""
+
+ Receives a list of record and sanityze them in order for them to be
+ properly imported to qutebrowser. Sanitation requires addiing 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)
@@ -103,9 +116,13 @@ def clean(history):
def insert_qb(history, dest):
- """Insert history into dest database
- Given a list of records in history and a dest db, insert all records in
- the dest db."""
+ """Insert history into dest database.
+
+ Args:
+ history: List of records.
+ dest: File path to the destination database, where history will be
+ inserted.
+ """
conn = open_db(dest)
cursor = conn.cursor()
cursor.executemany(