diff --git a/docs/source/conf.py b/docs/source/conf.py index 9fd45a2f..e77c2017 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import datetime +from datetime import date import pyiem @@ -49,7 +49,7 @@ # General information about the project. project = "pyIEM" -copyright = "2015-%s, daryl herzmann" % (datetime.date.today().year,) +copyright = f"2015-{date.today().year}, daryl herzmann" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/src/pyiem/dep.py b/src/pyiem/dep.py index 2302cffe..a9a782b6 100644 --- a/src/pyiem/dep.py +++ b/src/pyiem/dep.py @@ -1,8 +1,8 @@ """Utilities for the Daily Erosion Project""" -import datetime import math import re +from datetime import date, timedelta import numpy as np import pandas as pd @@ -80,12 +80,10 @@ def read_yld(filename): xref[cropcode] = label # noqa rows = [] for cropcode, doy, ofe, yld, year in YLD_DATA.findall(data): - date = datetime.date(int(year), 1, 1) + datetime.timedelta( - days=(int(doy) - 1) - ) + dt = date(int(year), 1, 1) + timedelta(days=(int(doy) - 1)) rows.append( dict( - valid=date, + valid=dt, year=int(year), yield_kgm2=float(yld), crop=xref[cropcode], @@ -160,9 +158,7 @@ def man2df(mandict: dict, year1: int = 1) -> pd.DataFrame: > -1 ): doy = surfeff["mdate"] - plant_date = datetime.date( - year, 1, 1 - ) + datetime.timedelta(days=doy - 1) + plant_date = date(year, 1, 1) + timedelta(days=doy - 1) rows.append( { "year": year, @@ -446,7 +442,7 @@ def read_cli(filename, compute_rfactor=False, return_rfactor_metric=True): dr = points[i] - points[i - 1] maxr = max(maxr, dr / dt) linenum += breakpoints + 1 - dates.append(datetime.date(int(year), int(mo), int(da))) + dates.append(date(int(year), int(mo), int(da))) rows.append( { "tmax": float(tmax), diff --git a/src/pyiem/htmlgen.py b/src/pyiem/htmlgen.py index 4abd9d72..ccbbe86f 100644 --- a/src/pyiem/htmlgen.py +++ b/src/pyiem/htmlgen.py @@ -1,4 +1,6 @@ -"""Utility functions that generate HTML.""" +""" +Utility functions that generate HTML. +""" from pyiem.network import Table as NetworkTable @@ -43,15 +45,15 @@ def make_select( ) -> str: """Generate a HTML select element. - The trick here is what `data` looks like. The basic form is a ``dict``. - You can get `optgroup`s by having the dictionary keys be additional + The trick here is what ``data`` looks like. The basic form is a ``dict``. + You can get ``optgroup`` by having the dictionary keys be additional lists or dicts. Args: name (str): The select name attribute to assign. selected (mixed): The option value that should be set to selected. data (dict): The structure to build our select from. - jscallback (str): javascript to place in the `onChange` attribute. + jscallback (str): javascript to place in the ``onChange`` attribute. cssclass (str): CSS class to assign to the select element. showvalue (bool): Should option label be prepended by key label.