Skip to content

Commit

Permalink
Some little fix
Browse files Browse the repository at this point in the history
  • Loading branch information
faouziMohamed committed Dec 21, 2020
1 parent bb51339 commit ba2b9ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
33 changes: 18 additions & 15 deletions src/dataView.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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())
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
6 changes: 4 additions & 2 deletions src/resources/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
3 changes: 1 addition & 2 deletions src/resources/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit ba2b9ca

Please sign in to comment.