-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
52 lines (38 loc) · 1.28 KB
/
__init__.py
File metadata and controls
52 lines (38 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
from .core.logger import LOGGING, logger # noqa: E402
try:
import importlib
except ImportError:
importlib = None
__all__ = ["LOGGING", "logger", "show", "VERSION", "TOOL_TITLE"]
TOOL_TITLE = "Job Fetcher"
MOD_NAME = __name__
# Expose version
try:
_v_path = os.path.join(current_dir, "VERSION")
with open(_v_path, "r", encoding="utf-8") as _f:
VERSION = _f.read().strip()
except Exception:
VERSION = "0.0.0"
def show(mod_name=MOD_NAME, force_reload=True):
if force_reload:
# Recursive reload for submodules in this package
for name in list(sys.modules.keys()):
if name == mod_name or name.startswith(mod_name + "."):
del sys.modules[name]
if importlib and hasattr(importlib, "invalidate_caches"):
importlib.invalidate_caches()
try:
# Re-import this package
if mod_name not in sys.modules:
importlib.import_module(mod_name)
main_mod = importlib.import_module(mod_name + ".main")
return main_mod.runner()
except Exception as e:
logger.error(f"Error launching {mod_name}: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
show()