-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodule_config.py
More file actions
40 lines (29 loc) · 1.05 KB
/
module_config.py
File metadata and controls
40 lines (29 loc) · 1.05 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
"""
Module configuration for UTTR import system.
Defines module search paths and resolution rules.
"""
import os
# Get the directory of this file (the UTTR root directory)
UTTR_ROOT = os.path.dirname(os.path.abspath(__file__))
# Standard library directory
STDLIB_DIR = os.path.join(UTTR_ROOT, 'stdlib')
# Module file extension
MODULE_EXTENSION = '.uttr'
def get_module_search_paths(current_file_path=None):
"""
Get list of paths to search for modules, in order of precedence.
Args:
current_file_path: Path to the file doing the import (for relative imports)
Returns:
List of directory paths to search
"""
search_paths = []
# 1. Current directory of the importing file (for relative imports)
if current_file_path:
current_dir = os.path.dirname(os.path.abspath(current_file_path))
search_paths.append(current_dir)
# 2. Current working directory
search_paths.append(os.getcwd())
# 3. Standard library directory
search_paths.append(STDLIB_DIR)
return search_paths