Handle Bunch/Munch import failure

This commit is contained in:
Fierelier 2023-10-14 13:56:36 +02:00
parent 0447ffcb5c
commit a9543243b4
1 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,4 @@
import sys
import os
# BUNCH
@ -6,11 +7,15 @@ try:
Bunch = munch.Munch
bunchify = munch.munchify
unbunchify = munch.unmunchify
except Exception:
import bunch
Bunch = munch.Bunch
bunchify = munch.bunchify
unbunchify = munch.unbunchify
except ModuleNotFoundError:
try:
import bunch
Bunch = munch.Bunch
bunchify = munch.bunchify
unbunchify = munch.unbunchify
except ModuleNotFoundError:
print("Error: Could not find munch/bunch module. Install munch on Python 3, bunch on Python 2.",file=sys.stderr)
sys.exit(1)
# GLOBALS
g = Bunch()