Skip to content

Commit

Permalink
Merge pull request #129 from dopplershift/fix-build
Browse files Browse the repository at this point in the history
Fix build
  • Loading branch information
dopplershift authored Jul 19, 2017
2 parents 6584c7b + dc88ed4 commit 4bee767
Show file tree
Hide file tree
Showing 31 changed files with 593 additions and 385 deletions.
6 changes: 3 additions & 3 deletions appveyor.yml → .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ build: off

test_script:
- cmd: python setup.py test --addopts "-s --junitxml=tests.xml --flake8 --cov=siphon"
- cmd: cd docs
- cmd: make html
- cmd: cd ..
#- cmd: cd docs
#- cmd: make html
#- cmd: cd ..

on_finish:
- ps: $wc = New-Object 'System.Net.WebClient'
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies:
- flake8-builtins
- flake8-comprehensions
- flake8-copyright
- flake8-docstrings
- flake8-import-order
- flake8-mutable
- flake8-pep3101
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ copyright-check = True
copyright-author = University Corporation for Atmospheric Research/Unidata
application-import-names = siphon
import-order-style = google
inline-quotes = single
multiline-quotes = double

[tool:pytest]
norecursedirs = build docs
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Setup script for installing Siphon."""

from __future__ import print_function

Expand Down Expand Up @@ -44,10 +45,11 @@
extras_require={
'netcdf': 'netCDF4>=1.1.0',
'dev': 'ipython[all]>=3.1',
'test': ['pytest', 'pytest-flake8', 'pytest-runner', 'netCDF4>=1.1.0',
'test': ['pytest', 'pytest-catchlog', 'pytest-flake8', 'pytest-runner',
'netCDF4>=1.1.0',
'flake8>3.2.0', 'flake8-builtins', 'flake8-comprehensions',
'flake8-copyright', 'flake8-import-order', 'flake8-mutable',
'flake8-pep3101', 'flake8-print', 'flake8-quotes',
'flake8-copyright', 'flake8-docstrings', 'flake8-import-order',
'flake8-mutable', 'flake8-pep3101', 'flake8-print', 'flake8-quotes',
'pep8-naming',
'vcrpy~=1.5,!=1.7.0,!=1.7.1,!=1.7.2,!=1.7.3', 'xarray>=0.6'],
'doc': ['sphinx>=1.3', 'sphinx-gallery', 'doc8'],
Expand Down
1 change: 1 addition & 0 deletions siphon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Tools for accessing atmospheric and oceanic science data on remote servers."""

# Version import needs to come first so everyone else can pull on import
from ._version import get_versions
Expand Down
78 changes: 39 additions & 39 deletions siphon/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""
This module contains code to support reading and parsing
catalog files from a THREDDS Data Server (TDS). They help identifying
the latest dataset and finding proper URLs to access the data.
Code to support reading and parsing catalog files from a THREDDS Data Server (TDS).
They help identifying the latest dataset and finding proper URLs to access the data.
"""

from collections import OrderedDict
Expand All @@ -25,8 +25,8 @@


class TDSCatalog(object):
r"""
An object for holding information from a THREDDS Client Catalog.
"""
Parse information from a THREDDS Client Catalog.
Attributes
----------
Expand All @@ -44,14 +44,16 @@ class TDSCatalog(object):
catalog ref title.
"""

def __init__(self, catalog_url):
r"""
"""
Initialize the TDSCatalog object.
Parameters
----------
catalog_url : str
The URL of a THREDDS client catalog
"""
# top level server url
self.catalog_url = catalog_url
Expand Down Expand Up @@ -158,9 +160,8 @@ def _process_datasets(self):


class CatalogRef(object):
r"""
An object for holding Catalog References obtained from a THREDDS Client
Catalog.
"""
An object for holding catalog references obtained from a THREDDS Client Catalog.
Attributes
----------
Expand All @@ -170,9 +171,11 @@ class CatalogRef(object):
url to the :class:`CatalogRef`'s THREDDS Client Catalog
title : str
Title of the :class:`CatalogRef` element
"""

def __init__(self, base_url, element_node):
r"""
"""
Initialize the catalogRef object.
Parameters
Expand All @@ -191,18 +194,19 @@ def __init__(self, base_url, element_node):
self.href = urljoin(base_url, href)

def follow(self):
r""" Follow the catalog reference, returning a new :class:`TDSCatalog`
"""Follow the catalog reference and return a new :class:`TDSCatalog`.
Returns
-------
TDSCatalog
The referenced catalog
"""
return TDSCatalog(self.href)


class Dataset(object):
r"""
"""
An object for holding Datasets obtained from a THREDDS Client Catalog.
Attributes
Expand All @@ -215,10 +219,11 @@ class Dataset(object):
A dictionary of access urls whose keywords are the access service
types defined in the catalog (for example, "OPENDAP", "NetcdfSubset",
"WMS", etc.
"""

