You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
# Note: You can just use handler.exception() or handler.exception(msg=e) to rely on global settings
78
-
handler.exception(
79
-
# These are local settings, if they are different from the global, they take priority
80
-
# so they will override the global settings only for this case.
81
-
msg=e, # Detailed exception message, can be a custom string
82
-
exit_script=True, # Exit the script after handling the exception
83
-
quit_code=1, # Exit code to use when exiting the script, defaults to 1
84
-
return_string_rather_than_print=False# Return the message instead of printing it
85
-
#NOTE: If return_string_rather_than_print is set to True globally,
86
-
# and you want to locally quit for this singular case,
87
-
# then you HAVE TO explicitly set it to False here.
88
-
)
89
-
90
-
divide_numbers(10, 0)
74
+
# Use the example script at example/ExceptionHandle.py for a full demonstration
91
75
```
92
76
93
-
## Customization
94
-
95
-
-**Global Settings**: Set during `Handler` initialization.
96
-
-**Local Settings**: Override global settings in the `exception` method.
97
-
-**Formatter**: Customize colors and formats using the `formatter` method.
98
-
99
-
Check the [`example.py`](example.py) file for a proper example.
100
-
101
-
### Override priority
77
+
## Override priority
102
78
103
79
- Local settings take precedence over global settings.
104
-
- If both global and local settings are provided, the local settings will override the global ones.
105
-
- To use the global settings, simply call `handler.exception()`/`handler.exception(msg=e)`.
106
-
- Any settings you want to override for this specific use case can be passed as arguments.
107
80
-`return_string_rather_than_print` has priority over `exit_script` both locally and globally.
108
-
- If `return_string_rather_than_print` is set to `True` globally, and you want to locally quit for this singular case, then you HAVE TO explicitly set it to `False` in the local settings.
109
-
110
-
### Modify Colors, Format or Messages
111
81
112
-
If you want to modify the DataType for format's or colors ANSI, you can do so by modifying the `Format` and `Colors` classes in the [`exception.py`](colors.py) file.
82
+
## Modify Colors, Format or Messages
113
83
114
-
If you want to add/remove Messages from the dictionary, you can do so by modifying the `Messages` class in the [`messages.py`](messages.py) file.
84
+
- Colors and formats are defined in `ExceptionHandler/colors.py`.
85
+
- Generic messages are stored in `ExceptionHandler/messages.py`.
115
86
116
87
## Dependencies
117
88
118
-
- Datetime
89
+
- Datetime (standard library)
90
+
-`TerminalPrint` for the default print function
91
+
92
+
## Notes and Safety
93
+
94
+
- If `exit_script` is True the program will call `sys.exit()` after printing/returning the message.
95
+
-`return_string_rather_than_print` has priority over `exit_script` (if message is returned, the handler will not exit).
96
+
- The default printing function is `TPrint().critical` from `TerminalPrint`. You can pass any callable that accepts a single string argument.
Lightweight collection of small Python utilities used across projects: a configurable exception handler, a colored terminal printing helper, and a simple Git update manager.
4
+
5
+
Last updated: 2026-01-17
6
+
7
+
## Modules
8
+
9
+
-`ExceptionHandler/` — Friendly, configurable exception formatting and handling. See `ExceptionHandler/README.md` for details and examples.
10
+
-`TerminalPrint/` — Console printing helper with color schemes, log-to-file and timestamp support. See `TerminalPrint/README.md`.
11
+
-`UpdateManager/` — Small helper to fetch and merge updates from a remote Git branch for a local repo path. See `UpdateManager/README.md`.
-`example/ExceptionHandle.py` — demo for `ExceptionHandler`.
48
+
-`example/Update.py` — demo for `UpdateManager`.
49
+
50
+
## Notes & Safety
51
+
52
+
-`UpdateManager` calls the system `git` CLI and will `sys.exit()` on failures or when uncommitted changes are detected — ensure you have a clean working tree before running `update()`.
53
+
-`ExceptionHandler` may call `sys.exit()` when `exit_script` is enabled; prefer `return_string_rather_than_print` for library usage.
54
+
- Terminal coloring uses ANSI escape codes; results may vary on non-ANSI terminals (Windows terminals recent versions and WSL work well).
55
+
56
+
## Contributing
57
+
58
+
Contributions welcome — open a pull request and include tests/examples where appropriate.
0 commit comments