-
Notifications
You must be signed in to change notification settings - Fork 13
/
__init__.py
59 lines (48 loc) · 1.1 KB
/
__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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from pathlib import Path
from typing import Mapping, Type
import importlib
import logging
import os
import sys
logger = logging.getLogger(__name__)
from camisole.models import Lang
from camisole.conf import conf
def all() -> Mapping[str, Type[Lang]]:
return Lang._registry
def by_name(name: str) -> Type[Lang]:
return all()[name.lower()]
def load_builtins():
sys.path.extend(
str(Path(path).expanduser()) for path in conf.get('syspath', []))
logger.debug("sys.path: %s", sys.path)
for name in __all__:
importlib.import_module(f'camisole.languages.{name}')
def load_from_environ():
for module in os.environ.get('CAMISOLE_LANGS', '').split(':'):
if not module:
continue
try:
importlib.import_module(module)
except Exception:
logger.exception("could not load %s", module)
__all__ = [
'ada',
'c',
'd',
'csharp',
'cxx',
'go',
'haskell',
'java',
'javascript',
'lua',
'ocaml',
'pascal',
'perl',
'php',
'prolog',
'python',
'ruby',
'rust',
'scheme',
]