raw strings for regexes

This commit is contained in:
Gaspard Jankowiak 2024-03-01 14:50:02 +01:00
parent b4624e6dd6
commit f8e38b7dd8

View file

@ -114,15 +114,15 @@ class Reading:
options={} options={}
for i in range(len(self.OPT)): for i in range(len(self.OPT)):
if re.match( "^DATA_FILE:$", self.OPT[i][0] ): if re.match( r"^DATA_FILE:$", self.OPT[i][0] ):
options['datafile'] = str(self.OPT[i][1]) options['datafile'] = str(self.OPT[i][1])
file_exists(options['datafile'], "Data File") file_exists(options['datafile'], "Data File")
elif re.match( "^TITLE:$", self.OPT[i][0] ): elif re.match( r"^TITLE:$", self.OPT[i][0] ):
options['title'] = str(self.OPT[i][1]) options['title'] = str(self.OPT[i][1])
print("Title:\t\t", options['title']) print("Title:\t\t", options['title'])
elif re.match( "^SAVE_FOLDER:$", self.OPT[i][0] ): elif re.match( r"^SAVE_FOLDER:$", self.OPT[i][0] ):
options['folder'] = str(self.OPT[i][1]) options['folder'] = str(self.OPT[i][1])
if os.path.exists(options['folder'])==0: if os.path.exists(options['folder'])==0:
os.makedirs(options['folder']) os.makedirs(options['folder'])
@ -131,34 +131,34 @@ class Reading:
elif os.path.exists(options['folder'])==1: elif os.path.exists(options['folder'])==1:
print("Saving Folder:\t", options['folder']) print("Saving Folder:\t", options['folder'])
elif re.match( "^q_MIN\(nm\^-1\):$", self.OPT[i][0] ): elif re.match( r"^q_MIN\(nm\^-1\):$", self.OPT[i][0] ):
options['qmin'] = check_float_positive(self.OPT[i][1], "qmin") options['qmin'] = check_float_positive(self.OPT[i][1], "qmin")
print("q range:\t(%s .." %options['qmin'], ) print("q range:\t(%s .." %options['qmin'], )
elif re.match( "^q_MAX\(nm\^-1\):$", self.OPT[i][0] ): elif re.match( r"^q_MAX\(nm\^-1\):$", self.OPT[i][0] ):
options['qmax'] = check_float_positive(self.OPT[i][1], "qmax") options['qmax'] = check_float_positive(self.OPT[i][1], "qmax")
print("%s) nm^-1\n" %options['qmax'], ) print("%s) nm^-1\n" %options['qmax'], )
elif re.match( "^MODEL:$", self.OPT[i][0] ): elif re.match( r"^MODEL:$", self.OPT[i][0] ):
options['function'] = str(self.OPT[i][1]) options['function'] = str(self.OPT[i][1])
print("Function:\t", options['function']) print("Function:\t", options['function'])
elif re.match( "^TEMPERATURE\(none=0\):$", self.OPT[i][0] ): elif re.match( r"^TEMPERATURE\(none=0\):$", self.OPT[i][0] ):
options['temp'] = check_float_positive(self.OPT[i][1], "Temperarure") options['temp'] = check_float_positive(self.OPT[i][1], "Temperarure")
if options['temp'] != 0: if options['temp'] != 0:
print("Temperarure:\t", options['temp']) print("Temperarure:\t", options['temp'])
else: else:
print("Temperarure:\tNo Simulated Annealing") print("Temperarure:\tNo Simulated Annealing")
elif re.match( "^BINNING:$", self.OPT[i][0] ): elif re.match( r"^BINNING:$", self.OPT[i][0] ):
options['bing'] = check_int(self.OPT[i][1], "Binning") options['bing'] = check_int(self.OPT[i][1], "Binning")
print("Binning:\t", options['bing']) print("Binning:\t", options['bing'])
elif re.match( "^ERROR\(0\.\.1\):$", self.OPT[i][0] ): elif re.match( r"^ERROR\(0\.\.1\):$", self.OPT[i][0] ):
options['err_mul'] = check_float_positive(self.OPT[i][1], "Error Mult.") options['err_mul'] = check_float_positive(self.OPT[i][1], "Error Mult.")
print("Error Mult.:\t", options['err_mul']) print("Error Mult.:\t", options['err_mul'])
elif re.match( "^PLOT\(0-1\):$", self.OPT[i][0] ): elif re.match( r"^PLOT\(0-1\):$", self.OPT[i][0] ):
options['plot'] = check_int(self.OPT[i][1], "Plot") options['plot'] = check_int(self.OPT[i][1], "Plot")
check_binary(options['plot'], "Plot") check_binary(options['plot'], "Plot")
print("Plot:\t\t", options['plot']) print("Plot:\t\t", options['plot'])
@ -186,7 +186,7 @@ class Reading:
L_LIM=[] L_LIM=[]
H_LIM=[] H_LIM=[]
for i in range(len(self.PARA)): for i in range(len(self.PARA)):
if not re.match( "^#" , self.PARA[i][0] ): if not re.match( r"^#" , self.PARA[i][0] ):
NAME.append(self.PARA[i][0]) NAME.append(self.PARA[i][0])
PAR.append(float(self.PARA[i][1])) PAR.append(float(self.PARA[i][1]))
FIX.append(self.PARA[i][2]) FIX.append(self.PARA[i][2])
@ -241,7 +241,7 @@ class Reading:
L_LIM=[] L_LIM=[]
H_LIM=[] H_LIM=[]
for i in range(len(self.PARA)): for i in range(len(self.PARA)):
if not re.match( "^#" , self.PARA[i][0] ): if not re.match( r"^#" , self.PARA[i][0] ):
NAME.append(self.PARA[i][0]) NAME.append(self.PARA[i][0])
PAR.append(float(self.PARA[i][1])) PAR.append(float(self.PARA[i][1]))
FIX.append(self.PARA[i][2]) FIX.append(self.PARA[i][2])