Skip to content

Commit

Permalink
Fixed spelling, added check of empty export data
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreWohnsland committed Aug 13, 2020
1 parent 8d993ba commit 8b2d7fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/button_controler.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ def export_data(self):
overtime_report = self.ui_controler.report_choice()
if overtime_report == None:
return
succesful, file_path = self.data_exporter.export_data(self.report_df, report_date, overtime_report)
succesful, message = self.data_exporter.export_data(self.report_df, report_date, overtime_report)
if succesful:
self.ui_controler.show_message(f"File saved under: {file_path}")
else:
self.ui_controler.show_message(f"Could not open Workbook: {file_path}, is it still opened?")
self.ui_controler.show_message(message)

def switch_dataview(self):
self.ui_controler.handle_delete_button(self.delete_selected_event)
Expand Down
11 changes: 8 additions & 3 deletions src/data_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def __init__(self):
self.worktime = 8

def export_data(self, df, report_date, overtime_report=True):
if not df:
message = f"No data to export, will no generate file..."
print(message)
return False, message
config = self.config_handler.get_config_file_data()
file_suffix = "time"
if overtime_report:
Expand All @@ -35,16 +39,17 @@ def export_data(self, df, report_date, overtime_report=True):
workbook.close()
return True, file_path
except:
print(f"Could not open Workbook: {file_name}, is it still opened?")
return False, file_path
message = f"Could not open Workbook: {file_name}, is it still opened?"
print(message)
return False, message

def round_quarterly(self, number):
return round(number * 4) / 4

def write_person_information(self, worksheet, df, config, bold, color, overtime_report):
worksheet.write("A1", "Name:", bold)
worksheet.write("B1", config["Name"], color)
worksheet.write("A2", "Pers.Nr::", bold)
worksheet.write("A2", "Pers.Nr:", bold)
worksheet.write("B2", config["Personal Number"], color)
worksheet.write("A3", "Monat:", bold)
worksheet.write("B3", df.index[0].strftime("%B"), color)
Expand Down
2 changes: 1 addition & 1 deletion src/ui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def connect_buttons(self):

def set_icon(self, window):
dirpath = os.path.dirname(__file__)
self.clock_picture = os.path.join(dirpath, "..", "ui", "clock.png")
self.clock_picture = os.path.join(os.path.dirname(dirpath), "ui", "clock.png")
window.setWindowIcon(QIcon(self.clock_picture))

def set_objects(self):
Expand Down

0 comments on commit 8b2d7fe

Please sign in to comment.