Skip to content

Commit

Permalink
Fix updatedFile usage to be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Jan 22, 2024
1 parent 497c8e6 commit f2dfdfc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions python/lsst/daf/butler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ def __init__(self, stream: str | IO): # types-PyYAML annotates 'stream' with a
super().__init__(stream)
# if this is a string and not a stream we may well lack a name
if hasattr(stream, "name"):
self._root = ResourcePath(stream.name)
self._root = ResourcePath(stream.name, forceDirectory=False)
else:
# No choice but to assume a local filesystem
self._root = ResourcePath("no-file.yaml")
self._root = ResourcePath("no-file.yaml", forceDirectory=False)
self.add_constructor("!include", Loader.include)

def include(self, node: yaml.Node) -> list[Any] | dict[str, Any]:
Expand Down Expand Up @@ -174,7 +174,7 @@ def extractFile(self, filename: str) -> Any:
# instead of a relative URI, therefore we first see if it is
# scheme-less or not. If it has a scheme we use it directly
# if it is scheme-less we use it relative to the file root.
requesteduri = ResourcePath(filename, forceAbsolute=False)
requesteduri = ResourcePath(filename, forceAbsolute=False, forceDirectory=False)

if requesteduri.scheme:
fileuri = requesteduri
Expand Down Expand Up @@ -950,7 +950,10 @@ def dumpToUri(
uri = ResourcePath(uri)

if updateFile and not uri.getExtension():
uri = uri.updatedFile(defaultFileName)
if uri.isdir():
uri = uri.join(defaultFileName, forceDirectory=False)
else:
uri = uri.updatedFile(defaultFileName)

Check warning on line 956 in python/lsst/daf/butler/_config.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/_config.py#L956

Added line #L956 was not covered by tests

# Try to work out the format from the extension
ext = uri.getExtension()
Expand Down

0 comments on commit f2dfdfc

Please sign in to comment.