]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python: use python3 style super statements
authorRob van der Linde <rob@catalyst.net.nz>
Thu, 14 Dec 2023 02:30:42 +0000 (15:30 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 15 Dec 2023 02:54:34 +0000 (02:54 +0000)
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
12 files changed:
python/samba/dnsserver.py
python/samba/drs_utils.py
python/samba/gp_parse/gp_ini.py
python/samba/idmap.py
python/samba/join.py
python/samba/logger.py
python/samba/netcmd/gpo.py
python/samba/netcmd/user/readpasswords/common.py
python/samba/provision/__init__.py
python/samba/provision/sambadns.py
python/samba/samdb.py
python/samba/subunit/run.py

index 965977acdeb62acb778442a07f2a8f2ea0c601a5..d907f8e1b8d71e96a9cc30b6f5f310b7d5ae3250 100644 (file)
@@ -49,7 +49,7 @@ class DNSParseError(ValueError):
 class ARecord(dnsserver.DNS_RPC_RECORD):
     def __init__(self, ip_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=0):
-        super(ARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_A
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -65,7 +65,7 @@ class AAAARecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, ip6_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=0):
-        super(AAAARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_AAAA
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -81,7 +81,7 @@ class PTRRecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, ptr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=0):
-        super(PTRRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_PTR
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -119,7 +119,7 @@ class NSRecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, dns_server, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=0):
-        super(NSRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_NS
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -138,7 +138,7 @@ class MXRecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, mail_server, preference, serial=1, ttl=900,
                  rank=dnsp.DNS_RANK_ZONE, node_flag=0):
-        super(MXRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_MX
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -165,7 +165,7 @@ class SOARecord(dnsserver.DNS_RPC_RECORD):
     def __init__(self, mname, rname, serial=1, refresh=900, retry=600,
                  expire=86400, minimum=3600, ttl=3600, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=dnsp.DNS_RPC_FLAG_AUTH_ZONE_ROOT):
-        super(SOARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_SOA
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -202,7 +202,7 @@ class SRVRecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, target, port, priority=0, weight=100, serial=1, ttl=900,
                  rank=dnsp.DNS_RANK_ZONE, node_flag=0):
-        super(SRVRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_SRV
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
@@ -237,7 +237,7 @@ class TXTRecord(dnsserver.DNS_RPC_RECORD):
 
     def __init__(self, slist, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE,
                  node_flag=0):
-        super(TXTRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_TXT
         self.dwFlags = rank | node_flag
         self.dwSerial = serial
index f3209e63eb9e64c87411ac4cd9e52597229f0e90..06e6928e3083ad007a43e84233c6b5ca0e276ef8 100644 (file)
@@ -405,8 +405,7 @@ class drs_ReplicateRenamer(drs_Replicate):
 
     def __init__(self, binding_string, lp, creds, samdb, invocation_id,
                  old_base_dn, new_base_dn):
-        super(drs_ReplicateRenamer, self).__init__(binding_string, lp, creds,
-                                                   samdb, invocation_id)
+        super().__init__(binding_string, lp, creds, samdb, invocation_id)
         self.old_base_dn = old_base_dn
         self.new_base_dn = new_base_dn
 
@@ -454,6 +453,4 @@ class drs_ReplicateRenamer(drs_Replicate):
             self.rename_top_level_object(ctr.first_object.object)
 
         # then do the normal repl processing to apply this chunk to our DB
-        super(drs_ReplicateRenamer, self).process_chunk(level, ctr, schema,
-                                                        req_level, req,
-                                                        first_chunk)
+        super().process_chunk(level, ctr, schema, req_level, req, first_chunk)
index 342a1ee162061accbc5d1871f1a744bc81453dbc..e9b7ad29de9e7c6f3d94895f3efca622c179b3d0 100644 (file)
@@ -109,7 +109,7 @@ class GPTIniParser(GPIniParser):
 
     def parse(self, contents):
         try:
-            super(GPTIniParser, self).parse(contents)
+            super().parse(contents)
         except UnicodeDecodeError:
             # Required dict_type in Python 2.7
             self.ini_conf = ConfigParser(dict_type=collections.OrderedDict,
@@ -122,9 +122,8 @@ class GPTIniParser(GPIniParser):
 
 class GPScriptsIniParser(GPIniParser):
     def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
-        parent_return = super(GPScriptsIniParser,
-                              self).build_xml_parameter(section_xml, section,
-                                                        key_ini, val_ini)
+        parent_return = super().build_xml_parameter(section_xml, section,
+                                                    key_ini, val_ini)
 
         cmdline = re.match('\\d+CmdLine$', key_ini)
         if cmdline is not None:
@@ -136,9 +135,8 @@ class GPScriptsIniParser(GPIniParser):
 
 class GPFDeploy1IniParser(GPIniParser):
     def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
-        parent_return = super(GPFDeploy1IniParser,
-                              self).build_xml_parameter(section_xml, section,
-                                                        key_ini, val_ini)
+        parent_return = super().build_xml_parameter(section_xml, section,
+                                                    key_ini, val_ini)
         # Add generalization metadata and parse out SID list
         if section.lower() == 'folder_redirection':
             # Process the header section
@@ -182,8 +180,7 @@ class GPFDeploy1IniParser(GPIniParser):
             return (key, value)
 
         # Do the normal ini code for other sections
-        return super(GPFDeploy1IniParser,
-                     self).load_xml_parameter(param_xml, section)
+        return super().load_xml_parameter(param_xml, section)
 
     def build_xml_section(self, root_xml, sec_ini):
         section = SubElement(root_xml, 'Section')
index 8abaf98cadb8a075f19a10f8d30304c01b525323..321ae8b7ee55f7d5302c7acd30c5e848cb67a89d 100644 (file)
@@ -42,13 +42,13 @@ class IDmapDB(samba.Ldb):
         if url is None:
             url = lp.private_path("idmap.ldb")
 
-        super(IDmapDB, self).__init__(url=url, lp=lp, modules_dir=modules_dir,
-                                      session_info=session_info, credentials=credentials, flags=flags,
-                                      options=options)
+        super().__init__(url=url, lp=lp, modules_dir=modules_dir,
+                         session_info=session_info, credentials=credentials, flags=flags,
+                         options=options)
 
     def connect(self, url=None, flags=0, options=None):
-        super(IDmapDB, self).connect(url=self.lp.private_path(url), flags=flags,
-                                     options=options)
+        super().connect(url=self.lp.private_path(url), flags=flags,
+                        options=options)
 
     def increment_xid(self):
         """Increment xidNumber, if not present it create and assign it to the lowerBound
index 4d08cccb567cd12b37e940792cc12339d6a81e9f..8b7e882a236c160c96bbf14745d3da36d5ae9860 100644 (file)
@@ -54,7 +54,7 @@ from samba import dsdb, functional_level
 class DCJoinException(Exception):
 
     def __init__(self, msg):
-        super(DCJoinException, self).__init__("Can't join, error: %s" % msg)
+        super().__init__("Can't join, error: %s" % msg)
 
 
 class DCJoinContext(object):
@@ -1651,11 +1651,11 @@ class DCCloneContext(DCJoinContext):
                  targetdir=None, domain=None, dns_backend=None,
                  include_secrets=False, backend_store=None,
                  backend_store_size=None):
-        super(DCCloneContext, ctx).__init__(logger, server, creds, lp,
-                                            targetdir=targetdir, domain=domain,
-                                            dns_backend=dns_backend,
-                                            backend_store=backend_store,
-                                            backend_store_size=backend_store_size)
+        super().__init__(logger, server, creds, lp,
+                         targetdir=targetdir, domain=domain,
+                         dns_backend=dns_backend,
+                         backend_store=backend_store,
+                         backend_store_size=backend_store_size)
 
         # As we don't want to create or delete these DNs, we set them to None
         ctx.server_dn = None
@@ -1706,12 +1706,12 @@ class DCCloneAndRenameContext(DCCloneContext):
     def __init__(ctx, new_base_dn, new_domain_name, new_realm, logger=None,
                  server=None, creds=None, lp=None, targetdir=None, domain=None,
                  dns_backend=None, include_secrets=True, backend_store=None):
-        super(DCCloneAndRenameContext, ctx).__init__(logger, server, creds, lp,
-                                                     targetdir=targetdir,
-                                                     domain=domain,
-                                                     dns_backend=dns_backend,
-                                                     include_secrets=include_secrets,
-                                                     backend_store=backend_store)
+        super().__init__(logger, server, creds, lp,
+                         targetdir=targetdir,
+                         domain=domain,
+                         dns_backend=dns_backend,
+                         include_secrets=include_secrets,
+                         backend_store=backend_store)
         # store the new DN (etc) that we want the cloned DB to use
         ctx.new_base_dn = new_base_dn
         ctx.new_domain_name = new_domain_name
index 7fb2199e031bf559993618339388bc4f0502db82..a35ef2a358f69d61cba62706fe01717be84198d0 100644 (file)
@@ -34,7 +34,7 @@ class ColoredFormatter(logging.Formatter):
     """Add color to log according to level"""
 
     def format(self, record):
-        log = super(ColoredFormatter, self).format(record)
+        log = super().format(record)
         color = LEVEL_COLORS.get(record.levelno, GREY)
         return color + log + C_NORMAL
 
index 823e048f4001b6cb6af226e34325a856e043bb09..ba55b2ec7a772224c0679032894c982a2fca56a2 100644 (file)
@@ -1660,8 +1660,7 @@ class cmd_restore(cmd_create):
 
             dtd_header += '\n]>\n'
 
-        super(cmd_restore, self).run(displayname, H, tmpdir, sambaopts,
-                                     credopts, versionopts)
+        super().run(displayname, H, tmpdir, sambaopts, credopts, versionopts)
 
         try:
             if tmpdir is None:
index f9406844a3de8ced658aa35d5fa44f1d2ccdf7a9..02f7d36f5fc1f76264b3df33960ac56820f61b49 100644 (file)
@@ -178,7 +178,7 @@ if len(disabled_virtual_attributes) != 0:
 class GetPasswordCommand(Command):
 
     def __init__(self):
-        super(GetPasswordCommand, self).__init__()
+        super().__init__()
         self.lp = None
 
     def inject_virtual_attributes(self, samdb):
index f731d642d7f136c41bde211b6a437e7629c8d514..56ca74964078861bda8573547717525a3a7c51ef 100644 (file)
@@ -2511,14 +2511,14 @@ class InvalidNetbiosName(Exception):
     """A specified name was not a valid NetBIOS name."""
 
     def __init__(self, name):
-        super(InvalidNetbiosName, self).__init__(
+        super().__init__(
             "The name '%r' is not a valid NetBIOS name" % name)
 
 
 class MissingShareError(ProvisioningError):
 
     def __init__(self, name, smbconf):
-        super(MissingShareError, self).__init__(
+        super().__init__(
             "Existing smb.conf does not have a [%s] share, but you are "
             "configuring a DC. Please remove %s or add the share manually." %
             (name, smbconf))
index f77329e28183e289bd04b0a995b116c001dfc734..01398bbc346e842293206634db1b4796aba11502 100644 (file)
@@ -86,7 +86,7 @@ def get_dnsadmins_sid(samdb, domaindn):
 class ARecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, ip_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE):
-        super(ARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_A
         self.rank = rank
         self.dwSerial = serial
@@ -97,7 +97,7 @@ class ARecord(dnsp.DnssrvRpcRecord):
 class AAAARecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, ip6_addr, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE):
-        super(AAAARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_AAAA
         self.rank = rank
         self.dwSerial = serial
@@ -119,7 +119,7 @@ class CNAMERecord(dnsp.DnssrvRpcRecord):
 class NSRecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, dns_server, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE):
-        super(NSRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_NS
         self.rank = rank
         self.dwSerial = serial
@@ -131,7 +131,7 @@ class SOARecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, mname, rname, serial=1, refresh=900, retry=600,
                  expire=86400, minimum=3600, ttl=3600, rank=dnsp.DNS_RANK_ZONE):
-        super(SOARecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_SOA
         self.rank = rank
         self.dwSerial = serial
@@ -151,7 +151,7 @@ class SRVRecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, target, port, priority=0, weight=100, serial=1, ttl=900,
                  rank=dnsp.DNS_RANK_ZONE):
-        super(SRVRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_SRV
         self.rank = rank
         self.dwSerial = serial
@@ -167,7 +167,7 @@ class SRVRecord(dnsp.DnssrvRpcRecord):
 class TXTRecord(dnsp.DnssrvRpcRecord):
 
     def __init__(self, slist, serial=1, ttl=900, rank=dnsp.DNS_RANK_ZONE):
-        super(TXTRecord, self).__init__()
+        super().__init__()
         self.wType = dnsp.DNS_TYPE_TXT
         self.rank = rank
         self.dwSerial = serial
@@ -181,7 +181,7 @@ class TXTRecord(dnsp.DnssrvRpcRecord):
 class TypeProperty(dnsp.DnsProperty):
 
     def __init__(self, zone_type=dnsp.DNS_ZONE_TYPE_PRIMARY):
-        super(TypeProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_TYPE
@@ -191,7 +191,7 @@ class TypeProperty(dnsp.DnsProperty):
 class AllowUpdateProperty(dnsp.DnsProperty):
 
     def __init__(self, allow_update=dnsp.DNS_ZONE_UPDATE_SECURE):
-        super(AllowUpdateProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_ALLOW_UPDATE
@@ -201,7 +201,7 @@ class AllowUpdateProperty(dnsp.DnsProperty):
 class SecureTimeProperty(dnsp.DnsProperty):
 
     def __init__(self, secure_time=0):
-        super(SecureTimeProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_SECURE_TIME
@@ -211,7 +211,7 @@ class SecureTimeProperty(dnsp.DnsProperty):
 class NorefreshIntervalProperty(dnsp.DnsProperty):
 
     def __init__(self, norefresh_interval=0):
-        super(NorefreshIntervalProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_NOREFRESH_INTERVAL
@@ -221,7 +221,7 @@ class NorefreshIntervalProperty(dnsp.DnsProperty):
 class RefreshIntervalProperty(dnsp.DnsProperty):
 
     def __init__(self, refresh_interval=0):
-        super(RefreshIntervalProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_REFRESH_INTERVAL
@@ -231,7 +231,7 @@ class RefreshIntervalProperty(dnsp.DnsProperty):
 class AgingStateProperty(dnsp.DnsProperty):
 
     def __init__(self, aging_enabled=0):
-        super(AgingStateProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_AGING_STATE
@@ -241,7 +241,7 @@ class AgingStateProperty(dnsp.DnsProperty):
 class AgingEnabledTimeProperty(dnsp.DnsProperty):
 
     def __init__(self, next_cycle_hours=0):
-        super(AgingEnabledTimeProperty, self).__init__()
+        super().__init__()
         self.wDataLength = 1
         self.version = 1
         self.id = dnsp.DSPROPERTY_ZONE_AGING_ENABLED_TIME
index f2d7d4077c2443e586ece774f35784c73d916b62..9bbec435062f5a71dacb39f10f7f2f7ec27f9aac 100644 (file)
@@ -87,9 +87,9 @@ class SamDB(samba.Ldb):
 
         self.url = url
 
-        super(SamDB, self).__init__(url=url, lp=lp, modules_dir=modules_dir,
-                                    session_info=session_info, credentials=credentials, flags=flags,
-                                    options=options)
+        super().__init__(url=url, lp=lp, modules_dir=modules_dir,
+                         session_info=session_info, credentials=credentials, flags=flags,
+                         options=options)
 
         if global_schema:
             dsdb._dsdb_set_global_schema(self)
@@ -103,8 +103,7 @@ class SamDB(samba.Ldb):
             url = self.lp.private_path(url)
         self.url = url
 
-        super(SamDB, self).connect(url=url, flags=flags,
-                                   options=options)
+        super().connect(url=url, flags=flags, options=options)
 
     def am_rodc(self):
         """return True if we are an RODC"""
@@ -1357,7 +1356,7 @@ schemaUpdateNow: 1
          """
         self.transaction_start()
         try:
-            seq = super(SamDB, self).sequence_number(seq_type)
+            seq = super().sequence_number(seq_type)
         except:
             self.transaction_cancel()
             raise
index 4cf42b05eaf12ac948c39c19875241462735607c..dc3f9316fcbeff23671692c7392579afac19893c 100755 (executable)
@@ -77,13 +77,13 @@ class TestProtocolClient(unittest.TestResult):
 
     def startTest(self, test):
         """Mark a test as starting its test run."""
-        super(TestProtocolClient, self).startTest(test)
+        super().startTest(test)
         self._stream.write("test: " + test.id() + "\n")
         self._stream.flush()
 
     def stopTest(self, test):
         """Mark a test as having finished its test run."""
-        super(TestProtocolClient, self).stopTest(test)
+        super().stopTest(test)
         self.writeOutcome(test)
 
     def writeOutcome(self, test):
@@ -359,7 +359,7 @@ class HookedTestResultDecorator(TestResultDecorator):
     """A TestResult which calls a hook on every event."""
 
     def __init__(self, decorated):
-        self.super = super(HookedTestResultDecorator, self)
+        self.super = super()
         self.super.__init__(decorated)
 
     def startTest(self, test):
@@ -430,7 +430,7 @@ class AutoTimingTestResultDecorator(HookedTestResultDecorator):
 
     def __init__(self, decorated):
         self._time = None
-        super(AutoTimingTestResultDecorator, self).__init__(decorated)
+        super().__init__(decorated)
 
     def _before_event(self):
         time = self._time