[chronojump/chronojump-importer] Prints the summary for the table again.
- From: Carles Pina i Estany <carlespina src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump/chronojump-importer] Prints the summary for the table again.
- Date: Fri, 9 Sep 2016 15:37:37 +0000 (UTC)
commit df12a38b33080be48b5dab466cdb2c259ba6e2d2
Author: Carles Pina i Estany <carles pina cat>
Date: Fri Sep 9 16:37:20 2016 +0100
Prints the summary for the table again.
src/chronojump-importer/chronojump_importer.py | 37 ++++++++++++-----------
1 files changed, 19 insertions(+), 18 deletions(-)
---
diff --git a/src/chronojump-importer/chronojump_importer.py b/src/chronojump-importer/chronojump_importer.py
index 67bd319..df69e33 100755
--- a/src/chronojump-importer/chronojump_importer.py
+++ b/src/chronojump-importer/chronojump_importer.py
@@ -112,6 +112,24 @@ class Table:
def __getitem__(self, index):
return self._table_data[index]
+ def print_summary(self):
+ inserted_ids = []
+ reused_ids = []
+ for row in self._table_data:
+ if row.get('importer_action') == 'inserted':
+ inserted_ids.append(row.get('uniqueID'))
+
+ elif row.get('importer_action') == 'reused':
+ reused_ids.append(row.get('uniqueID'))
+ else:
+ assert False
+
+ print("{table_name}".format(table_name=self.name))
+ print("\tinserted: {inserted_counter} uniqueIDs:
{inserted}".format(inserted_counter=len(inserted_ids),
+ inserted=inserted_ids))
+ print(
+ "\treused: {reused_counter} uniqueIDs: {reused}".format(reused_counter=len(reused_ids),
reused=reused_ids))
+
class Database:
""" A database represents the database and read/writes tables. """
@@ -214,7 +232,7 @@ class Database:
row.set('new_uniqueID', new_id)
- # TODO print_summary(table, data_result)
+ table.print_summary()
def read(self, table_name, where_condition, join_clause ="", group_by_clause=""):
""" Returns a list of dictionaries of the table table_name applying the where_condition, join_clause
and group_by_clause. """
@@ -328,23 +346,6 @@ class Database:
return "{} ({})".format(base_name, counter)
-def print_summary(table_name, table_data):
- inserted_ids = []
- reused_ids = []
- for row in table_data:
- if row['importer_action'] == 'inserted':
- inserted_ids.append(row['uniqueID'])
-
- elif row['importer_action'] == 'reused':
- reused_ids.append(row['uniqueID'])
- else:
- assert False
-
- print("{table_name}".format(table_name=table_name))
- print("\tinserted: {inserted_counter} uniqueIDs: {inserted}".format(inserted_counter=len(inserted_ids),
inserted=inserted_ids))
- print("\treused: {reused_counter} uniqueIDs: {reused}".format(reused_counter=len(reused_ids),
reused=reused_ids))
-
-
def import_database(source_path, destination_path, source_session):
""" Imports the session source_session from source_db into destination_db """
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]