mirror of
https://github.com/samba-team/samba.git
synced 2025-12-20 16:23:51 +03:00
python: use raw string for regex with escape
Python regards 'GPT\.INI$' as a string containing an invalid escape
sequence '\.', which is ignored (i.e. treated as the literal sequence
of those 2 characters), but only after Python has grumbled to itself,
and to you if you enabled DeprecationWarnings.
The proper thing to do here is use r-strings, like r'GPT\.INI$', which
tell Python that all backslashes are literal. Alternatively (as we do
once in this patch), the backslash can itself be escaped ('\\').
There are more problems of this nature in the build scripts.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
This commit is contained in:
committed by
Noel Power
parent
c247afbda0
commit
07fa6678e4
@@ -248,29 +248,29 @@ def parse_unc(unc):
|
||||
|
||||
|
||||
def find_parser(name, flags=re.IGNORECASE):
|
||||
if re.match('fdeploy1\.ini$', name, flags=flags):
|
||||
if re.match(r'fdeploy1\.ini$', name, flags=flags):
|
||||
return GPFDeploy1IniParser()
|
||||
if re.match('audit\.csv$', name, flags=flags):
|
||||
if re.match(r'audit\.csv$', name, flags=flags):
|
||||
return GPAuditCsvParser()
|
||||
if re.match('GptTmpl\.inf$', name, flags=flags):
|
||||
if re.match(r'GptTmpl\.inf$', name, flags=flags):
|
||||
return GptTmplInfParser()
|
||||
if re.match('GPT\.INI$', name, flags=flags):
|
||||
if re.match(r'GPT\.INI$', name, flags=flags):
|
||||
return GPTIniParser()
|
||||
if re.match('scripts.ini$', name, flags=flags):
|
||||
return GPScriptsIniParser()
|
||||
if re.match('psscripts.ini$', name, flags=flags):
|
||||
return GPScriptsIniParser()
|
||||
if re.match('GPE\.INI$', name, flags=flags):
|
||||
if re.match(r'GPE\.INI$', name, flags=flags):
|
||||
# This file does not appear in the protocol specifications!
|
||||
#
|
||||
# It appears to be a legacy file used to maintain gPCUserExtensionNames
|
||||
# and gPCMachineExtensionNames. We should just copy the file as binary.
|
||||
return GPParser()
|
||||
if re.match('.*\.ini$', name, flags=flags):
|
||||
if re.match(r'.*\.ini$', name, flags=flags):
|
||||
return GPIniParser()
|
||||
if re.match('.*\.pol$', name, flags=flags):
|
||||
if re.match(r'.*\.pol$', name, flags=flags):
|
||||
return GPPolParser()
|
||||
if re.match('.*\.aas$', name, flags=flags):
|
||||
if re.match(r'.*\.aas$', name, flags=flags):
|
||||
return GPAasParser()
|
||||
|
||||
return GPParser()
|
||||
|
||||
Reference in New Issue
Block a user