Skip to content

Commit

Permalink
Merge pull request #9 from jepler/leapsecond-urls
Browse files Browse the repository at this point in the history
ietf no longer serves leapseconddata, use alternate sources
  • Loading branch information
jepler authored Oct 3, 2023
2 parents 053543c + 7724600 commit 9f044a0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 47 deletions.
37 changes: 17 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,37 @@ jobs:
strategy:
matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- 'pypy-3.7'
- '3.11'
- '3.12.0-alpha.0 - 3.12'
- 'pypy-3.9'
os-version:
- 'ubuntu-latest'
include:
- os-version: 'macos-latest'
python-version: '3.x'
- os-version: 'windows-latest'
python-version: '3.x'

env:
PYTHON: ${{ matrix.python-version }}

runs-on: ubuntu-latest
runs-on: ${{ matrix.os-version }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2.2.0
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install deps
run: python -mpip install -r requirements-dev.txt

- name: Check stubs
if: (! startsWith(matrix.python-version, 'pypy-'))
if: (startsWith(matrix.python-version, '3.12') && startswith(matrix.os-version, 'ubuntu-'))
run: mypy --strict *.py

- name: Test
Expand All @@ -75,12 +78,6 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- name: set PY
run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')"
- uses: actions/cache@v1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.1.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/action@v3.0.0
49 changes: 24 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@
#
# SPDX-License-Identifier: Unlicense

default_language_version:
python: python3

repos:
- repo: https://github.com/python/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: tests
- id: trailing-whitespace
exclude: tests
- repo: https://github.com/fsfe/reuse-tool
rev: v1.0.0
hooks:
- id: reuse
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
types: [python]
additional_dependencies: [beautifulsoup4, "pylint==2.15.3", requests, adafruit-circuitpython-datetime, click, python-dateutil]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ['--profile', 'black']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: tests
- id: trailing-whitespace
exclude: tests
- repo: https://github.com/fsfe/reuse-tool
rev: v2.1.0
hooks:
- id: reuse
- repo: https://github.com/pycqa/pylint
rev: v2.17.1
hooks:
- id: pylint
6 changes: 4 additions & 2 deletions leapseconddata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def to_tai(
:param when: Moment in time to convert. If naive, it is assumed to be in UTC.
:param check_validity: Check whether the database is valid for the given moment
Naive timestamps are assumed to be UTC. A TAI timestamp is returned unchanged."""
Naive timestamps are assumed to be UTC. A TAI timestamp is returned unchanged.
"""
if datetime_is_tai(when):
return when
when = self._utc_datetime(when)
Expand Down Expand Up @@ -213,7 +214,8 @@ def from_standard_source(
for location in [ # pragma no branch
"file:///usr/share/zoneinfo/leap-seconds.list", # Debian Linux
"file:///var/db/ntpd.leap-seconds.list", # FreeBSD
"https://www.ietf.org/timezones/data/leap-seconds.list",
"https://raw.githubusercontent.com/eggert/tz/main/leap-seconds.list",
"https://www.meinberg.de/download/ntp/leap-seconds.list",
]:
logging.debug("Trying leap second data from %s", location)
try:
Expand Down

0 comments on commit 9f044a0

Please sign in to comment.