feat: Use preferred sesions as a template
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
.env
|
.env
|
||||||
|
preferred_sessions.json
|
||||||
log/
|
log/
|
||||||
!log/.gitkeep
|
!log/.gitkeep
|
||||||
|
|
||||||
@@ -177,4 +178,4 @@ poetry.toml
|
|||||||
# LSP config files
|
# LSP config files
|
||||||
pyrightconfig.json
|
pyrightconfig.json
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/python
|
# End of https://www.toptal.com/developers/gitignore/api/python
|
||||||
|
|||||||
22
preferred_sessions.json.example
Normal file
22
preferred_sessions.json.example
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"day_of_week": 0,
|
||||||
|
"start_time": "17:45",
|
||||||
|
"session_name_contains": "WEIGHTLIFTING LOUVRE 3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day_of_week": 4,
|
||||||
|
"start_time": "17:00",
|
||||||
|
"session_name_contains": "CONDITIONING LOUVRE 3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day_of_week": 5,
|
||||||
|
"start_time": "12:30",
|
||||||
|
"session_name_contains": "HYROX"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"day_of_week": 5,
|
||||||
|
"start_time": "12:30",
|
||||||
|
"session_name_contains": "CONDITIONING"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -36,20 +36,19 @@ class SessionConfig:
|
|||||||
preferred_sessions.append((day_of_week, start_time, session_name_contains))
|
preferred_sessions.append((day_of_week, start_time, session_name_contains))
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Log a warning if the file is not found
|
# Log error and exit if the file is not found
|
||||||
logging.warning(f"Configuration file '{config_file}' not found. Falling back to default settings.")
|
logging.error(f"Configuration file '{config_file}' not found. Please create the configuration file.")
|
||||||
|
logging.error("You can copy 'preferred_sessions.json.example' to 'preferred_sessions.json' as a template.")
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
# Log a warning if the file is not a valid JSON
|
# Log error and exit if the file is not a valid JSON
|
||||||
logging.warning(f"Failed to decode JSON from file '{config_file}'. Falling back to default settings.")
|
logging.error(f"Failed to decode JSON from file '{config_file}'. Please check the file format.")
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
# Fallback to default hardcoded sessions if no valid sessions were loaded
|
# Return empty list if no valid sessions were loaded
|
||||||
if not preferred_sessions:
|
if not preferred_sessions:
|
||||||
preferred_sessions = [
|
return []
|
||||||
(2, "18:30", "CONDITIONING"), # Wednesday 18:30 CONDITIONING
|
|
||||||
(4, "17:00", "WEIGHTLIFTING"), # Friday 17:00 WEIGHTLIFTING
|
|
||||||
(5, "12:30", "HYROX"), # Saturday 12:30 HYROX
|
|
||||||
]
|
|
||||||
|
|
||||||
return preferred_sessions
|
return preferred_sessions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user