Rename get_all_records to records and decorate it.

pull/61/head
Christian T. Jacobs 2017-04-20 22:57:17 +01:00
rodzic 8d8276ff33
commit a6aa5813f5
4 zmienionych plików z 9 dodań i 8 usunięć

Wyświetl plik

@ -81,7 +81,7 @@ class Awards:
count.append([0]*len(self.bands))
for log in logbook.logs:
records = log.get_all_records()
records = log.records
if(records is not None):
for r in records:
if(r["BAND"] is not None and r["MODE"] is not None):

Wyświetl plik

@ -53,7 +53,7 @@ class Log(Gtk.ListStore):
logging.debug("Populating '%s'..." % self.name)
self.add_missing_db_columns()
self.clear()
records = self.get_all_records()
records = self.records
if(records is not None):
for r in records:
liststore_entry = [r["id"]]
@ -300,7 +300,8 @@ class Log(Gtk.ListStore):
logging.exception(e)
return None
def get_all_records(self):
@property
def records(self):
""" 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.

Wyświetl plik

@ -636,7 +636,7 @@ class Logbook:
logging.debug("No file path specified.")
else:
adif = ADIF()
records = log.get_all_records()
records = log.records
if(records is not None):
adif.write(records, path)
else:
@ -693,7 +693,7 @@ class Logbook:
ced.dialog.destroy()
cabrillo = Cabrillo()
records = log.get_all_records()
records = log.records
if(records is not None):
cabrillo.write(records, path, contest=contest, mycall=mycall)
else:
@ -709,7 +709,7 @@ class Logbook:
return
log_index = self.get_log_index()
log = self.logs[log_index]
records = log.get_all_records()
records = log.records
if(records is not None):
printer = Printer(self.application)
printer.print_records(records)

Wyświetl plik

@ -130,14 +130,14 @@ class TestLog(unittest.TestCase):
assert(record[field_name.upper()] == self.fields_and_data[field_name.upper()])
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, ?, ?, ?, ?, ?, ?, ?, ?)"
c = self.connection.cursor()
# 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"]))
records = self.log.get_all_records()
records = self.log.records
print("Contents of all retrieved records: ", records)
assert(len(records) == 2) # There should be 2 records
for field_name in self.field_names: