forked from aroumie1997/duckietown-shell-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
33 lines (28 loc) · 792 Bytes
/
__init__.py
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
# This is a default __init__ file for the Duckietown Shell commands
#
# Maintainer: Andrea F. Daniele
from os.path import (
exists as _exists,
dirname as _dirname,
basename as _basename,
isdir as _isdir,
join as _join,
)
import glob as _glob
# constants
_this_dir = _dirname(__file__)
_command_file = "command.py"
# import current command
if _exists(_join(_this_dir, _command_file)):
from .command import *
# find all modules
_modules = [m for m in _glob.glob(_join(_this_dir, "*")) if _isdir(m)]
# load submodules
for _mod in _modules:
try:
exec("from .%s import *" % _basename(_mod))
except ImportError as e:
if _exists(_join(_mod, _command_file)):
raise EnvironmentError(e)
except EnvironmentError as e:
raise e