Provide error messages when CSVs not found at log location

This commit is contained in:
benjamin melançon 2024-11-23 23:42:57 -05:00
parent c1aa1f795b
commit 3783992de5

View file

@ -15,10 +15,14 @@ else:
if settings.pomodoro_logfile(): if settings.pomodoro_logfile():
# This works for one file: # This works for one file:
timelog = pd.read_csv(settings.pomodoro_logfile()) timelog = pd.read_csv(settings.pomodoro_logfile())
else: if not timelog:
sys.exit("No logfile found at location specified for logfile.")
elif settings.pomodoro_logpath():
# For multiple files: # For multiple files:
path = settings.pomodoro_logpath() path = settings.pomodoro_logpath()
all_files = glob.glob(path + "*.csv") all_files = glob.glob(path + "*.csv")
if not all_files:
sys.exit("No folder at location specified for logpath.")
li = [] li = []
@ -27,6 +31,8 @@ else:
li.append(df) li.append(df)
timelog = pd.concat(li, axis=0, ignore_index=True) timelog = pd.concat(li, axis=0, ignore_index=True)
else:
sys.exit("You must set either a logfile (single CSV) or a logpath (folder containing CSVs) in your settings.ini to use this script.")
if debug: if debug:
imported = copy.deepcopy(timelog) imported = copy.deepcopy(timelog)