From eec0c342d87cc392643950c3a54ba3b39c2c2521 Mon Sep 17 00:00:00 2001 From: Peter Howell Date: Fri, 29 Aug 2025 23:54:10 +0000 Subject: [PATCH] raw strings fix --- localcache.py | 9 ++++----- server.py | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/localcache.py b/localcache.py index 243b848..2668751 100644 --- a/localcache.py +++ b/localcache.py @@ -157,7 +157,7 @@ def setup_table(table='requests'): for L in open('cache/request_table.txt','r').readlines(): L = L.strip() #print(L) - (col,type) = re.split("\s\s\s\s",L) + (col,type) = re.split(r"\s\s\s\s",L) if not first: q += ",\n" first = 0 @@ -1159,13 +1159,13 @@ def guess_dept(t): method = 2 # xlisted takes dept first listed if method==1: - p = "^([A-Z/]+)\d+" + p = r"^([A-Z/]+)\d+" m = re.search(p, t['code']) if m: return m.group(1) return '?' if method==2: - p = "^([A-Z]+)[\d/]+" + p = r"^([A-Z]+)[\d/]+" m = re.search(p, t['code']) if m: return m.group(1) @@ -1700,7 +1700,7 @@ ORDER BY u.sortablename;""" def build_db_schedule(): # from the schedule json files - target = "\_sched\_expanded\.json" + target = r"\_sched\_expanded\.json" def finder(st): return re.search(target,st) @@ -2132,4 +2132,3 @@ if __name__ == "__main__": # Call the function in the options dict options[ int(resp)][1]() - diff --git a/server.py b/server.py index 9db0b74..d004ab1 100644 --- a/server.py +++ b/server.py @@ -201,20 +201,20 @@ def homepage(): a('want to shut down?','/sd') + "
" + \ a('', '') + br -def orgline(L): - L.strip() - if re.search("^\s*$", L): return "" - - a = re.search( '^\*\s(.*)$', L) - if a: return "

%s

\n" % a.group(1) - - b = re.search( 'TODO\s\[\#A\](.*)$', L) - if b: return "Todo - Priority 1: %s" % b.group(1) + br + nl - - d = re.search( '^\*\*\*\s(.*)$', L) - if d: return d.group(1) - d = re.search( '^\*\*\s(.*)$', L) - if d: L = d.group(1) +def orgline(L): + L.strip() + if re.search(r"^\s*$", L): return "" + + a = re.search( r'^\*\s(.*)$', L) + if a: return "

%s

\n" % a.group(1) + + b = re.search( r'TODO\s\[\#A\](.*)$', L) + if b: return "Todo - Priority 1: %s" % b.group(1) + br + nl + + d = re.search( r'^\*\*\*\s(.*)$', L) + if d: return d.group(1) + d = re.search( r'^\*\*\s(.*)$', L) + if d: L = d.group(1) return L + br + nl @@ -450,7 +450,7 @@ def lectures(): #print(f) with tag('item'): name = f.split('.')[0] - ff = re.sub('\s','%20',f) + ff = re.sub(r'\s','%20',f) with tag('title'): text(name) with tag('guid'): text(f) b = os.path.getsize(LECPATH+f) @@ -520,8 +520,8 @@ def staff_dir(search=''): ###### -def find_goo(n): - g = re.search('00(\d\d\d\d\d\d)', n) +def find_goo(n): + g = re.search(r'00(\d{6})', n) if g: return g.groups()[0]