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 ret
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@cache
|
|
||||||
def __read_project_conf(self, project_dir: str) -> ProjectConf:
|
def __read_project_conf(self, project_dir: str) -> ProjectConf:
|
||||||
return ProjectConf.read(project_dir + '/make/project.conf')
|
return ProjectConf.read(project_dir + '/make/project.conf')
|
||||||
|
|
||||||
@cache
|
@cache
|
||||||
def __get_project_conf(self, project: str) -> ProjectConf:
|
def __get_project_conf(self, project: str) -> ProjectConf | None:
|
||||||
pd = self.__proj_dir(project, False)
|
pd = self.__proj_dir(project, False)
|
||||||
if pd is None:
|
if pd is None:
|
||||||
raise Exception(f'Failed to find directory of project {project}')
|
raise Exception(f'Failed to find directory of project {project}')
|
||||||
return self.__read_project_conf(pd)
|
try:
|
||||||
|
return self.__read_project_conf(pd)
|
||||||
|
except FileNotFoundError:
|
||||||
|
return None
|
||||||
|
|
||||||
def __get_project_refs_cached(
|
def __get_project_refs_cached(
|
||||||
self, buf, visited, spec, section, key, add_self, scope, names_only
|
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}"')
|
log(DEBUG, f'Ignoring unreadable file "{version_path}"')
|
||||||
continue
|
continue
|
||||||
raise Exception(f'No version file found for project "{project}"')
|
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(
|
log(
|
||||||
DEBUG,
|
DEBUG,
|
||||||
'Lookup %s -> %s / [%s%s] -> "%s"' %
|
'Lookup %s -> %s / [%s%s] -> "%s"' %
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue