From f545dfd0cd8b69006b26e32838d125dab085997f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Deuchnord?= Date: Fri, 1 Nov 2019 12:29:59 +0100 Subject: [PATCH] Fix Python files header --- .pylintrc | 2 +- dumper.py | 2 ++ ephemeris.py | 30 ++++++++++++++++-------------- kosmorro.py | 2 ++ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.pylintrc b/.pylintrc index 2096239..9208a70 100644 --- a/.pylintrc +++ b/.pylintrc @@ -30,7 +30,7 @@ limit-inference-results=100 # usually to register additional checkers. load-plugins=pylintfileheader -file-header=# Kosmorro - Compute The Next Ephemeris\n# Copyright \(C\) 2019 Jérôme Deuchnord \n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as\n# published by the Free Software Foundation, either version 3 of the\n# License, or \(at your option\) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with this program. If not, see . +file-header=#!/usr/bin/env python3\n\n# Kosmorro - Compute The Next Ephemeris\n# Copyright \(C\) 2019 Jérôme Deuchnord \n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as\n# published by the Free Software Foundation, either version 3 of the\n# License, or \(at your option\) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with this program. If not, see .\n\n # Pickle collected data for later comparisons. persistent=yes diff --git a/dumper.py b/dumper.py index 24d6a57..650f8bd 100644 --- a/dumper.py +++ b/dumper.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Kosmorro - Compute The Next Ephemeris # Copyright (C) 2019 Jérôme Deuchnord # diff --git a/ephemeris.py b/ephemeris.py index 53752cf..1343c7e 100644 --- a/ephemeris.py +++ b/ephemeris.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Kosmorro - Compute The Next Ephemeris # Copyright (C) 2019 Jérôme Deuchnord # @@ -37,18 +39,6 @@ class Ephemeris: self.longitude = position['lon'] self.position = Topos(latitude_degrees=position['lat'], longitude_degrees=position['lon']) - def compute_ephemeris_for_day(self, year: int, month: int, day: int) -> dict: - ephemeris = {} - time1 = self.timescale.utc(year, month, day, 2) - time2 = self.timescale.utc(year, month, day + 1, 2) - - # Compute sunrise and sunset - ephemeris['sun'] = self.get_sun(time1, time2) - ephemeris['moon'] = self.get_moon(year, month, day) - ephemeris['planets'] = self.get_planets(year, month, day) - - return ephemeris - def get_sun(self, start_time, end_time) -> dict: times, is_risen = almanac.find_discrete(start_time, end_time, @@ -167,6 +157,18 @@ class Ephemeris: 'set': set_time if set_time is not None else None } + def compute_ephemerides_for_day(self, year: int, month: int, day: int) -> dict: + ephemeris = {} + time1 = self.timescale.utc(year, month, day, 2) + time2 = self.timescale.utc(year, month, day + 1, 2) + + # Compute sunrise and sunset + ephemeris['sun'] = self.get_sun(time1, time2) + ephemeris['moon'] = self.get_moon(year, month, day) + ephemeris['planets'] = self.get_planets(year, month, day) + + return ephemeris + def compute_ephemerides_for_month(self, year: int, month: int) -> list: if month == 2: is_leap_year = (year % 4 == 0 and year % 100 > 0) or (year % 400 == 0) @@ -179,7 +181,7 @@ class Ephemeris: ephemerides = [] for day in range(1, max_day + 1): - ephemerides.append(self.compute_ephemeris_for_day(year, month, day)) + ephemerides.append(self.compute_ephemerides_for_day(year, month, day)) return ephemerides @@ -216,7 +218,7 @@ class Ephemeris: def compute_ephemeris(self, year: int, month: int, day: int): if day is not None: - return self.compute_ephemeris_for_day(year, month, day) + return self.compute_ephemerides_for_day(year, month, day) if month is not None: return self.compute_ephemerides_for_month(year, month) diff --git a/kosmorro.py b/kosmorro.py index 00f7b79..91d965e 100644 --- a/kosmorro.py +++ b/kosmorro.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + # Kosmorro - Compute The Next Ephemeris # Copyright (C) 2019 Jérôme Deuchnord #