Skip to content

Commit 069faa0

Browse files
committed
MNT: Clean up docstring formatting and add more
This gets us a clean pass with flake8-docstrings.
1 parent 0830414 commit 069faa0

28 files changed

+554
-327
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Setup script for installing Siphon."""
45

56
from __future__ import print_function
67

siphon/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Tools for accessing atmospheric and oceanic science data on remote servers."""
45

56
# Version import needs to come first so everyone else can pull on import
67
from ._version import get_versions

siphon/catalog.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
44
"""
5-
This module contains code to support reading and parsing
6-
catalog files from a THREDDS Data Server (TDS). They help identifying
7-
the latest dataset and finding proper URLs to access the data.
5+
Code to support reading and parsing catalog files from a THREDDS Data Server (TDS).
6+
7+
They help identifying the latest dataset and finding proper URLs to access the data.
88
"""
99

1010
from collections import OrderedDict
@@ -26,7 +26,7 @@
2626

2727
class TDSCatalog(object):
2828
r"""
29-
An object for holding information from a THREDDS Client Catalog.
29+
Parse information from a THREDDS Client Catalog.
3030
3131
Attributes
3232
----------
@@ -44,6 +44,7 @@ class TDSCatalog(object):
4444
catalog ref title.
4545
4646
"""
47+
4748
def __init__(self, catalog_url):
4849
r"""
4950
Initialize the TDSCatalog object.
@@ -52,6 +53,7 @@ def __init__(self, catalog_url):
5253
----------
5354
catalog_url : str
5455
The URL of a THREDDS client catalog
56+
5557
"""
5658
# top level server url
5759
self.catalog_url = catalog_url
@@ -159,8 +161,7 @@ def _process_datasets(self):
159161

160162
class CatalogRef(object):
161163
r"""
162-
An object for holding Catalog References obtained from a THREDDS Client
163-
Catalog.
164+
An object for holding catalog references obtained from a THREDDS Client Catalog.
164165
165166
Attributes
166167
----------
@@ -170,7 +171,9 @@ class CatalogRef(object):
170171
url to the :class:`CatalogRef`'s THREDDS Client Catalog
171172
title : str
172173
Title of the :class:`CatalogRef` element
174+
173175
"""
176+
174177
def __init__(self, base_url, element_node):
175178
r"""
176179
Initialize the catalogRef object.
@@ -191,12 +194,13 @@ def __init__(self, base_url, element_node):
191194
self.href = urljoin(base_url, href)
192195

193196
def follow(self):
194-
r""" Follow the catalog reference, returning a new :class:`TDSCatalog`
197+
r"""Follow the catalog reference and return a new :class:`TDSCatalog`.
195198
196199
Returns
197200
-------
198201
TDSCatalog
199202
The referenced catalog
203+
200204
"""
201205
return TDSCatalog(self.href)
202206

@@ -215,10 +219,11 @@ class Dataset(object):
215219
A dictionary of access urls whose keywords are the access service
216220
types defined in the catalog (for example, "OPENDAP", "NetcdfSubset",
217221
"WMS", etc.
222+
218223
"""
224+
219225
def __init__(self, element_node, catalog_url=''):
220-
r"""
221-
Initialize the Dataset object.
226+
r"""Initialize the Dataset object.
222227
223228
Parameters
224229
----------
@@ -229,7 +234,7 @@ def __init__(self, element_node, catalog_url=''):
229234
230235
"""
231236
self.name = element_node.attrib['name']
232-
if ('urlPath' in element_node.attrib):
237+
if 'urlPath' in element_node.attrib:
233238
self.url_path = element_node.attrib['urlPath']
234239
else:
235240
self.url_path = None
@@ -248,8 +253,7 @@ def __init__(self, element_node, catalog_url=''):
248253
'the latest.xml dataset!')
249254

