Skip to content

Commit

Permalink
[#44] using aggregation resmap filename to filter aggregation by file…
Browse files Browse the repository at this point in the history
… path search
  • Loading branch information
pkdash committed Mar 29, 2023
1 parent 6f036f1 commit 2e52e0e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 10 additions & 1 deletion hsclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
from hsclient.hydroshare import Aggregation, File, HydroShare, Resource
from hsclient.hydroshare import (
Aggregation,
File,
HydroShare,
Resource,
NetCDFAggregation,
TimeseriesAggregation,
GeoRasterAggregation,
GeoFeatureAggregation,
)
from hsclient.oauth2_model import Token
15 changes: 12 additions & 3 deletions hsclient/hydroshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,18 @@ def aggregations(self, **kwargs) -> List[BaseMetadata]:
if not file_path:
file_path = kwargs.get("files__path", "")
if file_path:
for agg in aggregations:
if agg.files(path=file_path):
return [agg]
dir_path = os.path.dirname(file_path)
file_name = pathlib.Path(file_path).stem
if dir_path:
aggr_map_path = urljoin(dir_path, file_name)
else:
aggr_map_path = file_name

aggr_map_path = f"{aggr_map_path}_resmap.xml"
for aggr in self._parsed_aggregations:
aggr_map_full_path = f"/{aggr._resource_path}/data/contents/{aggr_map_path}"
if aggr._map_path == aggr_map_full_path:
return [aggr]
return []

for key, value in kwargs.items():
Expand Down

0 comments on commit 2e52e0e

Please sign in to comment.