kopia lustrzana https://github.com/ctjacobs/pyqso
Rename get_all_records to records and decorate it.
rodzic
8d8276ff33
commit
a6aa5813f5
|
@ -81,7 +81,7 @@ class Awards:
|
||||||
count.append([0]*len(self.bands))
|
count.append([0]*len(self.bands))
|
||||||
|
|
||||||
for log in logbook.logs:
|
for log in logbook.logs:
|
||||||
records = log.get_all_records()
|
records = log.records
|
||||||
if(records is not None):
|
if(records is not None):
|
||||||
for r in records:
|
for r in records:
|
||||||
if(r["BAND"] is not None and r["MODE"] is not None):
|
if(r["BAND"] is not None and r["MODE"] is not None):
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Log(Gtk.ListStore):
|
||||||
logging.debug("Populating '%s'..." % self.name)
|
logging.debug("Populating '%s'..." % self.name)
|
||||||
self.add_missing_db_columns()
|
self.add_missing_db_columns()
|
||||||
self.clear()
|
self.clear()
|
||||||
records = self.get_all_records()
|
records = self.records
|
||||||
if(records is not None):
|
if(records is not None):
|
||||||
for r in records:
|
for r in records:
|
||||||
liststore_entry = [r["id"]]
|
liststore_entry = [r["id"]]
|
||||||
|
@ -300,7 +300,8 @@ class Log(Gtk.ListStore):
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_all_records(self):
|
@property
|
||||||
|
def records(self):
|
||||||
""" Return a list of all the records in the log.
|
""" Return a list of all the records in the log.
|
||||||
|
|
||||||
:returns: A list of all the records in the log. Each record is represented by a dictionary.
|
:returns: A list of all the records in the log. Each record is represented by a dictionary.
|
||||||
|
|
|
@ -636,7 +636,7 @@ class Logbook:
|
||||||
logging.debug("No file path specified.")
|
logging.debug("No file path specified.")
|
||||||
else:
|
else:
|
||||||
adif = ADIF()
|
adif = ADIF()
|
||||||
records = log.get_all_records()
|
records = log.records
|
||||||
if(records is not None):
|
if(records is not None):
|
||||||
adif.write(records, path)
|
adif.write(records, path)
|
||||||
else:
|
else:
|
||||||
|
@ -693,7 +693,7 @@ class Logbook:
|
||||||
ced.dialog.destroy()
|
ced.dialog.destroy()
|
||||||
|
|
||||||
cabrillo = Cabrillo()
|
cabrillo = Cabrillo()
|
||||||
records = log.get_all_records()
|
records = log.records
|
||||||
if(records is not None):
|
if(records is not None):
|
||||||
cabrillo.write(records, path, contest=contest, mycall=mycall)
|
cabrillo.write(records, path, contest=contest, mycall=mycall)
|
||||||
else:
|
else:
|
||||||
|
@ -709,7 +709,7 @@ class Logbook:
|
||||||
return
|
return
|
||||||
log_index = self.get_log_index()
|
log_index = self.get_log_index()
|
||||||
log = self.logs[log_index]
|
log = self.logs[log_index]
|
||||||
records = log.get_all_records()
|
records = log.records
|
||||||
if(records is not None):
|
if(records is not None):
|
||||||
printer = Printer(self.application)
|
printer = Printer(self.application)
|
||||||
printer.print_records(records)
|
printer.print_records(records)
|
||||||
|
|
|
@ -130,14 +130,14 @@ class TestLog(unittest.TestCase):
|
||||||
assert(record[field_name.upper()] == self.fields_and_data[field_name.upper()])
|
assert(record[field_name.upper()] == self.fields_and_data[field_name.upper()])
|
||||||
assert(len(record) == len(self.fields_and_data) + 1)
|
assert(len(record) == len(self.fields_and_data) + 1)
|
||||||
|
|
||||||
def test_log_get_all_records(self):
|
def test_log_records(self):
|
||||||
query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
|
query = "INSERT INTO test VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?)"
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
# Add the same record twice
|
# Add the same record twice
|
||||||
c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
|
c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
|
||||||
c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
|
c.execute(query, (self.fields_and_data["CALL"], self.fields_and_data["QSO_DATE"], self.fields_and_data["TIME_ON"], self.fields_and_data["FREQ"], self.fields_and_data["BAND"], self.fields_and_data["MODE"], self.fields_and_data["RST_SENT"], self.fields_and_data["RST_RCVD"]))
|
||||||
|
|
||||||
records = self.log.get_all_records()
|
records = self.log.records
|
||||||
print("Contents of all retrieved records: ", records)
|
print("Contents of all retrieved records: ", records)
|
||||||
assert(len(records) == 2) # There should be 2 records
|
assert(len(records) == 2) # There should be 2 records
|
||||||
for field_name in self.field_names:
|
for field_name in self.field_names:
|
||||||
|
|
Ładowanie…
Reference in New Issue