in builder/core/project.py [0:0]
def _project_from_path(path='.', name_hint=None):
path = os.path.abspath(path)
project_config_file = os.path.join(path, "builder.json")
if os.path.exists(project_config_file):
import json
with open(project_config_file, 'r') as config_fp:
try:
project_config = json.load(config_fp)
except Exception as e:
print("Failed to parse config file", project_config_file, e)
sys.exit(1)
if name_hint is None or project_config.get('name', None) == name_hint:
print(' Found project: {} at {}'.format(project_config['name'], path))
project = Project._create_project(**project_config, path=path)
return Project._cache_project(project)
# load any builder scripts and check them
Scripts.load()
# only construct a new instance of the class if there isn't one already in the cache
if name_hint and name_hint.lower() not in Project._projects:
project_cls = Project._find_project_class(name_hint)
if project_cls:
project = project_cls(name=name_hint, path=path if os.path.basename(path) == name_hint else None)
return Project._cache_project(project)
return None