Skip to content

Commit

Permalink
fixes #628
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Sep 19, 2024
1 parent de52343 commit cb407c9
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 145 deletions.
2 changes: 1 addition & 1 deletion fastcore/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.7.8"
__version__ = "1.7.9"
1 change: 1 addition & 0 deletions fastcore/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
'fastcore.foundation.Config.__repr__': ('foundation.html#config.__repr__', 'fastcore/foundation.py'),
'fastcore.foundation.Config.__setitem__': ( 'foundation.html#config.__setitem__',
'fastcore/foundation.py'),
'fastcore.foundation.Config.find': ('foundation.html#config.find', 'fastcore/foundation.py'),
'fastcore.foundation.Config.get': ('foundation.html#config.get', 'fastcore/foundation.py'),
'fastcore.foundation.Config.path': ('foundation.html#config.path', 'fastcore/foundation.py'),
'fastcore.foundation.Config.save': ('foundation.html#config.save', 'fastcore/foundation.py'),
Expand Down
7 changes: 7 additions & 0 deletions fastcore/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,10 @@ def get(self,k,default=None):
def path(self,k,default=None):
v = self.get(k, default)
return v if v is None else self.config_path/v

@classmethod
def find(cls, cfg_name, cfg_path=None, **kwargs):
"Search `cfg_path` and its parents to find `cfg_name`"
p = Path(cfg_path or Path.cwd()).expanduser().absolute()
return first(cls(o, cfg_name, **kwargs)
for o in [p, *p.parents] if (o/cfg_name).exists())
Loading

0 comments on commit cb407c9

Please sign in to comment.