250255
def resolve_url(self, catalog_url):
251-
r"""
252-
Resolve the url of the dataset when reading latest.xml
256+
r"""Resolve the url of the dataset when reading latest.xml.
253257
254258
Parameters
255259
----------
@@ -283,9 +287,7 @@ def resolve_url(self, catalog_url):
283287
log.warning('no dataset url path found in latest.xml!')
284288

285289
def make_access_urls(self, catalog_url, all_services, metadata=None):
286-
r"""
287-
Make fully qualified urls for the access methods enabled on the
288-
dataset.
290+
r"""Make fully qualified urls for the access methods enabled on the dataset.
289291
290292
Parameters
291293
----------
@@ -295,8 +297,8 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
295297
list of :class:`SimpleService` objects associated with the dataset
296298
metadata : TDSCatalogMetadata
297299
Metadata from the :class:`TDSCatalog`
298-
"""
299300
301+
"""
300302
all_service_dict = {service.name: service for service in all_services}
301303
service_name = None
302304
if metadata:
@@ -335,15 +337,14 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
335337
self.access_urls = access_urls
336338

337339
def add_access_element_info(self, access_element):
340+
"""Create an access method from a catalog element."""
338341
service_name = access_element.attrib['serviceName']
339342
url_path = access_element.attrib['urlPath']
340343
self.access_element_info[service_name] = url_path
341344

342345

343346
class SimpleService(object):
344-
r"""
345-
An object for holding information about an access service enabled on a
346-
dataset.
347+
r"""Hold information about an access service enabled on a dataset.
347348
348349
Attributes
349350
----------
@@ -355,7 +356,9 @@ class SimpleService(object):
355356
A dictionary of access urls whose keywords are the access service
356357
types defined in the catalog (for example, "OPENDAP", "NetcdfSubset",
357358
"WMS", etc.)
359+
358360
"""
361+
359362
def __init__(self, service_node):
360363
r"""
361364
Initialize the Dataset object.
@@ -373,8 +376,7 @@ def __init__(self, service_node):
373376

374377

375378
class CompoundService(object):
376-
r"""
377-
An object for holding information about compound services.
379+
r"""Hold information about compound services.
378380
379381
Attributes
380382
----------
@@ -385,10 +387,11 @@ class CompoundService(object):
385387
"COMPOUND")
386388
services : list[SimpleService]
387389
A list of :class:`SimpleService` objects
390+
388391
"""
392+
389393
def __init__(self, service_node):
390-
r"""
391-
Initialize a :class:`CompoundService` object.
394+
r"""Initialize a :class:`CompoundService` object.
392395
393396
Parameters
394397
----------
@@ -410,8 +413,7 @@ def __init__(self, service_node):
410413

411414

412415
def _find_base_tds_url(catalog_url):
413-
"""
414-
Identify the base URL of the THREDDS server from the catalog URL.
416+
"""Identify the base URL of the THREDDS server from the catalog URL.
415417
416418
Will retain URL scheme, host, port and username/password when present.
417419
"""
@@ -423,9 +425,7 @@ def _find_base_tds_url(catalog_url):
423425

424426

425427
def _get_latest_cat(catalog_url):
426-
r"""
427-
Get the latest dataset catalog from the supplied top level dataset catalog
428-
url.
428+
r"""Get the latest dataset catalog from the supplied top level dataset catalog url.
429429
430430
Parameters
431431
----------
@@ -448,10 +448,10 @@ def _get_latest_cat(catalog_url):
448448

449449

450450
def get_latest_access_url(catalog_url, access_method):
451-
r"""
452-
Get the data access url, using a specified access method, to the latest
453-
data available from a top level dataset catalog (url). Currently only
454-
supports the existence of one "latest" dataset.
451+
r"""Get the data access url to the latest data using a specified access method.
452+
453+
These are available for a data available from a top level dataset catalog (url).
454+
Currently only supports the existence of one "latest" dataset.
455455
456456
Parameters
457457
----------
@@ -466,8 +466,8 @@ def get_latest_access_url(catalog_url, access_method):
466466
Data access URL to be used to access the latest data available from a
467467
given catalog using the specified `access_method`. Typically a single string,
468468
but not always.
469-
"""
470469
470+
"""
471471
latest_cat = _get_latest_cat(catalog_url)
472472
if latest_cat != '':
473473
if len(list(latest_cat.datasets.keys())) > 0:

