diff --git a/src/dataView.py b/src/dataView.py index 90cf0b1..9a0559c 100644 --- a/src/dataView.py +++ b/src/dataView.py @@ -53,8 +53,7 @@ def __setup_event_handler(self, is_first_load: bool = True): def initialize_fields(self, is_first_load: bool = True): if is_first_load: - print('Date, Continent, Country, New Tests, New cases,', - 'New Deaths, Total tests, Total cases, Total deaths') + self.print_data_columns_to_console() self.__fill_country_continent_combobox() calendar = self.dateEdit.calendarWidget() calendar.setGridVisible(True) @@ -147,6 +146,7 @@ def __set_current_continent(self, continent: str): self.continent_box.setCurrentIndex(continent_id + 1) self.continent_edit.setText(continent) + # Reimplemented functions and event handlers def on_treeview_selectionChanged(self, selected: QItemSelection, deselected: QItemSelection): utils.ignore(deselected) @@ -157,7 +157,6 @@ def on_treeview_selectionChanged(self, selected: QItemSelection, self.__display_details_about(selected_row) self.endFilteringRows() - # Reimplemented functions and event handlers def on_date_edit_dateChanged(self, new_date: QDate): calendar = self.dateEdit.calendarWidget() calendar.setCurrentPage(new_date.year(), new_date.month()) @@ -188,18 +187,6 @@ def on_countryBox_currentIndexChanged(self, index: int) -> None: self.resize_header_data() self.endFilteringRows() - def echo_to_console(self, text: str, value): - print(f"-------|| The {text} is {value} ||--------") - - def print_selectedRow_to_console(self, row): - data = [self.dateEdit_text.text(), row.continent, row.location, - int(row.new_tests), int(row.new_cases), int(row.new_deaths), - int(row.total_tests), int(row.total_cases), - int(row.total_deaths)] - for value in data[:-1]: - print(f"{value}, ", end='') - print(data[-1]) - def disconnect_dateEdit_connection(self, must_disconnect): if must_disconnect: self.dateEdit.dateChanged.disconnect(self.on_date_edit_dateChanged) @@ -241,5 +228,21 @@ def beginFilteringRows(self, dt=True, ct=True, cr=True, tree=True): def endFilteringRows(self, dt=False, ct=False, cr=False, tree=False): self.beginFilteringRows(dt, ct, cr, tree) + def print_data_columns_to_console(self): + print('Date, Continent, Country, New Tests, New cases,', + 'New Deaths, Total tests, Total cases, Total deaths') + + def echo_to_console(self, text: str, value): + print(f"-------|| The {text} is {value} ||--------") + + def print_selectedRow_to_console(self, row): + data = [self.dateEdit_text.text(), row.continent, row.location, + int(row.new_tests), int(row.new_cases), int(row.new_deaths), + int(row.total_tests), int(row.total_cases), + int(row.total_deaths)] + for value in data[:-1]: + print(f"{value}, ", end='') + print(data[-1]) + def closeEvent(self, a0: QCloseEvent) -> None: a0.accept() diff --git a/src/resources/constant.py b/src/resources/constant.py index f8c5105..5203cc9 100644 --- a/src/resources/constant.py +++ b/src/resources/constant.py @@ -4,5 +4,7 @@ JSON_FILE = f'{DB_PATH}/{FILE_NAME}.json' SQL_FILE = f'{DB_PATH}/{FILE_NAME}.sql' DB_NAME = f'{DB_PATH}/{FILE_NAME}.sqlite' -URL_CSV_FILE = 'https://raw.githubusercontent.com/owid/covid-19-data/master' \ - '/public/data/owid-covid-data.csv' +GITHUB_CSV_FILE = 'https://raw.githubusercontent.com/owid/covid-19-data/' \ + 'master/public/data/owid-covid-data.csv' +# The stable URL for the data accord to owid +URL_CSV_FILE = 'https://covid.ourworldindata.org/data/owid-covid-data.csv' diff --git a/src/resources/utils.py b/src/resources/utils.py index 0a7de25..78a33a2 100644 --- a/src/resources/utils.py +++ b/src/resources/utils.py @@ -10,8 +10,7 @@ def today(as_string=True): def is_leap_year(y): - return (y % 4 == 0 and y % 100 != 0) or - (y % 400 == 0) + return (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0) def year_mon_day(a_date: str = today()) -> Tuple[int, int, int]: