From f10b407577dee1b33b5260161def332a33ca9cd1 Mon Sep 17 00:00:00 2001
From: Thorsten Alteholz <debian@alteholz.de>
Date: Wed, 2 Nov 2022 23:14:11 +0100
Subject: [PATCH] first round of pylint fixes

---
 pysqm/__init__.py |  1 -
 pysqm/__main__.py |  6 +++---
 pysqm/common.py   | 32 +++++++++++++++++---------------
 pysqm/settings.py | 12 ++++++++++--
 setup.py          |  2 +-
 5 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/pysqm/__init__.py b/pysqm/__init__.py
index f759be3..b067704 100644
--- a/pysqm/__init__.py
+++ b/pysqm/__init__.py
@@ -41,4 +41,3 @@ __status__ = "Development" # "Prototype", "Development", or "Production"
 
 from types import ModuleType
 import sys
-
diff --git a/pysqm/__main__.py b/pysqm/__main__.py
index 1dae668..f13c77f 100644
--- a/pysqm/__main__.py
+++ b/pysqm/__main__.py
@@ -26,9 +26,10 @@ ____________________________
 #from types import ModuleType
 #import sys
 
-import pysqm.main as main
+#import pysqm.main as main
+from pysqm import main
 
-while(1==1):
+while 1==1:
     # Loop forever to make sure the program does not die.
     try:
         main.loop()
@@ -39,4 +40,3 @@ while(1==1):
         print(e)
         print('Trying to restart')
         print('')
-
diff --git a/pysqm/common.py b/pysqm/common.py
index 5d4a909..beeed16 100644
--- a/pysqm/common.py
+++ b/pysqm/common.py
@@ -24,8 +24,8 @@ ____________________________
 '''
 
 import math
-import ephem
 import datetime
+import ephem
 
 # Read the config variables from config.py
 import pysqm.settings as settings
@@ -37,26 +37,28 @@ def define_ephem_observatory():
     OBS.lat = config._observatory_latitude*ephem.pi/180
     OBS.lon = config._observatory_longitude*ephem.pi/180
     OBS.elev = config._observatory_altitude
-    return(OBS)
+    return OBS
 
 def remove_linebreaks(data):
+    '''remove linebreaks from data'''
     # Remove line breaks from data
     data = data.replace('\r\n','')
     data = data.replace('\r','')
     data = data.replace('\n','')
-    return(data)
+    return data
 
 def format_value(data,remove_str=' '):
+    '''format data'''
     # Remove string and spaces from data
     data = remove_linebreaks(data)
     data = data.replace(remove_str,'')
     data = data.replace(' ','')
-    return(data)
+    return data
 
 def format_value_list(data,remove_str=' '):
     # Remove string and spaces from data array/list
     data = [format_value(line,remove_str).split(';') for line in data]
-    return(data)
+    return data
 
 def set_decimals(number,dec=3):
         str_number = str(number)
@@ -64,37 +66,37 @@ def set_decimals(number,dec=3):
         while len(dec_)<=dec:
             dec_=dec_+'0'
 
-        return(int_+'.'+dec_[:dec])
+        return int_+'.'+dec_[:dec]
 
 class observatory(object):
     def read_datetime(self):
-        # Get UTC datetime from the computer.
+        '''Get UTC datetime from the computer.'''
         utc_dt = datetime.datetime.utcnow()
         #utc_dt = datetime.datetime.now() - datetime.timedelta(hours=config._computer_timezone)
                 #time.localtime(); daylight_saving=_.tm_isdst>0
-        return(utc_dt)
+        return utc_dt
 
     def local_datetime(self,utc_dt):
-        # Get Local datetime from the computer, without daylight saving.
-        return(utc_dt + datetime.timedelta(hours=config._local_timezone))
+        '''Get Local datetime from the computer, without daylight saving.'''
+        return utc_dt + datetime.timedelta(hours=config._local_timezone)
 
     def calculate_sun_altitude(self,OBS,timeutc):
-        # Calculate Sun altitude
+        '''Calculate Sun altitude'''
         OBS.date = ephem.date(timeutc)
         Sun = ephem.Sun(OBS)
-        return(Sun.alt)
+        return Sun.alt
 
     def next_sunset(self,OBS):
-        # Next sunset calculation
+        '''Next sunset calculation'''
         previous_horizon = OBS.horizon
         OBS.horizon = str(config._observatory_horizon)
         next_setting = OBS.next_setting(ephem.Sun()).datetime()
         next_setting = next_setting.strftime("%Y-%m-%d %H:%M:%S")
         OBS.horizon = previous_horizon
-        return(next_setting)
+        return next_setting
 
     def is_nighttime(self,OBS):
-        # Is nightime (sun below a given altitude)
+        '''Is nightime (sun below a given altitude)'''
         timeutc = self.read_datetime()
         if self.calculate_sun_altitude(OBS,timeutc)*180./math.pi>config._observatory_horizon:
             return False
diff --git a/pysqm/settings.py b/pysqm/settings.py
index 00e9958..4c96b34 100644
--- a/pysqm/settings.py
+++ b/pysqm/settings.py
@@ -23,28 +23,35 @@ along with PySQM.  If not, see <http://www.gnu.org/licenses/>.
 ____________________________
 '''
 
-import os,sys
+import os
+import sys
 
 
 class ArgParser:
+    '''parse arguments of program'''
+
     def __init__(self,inputfile=False):
         self.parse_arguments(inputfile)
 
     def parse_arguments(self,inputfile):
+        '''"do all the parsing work'''
         import argparse
         # Return config filename
         self.parser = argparse.ArgumentParser()
         self.parser.add_argument('-c', '--config', default="config.py")
-        if (inputfile):
+        if inputfile:
             self.parser.add_argument('-i', '--input', default=None)
         args = self.parser.parse_args()
         vars(self).update(args.__dict__)
 
     def print_help(self):
+        '''print help defined by argparse'''
         self.parser.print_help()
 
 
 class ConfigFile:
+    '''read config file'''
+
     def __init__(self, path="config.py"):
         # Guess the selected dir and config filename
         # Should accept:
@@ -57,6 +64,7 @@ class ConfigFile:
         self.config = None
 
     def read_config_file(self,path):
+        '''do all the work for reading the config file'''
         # Get the absolute path
         abspath = os.path.abspath(path)
         # Is a dir? Then add config.py (default filename)
diff --git a/setup.py b/setup.py
index 75a6ec9..ba769d2 100644
--- a/setup.py
+++ b/setup.py
@@ -23,5 +23,5 @@ setup(name='pysqm',
                    "Operating System :: OS Independent",
                    "Topic :: Scientific/Engineering :: Astronomy",
                    ],
-      long_description=open('README.txt').read()
+      long_description=open('README.txt', encoding="utf-8").read()
       )
-- 
GitLab