mirror of
https://github.com/samba-team/samba.git
synced 2025-07-30 19:42:05 +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
@ -319,7 +319,7 @@ class GptTmplInfParser(GPParser):
|
||||
current_header_name = None
|
||||
|
||||
for line in inf_file.splitlines():
|
||||
match = re.match('\[(.*)\]', line)
|
||||
match = re.match(r'\[(.*)\]', line)
|
||||
if match:
|
||||
header_name = match.group(1)
|
||||
if header_name in self.sections:
|
||||
|
@ -156,7 +156,7 @@ class cmd_drs_showrepl(Command):
|
||||
raise
|
||||
try:
|
||||
(site, server) = drs_parse_ntds_dn(n.source_dsa_obj_dn)
|
||||
d["DSA"] = "%s\%s" % (site, server)
|
||||
d["DSA"] = "%s\\%s" % (site, server)
|
||||
except RuntimeError:
|
||||
pass
|
||||
return d
|
||||
|
@ -114,11 +114,11 @@ class cmd_dsacl_set(Command):
|
||||
"""Add new ace explicitly."""
|
||||
desc = self.read_descriptor(samdb, object_dn)
|
||||
new_ace = security.descriptor.from_sddl("D:" + new_ace,self.get_domain_sid(samdb))
|
||||
new_ace_list = re.findall("\(.*?\)",new_ace.as_sddl())
|
||||
new_ace_list = re.findall(r"\(.*?\)",new_ace.as_sddl())
|
||||
for new_ace in new_ace_list:
|
||||
desc_sddl = desc.as_sddl(self.get_domain_sid(samdb))
|
||||
# TODO add bindings for descriptor manipulation and get rid of this
|
||||
desc_aces = re.findall("\(.*?\)", desc_sddl)
|
||||
desc_aces = re.findall(r"\(.*?\)", desc_sddl)
|
||||
for ace in desc_aces:
|
||||
if ("ID" in ace):
|
||||
desc_sddl = desc_sddl.replace(ace, "")
|
||||
|
@ -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()
|
||||
|
@ -37,7 +37,7 @@ from samba.netcmd import (
|
||||
Option,
|
||||
)
|
||||
|
||||
RE_RANGED_RESULT = re.compile("^([^;]+);range=(\d+)-(\d+|\*)$")
|
||||
RE_RANGED_RESULT = re.compile(r"^([^;]+);range=(\d+)-(\d+|\*)$")
|
||||
|
||||
|
||||
class LDAPBase(object):
|
||||
@ -274,9 +274,9 @@ class Descriptor(object):
|
||||
"""
|
||||
try:
|
||||
if "S:" in self.sddl:
|
||||
res = re.search("D:(.*?)(\(.*?\))S:", self.sddl).group(2)
|
||||
res = re.search(r"D:(.*?)(\(.*?\))S:", self.sddl).group(2)
|
||||
else:
|
||||
res = re.search("D:(.*?)(\(.*\))", self.sddl).group(2)
|
||||
res = re.search(r"D:(.*?)(\(.*\))", self.sddl).group(2)
|
||||
except AttributeError:
|
||||
return []
|
||||
return re.findall("(\(.*?\))", res)
|
||||
|
Reference in New Issue
Block a user