Skip to content

Commit

Permalink
Merge pull request #232 from nasa/release/1.4.0
Browse files Browse the repository at this point in the history
Release/1.4.0
  • Loading branch information
danielfromearth committed Aug 19, 2024
2 parents 8e76871 + f71f241 commit fb2ebdd
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 88 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Common Changelog](https://common-changelog.org/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.0] - 2024-08-19

### Changed
- Allow single netCDF file input in addition to single text file listings ([#230](https://github.com/nasa/stitchee/issues/230))([**@danielfromearth**](https://github.com/danielfromearth))


## [1.3.0] - 2024-07-11

### Changed
Expand Down
17 changes: 15 additions & 2 deletions concatenator/file_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

logger = logging.getLogger(__name__)

netcdf_extensions = [".nc", ".nc4", ".netcdf"]


def add_label_to_path(x: str, label="_flat_intermediate") -> str:
"""Constructs new filepath with label at end."""
Expand Down Expand Up @@ -55,7 +57,15 @@ def validate_output_path(filepath: str, overwrite: bool = False) -> str:


def validate_input_path(path_or_paths: list[str]) -> list[str]:
"""Checks whether input is a valid directory, list of files, or a text file containing paths."""
"""Checks whether input is a list of files, a directory, or a text file containing paths.
If the input is...
- a list of filepaths, then use those filepaths.
- a valid directory, then get the paths for all the files in the directory.
- a single file:
- that is a valid text file, then get the names of the files from each row in the text file.
- that is a valid netCDF file, then use that one filepath
"""
print(f"parsed_input === {path_or_paths}")
if len(path_or_paths) > 1:
input_files = path_or_paths
Expand All @@ -64,7 +74,10 @@ def validate_input_path(path_or_paths: list[str]) -> list[str]:
if directory_or_path.is_dir():
input_files = _get_list_of_filepaths_from_dir(directory_or_path)
elif directory_or_path.is_file():
input_files = _get_list_of_filepaths_from_file(directory_or_path)
if directory_or_path.suffix in netcdf_extensions:
input_files = [str(directory_or_path)]
else:
input_files = _get_list_of_filepaths_from_file(directory_or_path)
else:
raise TypeError(
"If one path is provided for 'data_dir_or_file_or_filepaths', "
Expand Down
Loading

0 comments on commit fb2ebdd

Please sign in to comment.