From cfc871cce6aefaa0ff64619780a807cba761c6b2 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 30 Jan 2023 12:20:23 +0100 Subject: ... --- tools/tai64dec/default.nix | 18 --------------- tools/tai64dec/setup.py | 10 -------- tools/tai64dec/tai64dec/__main__.py | 46 ------------------------------------- 3 files changed, 74 deletions(-) delete mode 100644 tools/tai64dec/default.nix delete mode 100644 tools/tai64dec/setup.py delete mode 100644 tools/tai64dec/tai64dec/__main__.py (limited to 'tools/tai64dec') diff --git a/tools/tai64dec/default.nix b/tools/tai64dec/default.nix deleted file mode 100644 index 380c22bf..00000000 --- a/tools/tai64dec/default.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ system, self, mach-nix, leapseconds, ... }: -let - pkgs = self.legacyPackages.${system}; -in mach-nix.lib.${system}.buildPythonPackage { - pname = "tai64dec"; - src = pkgs.lib.sourceByRegex ./. ["^setup\.py$" "^tai64dec(/[^/]+.*)?$"]; - version = "0.0.0"; - ignoreDataOutdated = true; - - requirements = '' - leapseconddata - ''; - - postInstall = '' - wrapProgram $out/bin/tai64dec \ - --set-default LEAPSECONDS_FILE ${leapseconds} - ''; -} diff --git a/tools/tai64dec/setup.py b/tools/tai64dec/setup.py deleted file mode 100644 index d936796b..00000000 --- a/tools/tai64dec/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -from setuptools import setup - -setup(name='tai64dec', - packages=['tai64dec'], - entry_points={ - 'console_scripts': [ - 'tai64dec=tai64dec.__main__:main' - ], - }, -) diff --git a/tools/tai64dec/tai64dec/__main__.py b/tools/tai64dec/tai64dec/__main__.py deleted file mode 100644 index a8854523..00000000 --- a/tools/tai64dec/tai64dec/__main__.py +++ /dev/null @@ -1,46 +0,0 @@ -import sys, os - -import argparse - -from leapseconddata import LeapSecondData -from math import ldexp -from pathlib import Path -from datetime import datetime, timezone -import secrets - - -class BooleanAction(argparse.Action): - def __init__(self, option_strings, dest, nargs=None, **kwargs): - super(BooleanAction, self).__init__(option_strings, dest, nargs=0, **kwargs) - - def __call__(self, parser, namespace, values, option_string=None): - setattr(namespace, self.dest, False if option_string.startswith('--no') else True) - - -def main(): - parser = argparse.ArgumentParser(prog='tai64dec', formatter_class=argparse.ArgumentDefaultsHelpFormatter) - parser.add_argument('--random', '--no-random', action=BooleanAction, default=False) - parser.add_argument('--ns', '--no-ns', action=BooleanAction, default=True) - args = parser.parse_args() - - - leapsecond_data = LeapSecondData.from_file(Path(os.getenv('LEAPSECONDS_FILE'))) - - now = datetime.now(tz=timezone.utc) - - tai_dt = leapsecond_data.to_tai(now) - seconds = int(tai_dt.timestamp()) - seconds += int(ldexp(1, 62)) - out = seconds - - if args.ns: - nanoseconds = int((tai_dt.timestamp() - seconds) / 1e-9) - out = out << 32 | nanoseconds - - if args.random: - out = out << 24 | int.from_bytes(secrets.token_bytes(3), byteorder='little', signed=False) - - print('{:d}'.format(out), file=sys.stdout) - -if __name__ == '__main__': - sys.exit(main()) -- cgit v1.2.3