diff --git a/gwdatafind/__main__.py b/gwdatafind/__main__.py index f3f48e3ecac6c545bf3e6d910e4b0092bcc525a9..486a45568e89444cce649c48c82578d554922710 100644 --- a/gwdatafind/__main__.py +++ b/gwdatafind/__main__.py @@ -15,8 +15,7 @@ # You should have received a copy of the GNU General Public License # along with GWDataFind. If not, see <http://www.gnu.org/licenses/>. -"""Query a GWDataFind server for information. -""" +"""Query a GWDataFind server for information.""" import argparse import re @@ -44,7 +43,7 @@ class DataFindFormatter( argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter, ): - pass + """Custom `argparse.Formatter` for GWDataFind.""" class DataFindArgumentParser(argparse.ArgumentParser): @@ -52,16 +51,15 @@ class DataFindArgumentParser(argparse.ArgumentParser): Mainly to handle the legacy mutually-exclusive optional arguments... """ + def __init__(self, *args, **kwargs): - """Create a new `DataFindArgumentParser`. - """ + """Create a new `DataFindArgumentParser`.""" kwargs.setdefault("formatter_class", DataFindFormatter) super().__init__(*args, **kwargs) self._optionals.title = "Optional arguments" def parse_args(self, *args, **kwargs): - """Parse arguments with an extra sanity check. - """ + """Parse arguments with an extra sanity check.""" args = super().parse_args(*args, **kwargs) args.show_urls = not any((args.ping, args.show_observatories, args.show_types, args.show_times, @@ -100,8 +98,7 @@ class DataFindArgumentParser(argparse.ArgumentParser): def command_line(): - """Build an `~argparse.ArgumentParser` for the `gwdatafind` CLI. - """ + """Build an `~argparse.ArgumentParser` for the `gwdatafind` CLI.""" try: defhost = get_default_host() except ValueError: @@ -524,8 +521,7 @@ def postprocess_cache(urls, args, out): # -- CLI ---------------------------------------------------------------------- def main(args=None): - """Run the thing. - """ + """Run the thing.""" # parse command line parser = command_line() opts = parser.parse_args(args=args) diff --git a/gwdatafind/api.py b/gwdatafind/api.py index 51fc1e746765988fe18d3500cfe8a3cc189fb0e2..a8b5f579c31304313135970a60578f213e03658e 100644 --- a/gwdatafind/api.py +++ b/gwdatafind/api.py @@ -45,22 +45,19 @@ def _prefix(func): @_prefix def ping_path(ext=DEFAULT_EXT): - """Return the API path to ping the server. - """ + """Return the API path to ping the server.""" return f"{ext}/H/R/1,2" @_prefix def find_observatories_path(ext=DEFAULT_EXT): - """Return the API path to query for all observatories. - """ + """Return the API path to query for all observatories.""" return f"{ext}.json" @_prefix def find_types_path(site=None, ext=DEFAULT_EXT): - """Return the API path to query for datasets for one or all sites. - """ + """Return the API path to query for datasets for one or all sites.""" if site: return f"{ext}/{site}.json" return f"{ext}/all.json" @@ -68,8 +65,7 @@ def find_types_path(site=None, ext=DEFAULT_EXT): @_prefix def find_times_path(site, frametype, start, end, ext=DEFAULT_EXT): - """Return the API path to query for data availability segments. - """ + """Return the API path to query for data availability segments.""" if start is None and end is None: return f"{ext}/{site}/{frametype}/segments.json" return f"{ext}/{site}/{frametype}/segments/{start},{end}.json" @@ -77,8 +73,7 @@ def find_times_path(site, frametype, start, end, ext=DEFAULT_EXT): @_prefix def find_url_path(framefile): - """Return the API path to query for the URL of a specific filename. - """ + """Return the API path to query for the URL of a specific filename.""" filename = basename(framefile) ext = filename.split(".", 1)[1] site, frametype, _ = filename.split("-", 2) @@ -87,8 +82,7 @@ def find_url_path(framefile): @_prefix def find_latest_path(site, frametype, urltype, ext=DEFAULT_EXT): - """Return the API path to query for the latest file in a dataset. - """ + """Return the API path to query for the latest file in a dataset.""" stub = f"{ext}/{site}/{frametype}/latest" if urltype: return f"{stub}/{urltype}.json" @@ -105,8 +99,7 @@ def find_urls_path( match=None, ext=DEFAULT_EXT, ): - """Return the API path to query for all URLs for a dataset in an interval. - """ + """Return the API path to query for all URLs for a dataset in an interval.""" stub = f"{ext}/{site}/{frametype}/{start},{end}" if urltype: path = f"{stub}/{urltype}.json" diff --git a/gwdatafind/io.py b/gwdatafind/io.py index acf778083c9c7efff2699adaa868b6d1d93ce7c0..cc70276209851b4f26b4f4f07e8bfeee3d24affb 100644 --- a/gwdatafind/io.py +++ b/gwdatafind/io.py @@ -15,8 +15,7 @@ # You should have received a copy of the GNU General Public License # along with GWDataFind. If not, see <http://www.gnu.org/licenses/>. -"""I/O (mainly O) routines for GWDataFind. -""" +"""I/O (mainly O) routines for GWDataFind.""" import os.path from collections import namedtuple @@ -35,7 +34,9 @@ class LalCacheEntry( This is provided so that we don't have to depend on lalsuite. """ + def __str__(self): + """Return a `str` representation of this `LalCacheEntry`.""" seg = self.segment return " ".join(map(str, ( self.obs, @@ -47,8 +48,7 @@ class LalCacheEntry( @classmethod def from_url(cls, url, **kwargs): - """Create a new `LalCacheEntry` from a URL that follows LIGO-T050017. - """ + """Create a new `LalCacheEntry` from a URL that follows LIGO-T050017.""" obs, tag, seg = filename_metadata(url) return cls(obs, tag, seg, url) @@ -74,7 +74,9 @@ class OmegaCacheEntry(namedtuple( <obs> <tag> <dir-start> <dir-end> <file-duration> <directory> """ + def __str__(self): + """Return a `str` representation of this `OmegaCacheEntry`.""" return " ".join(map(str, ( self.obs, self.tag, diff --git a/gwdatafind/ui.py b/gwdatafind/ui.py index 0761d711c0db5a687c366475de12b8eabdcad808..4c051afdc1fa6a55c47f7f416c25737601909e95 100644 --- a/gwdatafind/ui.py +++ b/gwdatafind/ui.py @@ -80,7 +80,7 @@ def get_json(*args, **kwargs): data : `object` the URL reponse parsed with :func:`json.loads` - See also + See Also -------- igwn_auth_utils.requests.get for information on how the request is performed diff --git a/gwdatafind/utils.py b/gwdatafind/utils.py index 8230d5d3542a51f93546e169fcdab07905984033..7d323134909df34bb2a2ef4a03370a50fd89d45d 100644 --- a/gwdatafind/utils.py +++ b/gwdatafind/utils.py @@ -16,8 +16,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -"""Utilities for the GW datafind service. -""" +"""Utilities for the GW datafind service.""" import os import warnings