Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.4.0 #232

Merged
merged 17 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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