From c3e7acc7a05158cfa20a36dfedca1448ed5cb409 Mon Sep 17 00:00:00 2001 From: David Polverari Date: Tue, 13 Feb 2024 19:19:59 -0300 Subject: [PATCH] Avoid invalid Python escape sequences When installing the program on Debian 12, there were some warnings about the usage of invalid Python escape sequences on some lines, mostly related to regular expressions and Windows paths. This patch avoids those cases by using Python raw strings instead. --- src/pythonprop/templates/area_userdefined.py | 2 +- src/pythonprop/voaAntennaChooser.py | 2 +- src/pythonprop/voaSiteChooser.py | 2 +- src/pythonprop/voacapgui.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pythonprop/templates/area_userdefined.py b/src/pythonprop/templates/area_userdefined.py index 1c2e632..b952351 100644 --- a/src/pythonprop/templates/area_userdefined.py +++ b/src/pythonprop/templates/area_userdefined.py @@ -59,7 +59,7 @@ def get_params(self): def load(self): if not self.area_templates_file: return -1 - re_tag_name = re.compile('\[(.*)\]') + re_tag_name = re.compile(r'\[(.*)\]') fd = None try: fd = open(os.path.expandvars(self.area_templates_file)) diff --git a/src/pythonprop/voaAntennaChooser.py b/src/pythonprop/voaAntennaChooser.py index d36a044..55af888 100644 --- a/src/pythonprop/voaAntennaChooser.py +++ b/src/pythonprop/voaAntennaChooser.py @@ -84,7 +84,7 @@ def run(self): testLine = f.readline() f.close() if (testLine.find("parameters") == 9): - antenna_description = re.sub('\s+', ' ', antenna_description) + antenna_description = re.sub(r'\s+', ' ', antenna_description) antenna_file = os.path.relpath(antenna_file, self.antenna_path) if len(antenna_file) > 21: err_msg_body = "The file path ('{:s}')\nis too long and should be less than 21 characters.\n\nPlease rename the antenna file.".format(antenna_file) diff --git a/src/pythonprop/voaSiteChooser.py b/src/pythonprop/voaSiteChooser.py index d2206e3..af83cd9 100644 --- a/src/pythonprop/voaSiteChooser.py +++ b/src/pythonprop/voaSiteChooser.py @@ -144,7 +144,7 @@ def __init__(self, location=HamLocation(), map_size=(), itshfbc_path = '', paren #sm.set_select_function(self.geo_tv_selected, False) # todo pygobject check this (it's just a guess) sm.connect("changed", self.geo_tv_selected) - self.alpha_numeric_re = re.compile('[\W_]+') + self.alpha_numeric_re = re.compile(r'[\W_]+') self.latitude_column = 0 self.longitude_column = 0 diff --git a/src/pythonprop/voacapgui.py b/src/pythonprop/voacapgui.py index 83f0ffd..72aa2e1 100644 --- a/src/pythonprop/voacapgui.py +++ b/src/pythonprop/voacapgui.py @@ -98,8 +98,8 @@ class VOACAP_GUI(): # Determine where the itshfbc and prefs files are, based on OS # The windows paths are guesses and need checking.... if os.name == 'nt': - itshfbc_path = 'C:\itshfbc' - prefs_dir = 'C:\itshfbc\database\\' + itshfbc_path = r'C:\itshfbc' + prefs_dir = r'C:\itshfbc\database' + '\\' else: itshfbc_path = os.path.expanduser("~")+os.sep+'itshfbc' prefs_dir = os.path.expanduser("~")+os.sep+'.voacapgui'+os.sep