def __init__(self, element_node, catalog_url=''):
r"""
Initialize the Dataset object.
"""Initialize the Dataset object.
Parameters
----------
Expand All @@ -229,7 +234,7 @@ def __init__(self, element_node, catalog_url=''):
"""
self.name = element_node.attrib['name']
if ('urlPath' in element_node.attrib):
if 'urlPath' in element_node.attrib:
self.url_path = element_node.attrib['urlPath']
else:
self.url_path = None
Expand All @@ -248,8 +253,7 @@ def __init__(self, element_node, catalog_url=''):
'the latest.xml dataset!')

def resolve_url(self, catalog_url):
r"""
Resolve the url of the dataset when reading latest.xml
"""Resolve the url of the dataset when reading latest.xml.
Parameters
----------
Expand Down Expand Up @@ -283,9 +287,7 @@ def resolve_url(self, catalog_url):
log.warning('no dataset url path found in latest.xml!')

def make_access_urls(self, catalog_url, all_services, metadata=None):
r"""
Make fully qualified urls for the access methods enabled on the
dataset.
"""Make fully qualified urls for the access methods enabled on the dataset.
Parameters
----------
Expand All @@ -295,8 +297,8 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
list of :class:`SimpleService` objects associated with the dataset
metadata : TDSCatalogMetadata
Metadata from the :class:`TDSCatalog`
"""
"""
all_service_dict = {service.name: service for service in all_services}
service_name = None
if metadata:
Expand Down Expand Up @@ -335,15 +337,14 @@ def make_access_urls(self, catalog_url, all_services, metadata=None):
self.access_urls = access_urls

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


class SimpleService(object):
r"""
An object for holding information about an access service enabled on a
dataset.
"""Hold information about an access service enabled on a dataset.
Attributes
----------
Expand All @@ -355,9 +356,11 @@ class SimpleService(object):
A dictionary of access urls whose keywords are the access service
types defined in the catalog (for example, "OPENDAP", "NetcdfSubset",
"WMS", etc.)
"""

def __init__(self, service_node):
r"""
"""
Initialize the Dataset object.
Parameters
Expand All @@ -373,8 +376,7 @@ def __init__(self, service_node):


class CompoundService(object):
r"""
An object for holding information about compound services.
"""Hold information about compound services.
Attributes
----------
Expand All @@ -385,10 +387,11 @@ class CompoundService(object):
"COMPOUND")
services : list[SimpleService]
A list of :class:`SimpleService` objects
"""

def __init__(self, service_node):
r"""
Initialize a :class:`CompoundService` object.
"""Initialize a :class:`CompoundService` object.
Parameters
----------
Expand All @@ -410,8 +413,7 @@ def __init__(self, service_node):


def _find_base_tds_url(catalog_url):
"""
Identify the base URL of the THREDDS server from the catalog URL.
"""Identify the base URL of the THREDDS server from the catalog URL.
Will retain URL scheme, host, port and username/password when present.
"""
Expand All @@ -423,9 +425,7 @@ def _find_base_tds_url(catalog_url):


def _get_latest_cat(catalog_url):
r"""
Get the latest dataset catalog from the supplied top level dataset catalog
url.
"""Get the latest dataset catalog from the supplied top level dataset catalog url.
Parameters
----------
Expand All @@ -448,10 +448,10 @@ def _get_latest_cat(catalog_url):


def get_latest_access_url(catalog_url, access_method):
r"""
Get the data access url, using a specified access method, to the latest
data available from a top level dataset catalog (url). Currently only
supports the existence of one "latest" dataset.
"""Get the data access url to the latest data using a specified access method.
These are available for a data available from a top level dataset catalog (url).
Currently only supports the existence of one "latest" dataset.
Parameters
----------
Expand All @@ -466,8 +466,8 @@ def get_latest_access_url(catalog_url, access_method):
Data access URL to be used to access the latest data available from a
given catalog using the specified `access_method`. Typically a single string,
but not always.
"""
"""
latest_cat = _get_latest_cat(catalog_url)
if latest_cat != '':
if len(list(latest_cat.datasets.keys())) > 0:
Expand Down
1 change: 1 addition & 0 deletions siphon/cdmr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Support for using CDMRemote on a THREDDS Data Server (TDS)."""

from .dataset import Dataset

Expand Down
10 changes: 10 additions & 0 deletions siphon/cdmr/cdmremote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2013-2015 University Corporation for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Support talking to the CDMRemote endpoint on a THREDDS Data Server (TDS)."""

from io import BytesIO

Expand All @@ -9,29 +10,37 @@


class CDMRemote(HTTPEndPoint):
"""Provide access to the various methods on the CDMRemote endpoint on a TDS."""

def __init__(self, url):
"""Initialize access to a particular url."""
super(CDMRemote, self).__init__(url)
self.deflate = 0

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

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

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

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

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

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

def query(self):
Expand All @@ -43,6 +52,7 @@ def query(self):
-------
HTTPQuery
The created query.
"""
q = super(CDMRemote, self).query()

Expand Down
4 changes: 3 additions & 1 deletion siphon/cdmr/cdmremotefeature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2016 University Corporation for Atmospheric Research/Unidata.
# Distributed under the terms of the MIT License.
# SPDX-License-Identifier: MIT
"""Provide access to the CDMRemoteFeature endpoint on TDS."""

from io import BytesIO

Expand All @@ -9,7 +10,8 @@


class CDMRemoteFeature(NCSS):
"""Simple wrapper for speaking to CDMRemoteFeature HTTP endpoint"""
"""Communicate to the CDMRemoteFeature HTTP endpoint."""

@staticmethod
def _parse_messages(resp):
"""Parse server responses as CDMRemoteFeature messages."""
Expand Down
Loading

0 comments on commit 4bee767

Please sign in to comment.