siphon/cdmr/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Support for using CDMRemote on a THREDDS Data Server (TDS)."""
45

56
from .dataset import Dataset
67

siphon/cdmr/cdmremote.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Support talking to the CDMRemote endpoint on a THREDDS Data Server (TDS)."""
45

56
from io import BytesIO
67

@@ -9,29 +10,37 @@
910

1011

1112
class CDMRemote(HTTPEndPoint):
13+
"""Provide access to the various methods on the CDMRemote endpoint on a TDS."""
14+
1215
def __init__(self, url):
16+
"""Initialize access to a particular url."""
1317
super(CDMRemote, self).__init__(url)
1418
self.deflate = 0
1519

1620
def _fetch(self, query):
1721
return read_ncstream_messages(BytesIO(self.get_query(query).content))
1822

1923
def fetch_capabilities(self):
24+
"""Query the CDMRemote end point for its capabilities."""
2025
return self.get_query(self.query().add_query_parameter(req='capabilities'))
2126

2227
def fetch_cdl(self):
28+
"""Retrieve the CDL response from CDMRemote."""
2329
return self.get_query(self.query().add_query_parameter(req='CDL'))
2430

2531
def fetch_data(self, **var):
32+
"""Retrieve data from CDMRemote for one or more variables."""
2633
varstr = ','.join(name + self._convert_indices(ind)
2734
for name, ind in var.items())
2835
query = self.query().add_query_parameter(req='data', var=varstr)
2936
return self._fetch(query)
3037

3138
def fetch_header(self):
39+
"""Retrieve the header response from CDMRemote."""
3240
return self._fetch(self.query().add_query_parameter(req='header'))
3341

3442
def fetch_ncml(self):
43+
"""Retrieve the NCML response from CDMRemote."""
3544
return self.get_query(self.query().add_query_parameter(req='NcML'))
3645

3746
def query(self):
@@ -43,6 +52,7 @@ def query(self):
4352
-------
4453
HTTPQuery
4554
The created query.
55+
4656
"""
4757
q = super(CDMRemote, self).query()
4858

siphon/cdmr/cdmremotefeature.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2016 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Provide access to the CDMRemoteFeature endpoint on TDS."""
45

56
from io import BytesIO
67

@@ -9,7 +10,8 @@
910

1011

1112
class CDMRemoteFeature(NCSS):
12-
"""Simple wrapper for speaking to CDMRemoteFeature HTTP endpoint"""
13+
"""Communicate to the CDMRemoteFeature HTTP endpoint."""
14+
1315
@staticmethod
1416
def _parse_messages(resp):
1517
"""Parse server responses as CDMRemoteFeature messages."""

siphon/cdmr/coveragedataset.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright (c) 2016 University Corporation for Atmospheric Research/Unidata.
22
# Distributed under the terms of the MIT License.
33
# SPDX-License-Identifier: MIT
4+
"""Provide access to TDS' Coverage Dataset."""
45

56
from collections import OrderedDict
67
import logging
@@ -15,12 +16,16 @@
1516

1617

1718
def reindent_lines(new_leader, source):
18-
'Helper for __str__ to re-indent lines'
19+
"""Re-indent string lines."""
1920
return new_leader + ('\n' + new_leader).join(source.split('\n'))
2021

2122

2223
class CoverageDataset(AttributeContainer):
23-
"""Experimental class wrapping dataset access using CDMRemoteFeature and Coverages."""
24+
"""Wrap dataset access using CDMRemoteFeature and Coverages.
25+
26+
This is still experimental.
27+
"""
28+
2429
def __init__(self, url):
2530
"""Initialize CoverageDataset from a url pointing to CDMRemoteFeature endpoint."""
2631
super(CoverageDataset, self).__init__()

0 commit comments

Comments
 (0)