move into a package

This commit is contained in:
Jeff Epler 2022-07-30 18:09:33 -05:00
parent e04d70cd9e
commit c5933762bc
No known key found for this signature in database
GPG key ID: D5BF15AB975AB4DE
224 changed files with 160 additions and 144 deletions

View file

@ -3,6 +3,6 @@ Upstream-Name: Bulletin D JSON version
Upstream-Contact: Jeff Epler <jepler@gmail.com>
Source: https://github.com/jepler/bulletind
Files: data/*.json
Files: bulletind/data/*.json
Copyright: Public Domain
License: CC0-1.0

View file

@ -5,7 +5,7 @@ default: mypy
.PHONY: mypy
mypy:
mypy --strict --no-warn-unused-ignores bulletind.py
mypy --strict --no-warn-unused-ignores bulletind/*.py
# Copyright (C) 2022 Jeff Epler <jepler@gmail.com>
# SPDX-FileCopyrightText: 2021 Jeff Epler

View file

@ -9,11 +9,10 @@ import typing
import xml.etree.ElementTree
import bs4
import click
import platformdirs
import requests
# Copyright (C) 2011-2020 Jeff Epler <jepler@gmail.com>
# Copyright (C) 2022 Jeff Epler <jepler@gmail.com>
# SPDX-FileCopyrightText: 2022 Jeff Epler
#
# SPDX-License-Identifier: GPL-3.0-only
@ -27,6 +26,7 @@ DATA_PATHS = [
KEYS = [
("number", int),
("date", str),
("startDate", str),
("DUT1", float),
@ -38,9 +38,10 @@ class BulletinDInfo(typing.TypedDict):
"""Type representing a Bulletin D dictionary"""
date: str
startdate: str
dut1: float
dut1_unit: str
number: int
startdate: str
startutc: float
@ -103,32 +104,3 @@ def get_cached_bulletin_d_data() -> list[BulletinDInfo]:
return typing.cast(BulletinDInfo, json.load(data_file))
return [content(p) for path in DATA_PATHS for p in path.glob("*.json")]
@click.command()
@click.option(
"--cache-only/--no-cache-only",
default=False,
help="Only retrieve cached data files",
)
@click.option(
"--update-package-data/--no-update-package-data",
default=False,
help="Update package data, not user cache",
)
def main(cache_only: bool, update_package_data: bool) -> None:
"""Download and show Bulletin D data in json format"""
if update_package_data:
get_bulletin_d_data([pathlib.Path(__file__).resolve().parent / "data"])
else:
if cache_only:
data = get_cached_bulletin_d_data()
else:
data = get_bulletin_d_data()
data = sorted(data, key=lambda x: typing.cast(float, x.get("number", 0)))
json.dump(data, indent=4, fp=sys.stdout)
print()
if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter

44
bulletind/__main__.py Normal file
View file

@ -0,0 +1,44 @@
#!/usr/bin/python3
# Copyright (C) 2022 Jeff Epler <jepler@gmail.com>
# SPDX-FileCopyrightText: 2022 Jeff Epler
#
# SPDX-License-Identifier: GPL-3.0-only
"""Commandline interface to 'Bulletin D' data"""
import json
import pathlib
import sys
import typing
import click
from . import get_bulletin_d_data, get_cached_bulletin_d_data
@click.command()
@click.option(
"--cache-only/--no-cache-only",
default=False,
help="Only retrieve cached data files",
)
@click.option(
"--update-package-data/--no-update-package-data",
default=False,
help="Update package data, not user cache",
)
def main(cache_only: bool, update_package_data: bool) -> None:
"""Download and show Bulletin D data in json format"""
if update_package_data:
get_bulletin_d_data([pathlib.Path(__file__).resolve().parent / "data"])
else:
if cache_only:
data = get_cached_bulletin_d_data()
else:
data = get_bulletin_d_data()
data = sorted(data, key=lambda x: typing.cast(float, x.get("number", 0)))
json.dump(data, indent=4, fp=sys.stdout)
print()
if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter

View file

@ -0,0 +1 @@
{"number": 21, "date": "1991-04-22", "startdate": "1991-06-20", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 22, "date": "1991-07-02", "startdate": "1991-08-22", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 23, "date": "1991-08-26", "startdate": "1991-10-17", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 24, "date": "1991-10-10", "startdate": "1991-11-21", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 28, "date": "1992-03-30", "startdate": "1992-05-07", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 30, "date": "1992-07-16", "startdate": "1992-09-03", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 31, "date": "1992-08-26", "startdate": "1992-10-22", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 32, "date": "1992-10-14", "startdate": "1992-11-26", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 33, "date": "1992-11-26", "startdate": "1993-01-14", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 36, "date": "1993-02-12", "startdate": "1993-05-06", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 37, "date": "1993-02-12", "startdate": "1993-07-01", "dut1": 0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 39, "date": "1993-08-30", "startdate": "1993-10-07", "dut1": 0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 40, "date": "1993-10-01", "startdate": "1993-11-18", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 41, "date": "1993-11-23", "startdate": "1993-12-30", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 43, "date": "1994-01-31", "startdate": "1994-03-17", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 44, "date": "1994-02-28", "startdate": "1994-04-21", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 46, "date": "1994-06-21", "startdate": "1994-07-01", "dut1": 0.8, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 50, "date": "1993-02-12", "startdate": "1995-02-23", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 51, "date": "1995-01-30", "startdate": "1995-03-16", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 52, "date": "1995-01-30", "startdate": "1995-04-13", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 53, "date": "1995-01-30", "startdate": "1995-05-28", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 54, "date": "1995-05-23", "startdate": "1995-07-13", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 55, "date": "1995-07-17", "startdate": "1995-09-07", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 56, "date": "1995-10-26", "startdate": "1995-10-26", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 57, "date": "1995-11-30", "startdate": "1995-11-30", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 58, "date": "1996-01-01", "startdate": "1996-01-01", "dut1": 0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 59, "date": "1996-02-22", "startdate": "1996-02-22", "dut1": 0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 60, "date": "1996-04-11", "startdate": "1996-04-11", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 61, "date": "1996-05-16", "startdate": "1996-05-16", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 62, "date": "1996-06-17", "startdate": "1996-08-08", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 63, "date": "1996-08-02", "startdate": "1996-10-03", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 64, "date": "1996-10-07", "startdate": "1996-12-05", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 65, "date": "1996-11-29", "startdate": "1997-02-06", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 66, "date": "1997-01-29", "startdate": "1997-03-20", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 67, "date": "1997-03-18", "startdate": "1997-05-08", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 68, "date": "1997-05-07", "startdate": "1997-06-26", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 69, "date": "1997-06-23", "startdate": "1997-07-01", "dut1": 0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 70, "date": "1997-07-17", "startdate": "1997-09-18", "dut1": 0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 71, "date": "1997-08-29", "startdate": "1997-10-30", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 72, "date": "1997-10-24", "startdate": "1997-12-18", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 73, "date": "1997-12-17", "startdate": "1998-02-19", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 74, "date": "1998-02-16", "startdate": "1998-03-26", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 75, "date": "1998-03-27", "startdate": "1998-05-07", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 76, "date": "1998-07-03", "startdate": "1998-08-13", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 77, "date": "1998-10-19", "startdate": "1998-11-26", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 78, "date": "1998-11-18", "startdate": "1999-01-01", "dut1": 0.7, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 79, "date": "1999-02-01", "startdate": "1999-03-04", "dut1": 0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 80, "date": "1999-04-16", "startdate": "1999-05-27", "dut1": 0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 81, "date": "1999-09-07", "startdate": "1999-10-14", "dut1": 0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 82, "date": "1999-11-26", "startdate": "2000-01-06", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 83, "date": "2000-03-02", "startdate": "2000-04-13", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 84, "date": "2000-09-07", "startdate": "2000-10-19", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 85, "date": "2001-01-19", "startdate": "2001-03-01", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 86, "date": "2001-09-03", "startdate": "2001-10-04", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 87, "date": "2002-01-11", "startdate": "2002-02-14", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 88, "date": "2002-09-16", "startdate": "2002-10-24", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 89, "date": "2003-02-26", "startdate": "2003-04-03", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 90, "date": "2004-03-24", "startdate": "2004-04-29", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 91, "date": "2005-02-18", "startdate": "2005-03-17", "dut1": -0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 92, "date": "2005-12-28", "startdate": "2006-01-01", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 93, "date": "2006-03-21", "startdate": "2006-04-27", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 94, "date": "2006-10-04", "startdate": "2006-09-28", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 95, "date": "2006-12-15", "startdate": "2006-12-22", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 96, "date": "2007-02-19", "startdate": "2007-03-15", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 97, "date": "2007-05-16", "startdate": "2007-06-14", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 98, "date": "2007-10-23", "startdate": "2007-11-29", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 99, "date": "2008-02-08", "startdate": "2008-03-13", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 100, "date": "2008-07-02", "startdate": "2008-08-07", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 101, "date": "2008-10-24", "startdate": "2008-11-20", "dut1": -0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 102, "date": "2009-02-09", "startdate": "2009-03-12", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 103, "date": "2009-05-14", "startdate": "2009-06-11", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 104, "date": "2009-10-09", "startdate": "2009-11-12", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 105, "date": "2010-02-05", "startdate": "2010-03-11", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 106, "date": "2010-05-07", "startdate": "2010-06-03", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 107, "date": "2010-11-30", "startdate": "2011-01-06", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 108, "date": "2011-04-11", "startdate": "2011-05-12", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 109, "date": "2011-09-29", "startdate": "2011-11-04", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 110, "date": "2012-01-16", "startdate": "2012-02-09", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 111, "date": "2012-04-10", "startdate": "2012-05-10", "dut1": -0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 112, "date": "2012-06-15", "startdate": "2012-07-01", "dut1": 0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 113, "date": "2012-09-21", "startdate": "2012-10-25", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 114, "date": "2012-12-21", "startdate": "2013-01-31", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 115, "date": "2013-03-18", "startdate": "2013-04-11", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 116, "date": "2013-07-16", "startdate": "2013-08-22", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 117, "date": "2013-10-18", "startdate": "2013-11-21", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 118, "date": "2014-01-17", "startdate": "2014-02-20", "dut1": -0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 119, "date": "2014-04-04", "startdate": "2014-05-08", "dut1": -0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 120, "date": "2014-08-26", "startdate": "2014-09-25", "dut1": -0.4, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 121, "date": "2014-11-21", "startdate": "2014-12-25", "dut1": -0.5, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 122, "date": "2015-02-13", "startdate": "2015-03-19", "dut1": -0.6, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 123, "date": "2015-04-17", "startdate": "2015-05-28", "dut1": -0.7, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 124, "date": "2015-05-28", "startdate": "2015-07-01", "dut1": 0.3, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 125, "date": "2015-09-11", "startdate": "2015-09-17", "dut1": 0.2, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 126, "date": "2015-10-27", "startdate": "2015-11-26", "dut1": 0.1, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 127, "date": "2016-01-04", "startdate": "2016-01-31", "dut1": 0.0, "startutc": 0.0, "dut1_unit": "s"}

View file

@ -0,0 +1 @@
{"number": 128, "date": "2016-02-19", "startdate": "2016-03-24", "dut1": -0.1, "startutc": 0.0, "dut1_unit": "s"}

Some files were not shown because too many files have changed in this diff Show more