App.get_value(): Fix FileNotFoundError regression
The refactored __get_project_conf() raises FileNotFoundError when project.conf does not exist, whereas the original read_value() returns None. This causes get_value() to crash for projects with missing or incomplete project.conf files.
Catch FileNotFoundError in __get_project_conf() and return None to restore original behavior. Remove redundant @cache from __read_project_conf() since __get_project_conf() already provides caching.
Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.devSigned-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
24d67a5ec0
commit
42f064de89
1 changed files with 9 additions and 4 deletions
|
|
@ -185,16 +185,18 @@ class App(Base):
|
|||
return ret
|
||||
return None
|
||||
|
||||
@cache
|
||||
def __read_project_conf(self, project_dir: str) -> ProjectConf:
|
||||
return ProjectConf.read(project_dir + '/make/project.conf')
|
||||
|
||||
@cache
|
||||
def __get_project_conf(self, project: str) -> ProjectConf:
|
||||
def __get_project_conf(self, project: str) -> ProjectConf | None:
|
||||
pd = self.__proj_dir(project, False)
|
||||
if pd is None:
|
||||
raise Exception(f'Failed to find directory of project {project}')
|
||||
try:
|
||||
return self.__read_project_conf(pd)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
def __get_project_refs_cached(
|
||||
self, buf, visited, spec, section, key, add_self, scope, names_only
|
||||
|
|
@ -552,7 +554,10 @@ class App(Base):
|
|||
log(DEBUG, f'Ignoring unreadable file "{version_path}"')
|
||||
continue
|
||||
raise Exception(f'No version file found for project "{project}"')
|
||||
ret = self.__get_project_conf(project).get_str_or_none(section, key)
|
||||
proj_conf = self.__get_project_conf(project)
|
||||
if proj_conf is None:
|
||||
return None
|
||||
ret = proj_conf.get_str_or_none(section, key)
|
||||
log(
|
||||
DEBUG,
|
||||
'Lookup %s -> %s / [%s%s] -> "%s"' %
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue