From 74aa531715ac08b9084633ace4c5859f902bbdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 21 Nov 2019 11:16:24 +0200 Subject: [PATCH] remove tools.py --- misc/deg.py | 6 +++++- misc/tools.py | 26 -------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 misc/tools.py diff --git a/misc/deg.py b/misc/deg.py index 8012f1d..d678a7b 100644 --- a/misc/deg.py +++ b/misc/deg.py @@ -1,6 +1,10 @@ +from collections import namedtuple + from decimal import Decimal as Dec -Deg = namedtuple('Deg', ['hh', 'mm', 'ss']) +class Deg(namedtuple('Deg', ['deg', 'mm', 'ss'])): + def __str__(self): + return "%03d-%02d-%.1f" % (self.deg, self.mm, self.ss) def guess(inp): if isinstance(inp, Dec): diff --git a/misc/tools.py b/misc/tools.py deleted file mode 100644 index 4a82d81..0000000 --- a/misc/tools.py +++ /dev/null @@ -1,26 +0,0 @@ -from decimal import Decimal - -class Deg: - def __str__(self): - return "%03d - %02d - %02d" % (self.deg, self.mm, self.ss) - - def __init__(self, deg, mm, ss): - self.deg = Decimal(deg) - self.mm = Decimal(mm) - self.ss = Decimal(ss) - - @staticmethod - def from_1(deg): - assert isinstance(deg, Decimal) - - pdeg, pmm = divmod(deg, 1) - pmm = pmm * Decimal(60) - pmm, pss = divmod(pmm, 1) - pss = pss * Decimal(60) - return Deg(pdeg, pmm, pss) - - def frac(self): - return ( - self.deg + - self.mm / Decimal(60) + - self.ss / Decimal(3600)).normalize()