Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
26 changes: 26 additions & 0 deletions src/siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from datetime import datetime
import logging
import re
import requests
import warnings
import xml.etree.ElementTree as ET # noqa:N814
try:
Expand Down Expand Up @@ -389,6 +390,31 @@ def _process_datasets(self):
else:
self.datasets.pop(ds_name)

def walk(self, depth=1):

"""Return a generator walking a THREDDS data catalog for datasets.

Parameters
----------
cat : TDSCatalog
THREDDS catalog.
depth : int
Maximum recursive depth. Setting 0 will return only datasets within the top-level catalog. If None,
depth is set to 1000.
"""
Comment thread
tlogan2000 marked this conversation as resolved.
yield from self.datasets.values()
if depth is None:
depth = 1000

if depth > 0:
for ref in self.catalog_refs.values():
try:
child = ref.follow()
yield from child.walk(depth=depth - 1)

except requests.HTTPError as exc:
log.exception(exc)

@property
def latest(self):
"""Get the latest dataset, if available."""
Expand Down
Loading