future proofing is good, but...

since print() was made a function in py3, i can predict at some point
that return will be made a func as well. sure, good.
but "return()" *currently* returns an empty tuple. We want to
explicitly return None for testing purposes.
This commit is contained in:
2019-12-11 04:33:15 -05:00
parent a1bc613979
commit d7d85c7d9d
24 changed files with 156 additions and 156 deletions

View File

@@ -204,19 +204,19 @@ class BaseConnection(object):
addrset = convertIpTuples(a)
if addrset not in self.addrs[addrtype]:
self.addrs[addrtype].append(addrset)
return()
return(None)
def _initCfg(self):
# A dummy method; this is overridden by the subclasses.
# It's honestly here to make my IDE stop complaining. :)
pass
return()
return(None)
def _initConnCfg(self):
# A dummy method; this is overridden by the subclasses.
# It's honestly here to make my IDE stop complaining. :)
pass
return()
return(None)
def _initResolvers(self):
resolvers_xml = self.xml.find('resolvers')
@@ -225,7 +225,7 @@ class BaseConnection(object):
resolver = ipaddress.ip_address(r.text.strip())
if resolver not in self.resolvers:
self.resolvers.append(resolver)
return()
return(None)
def _initRoutes(self):
routes_xml = self.xml.find('routes')
@@ -235,9 +235,9 @@ class BaseConnection(object):
addrset = convertIpTuples(a)
if addrset not in self.routes[addrtype]:
self.routes[addrtype].append(addrset)
return()
return(None)
def _writeConnCfg(self, chroot_base):
# Dummy method.
pass
return()
return(None)

View File

@@ -105,7 +105,7 @@ class Connection(_common.BaseConnection):
# Weird hack because netctl doesn't natively support assigning add'l addrs to a dhcp/dhcp6/slaac iface.
if 'IPCustom' in self._cfg['BASE'].keys() and isinstance(self._cfg['BASE']['IPCustom'], list):
self._cfg['BASE']['IPCustom'] = '({0})'.format(' '.join(self._cfg['BASE']['IPCustom']))
return()
return(None)
def writeConf(self, chroot_base):
systemd_base = os.path.join(chroot_base, 'etc', 'systemd', 'system')
@@ -260,7 +260,7 @@ class Connection(_common.BaseConnection):
fh.write(line)
os.chmod(netctl_file, 0o0600)
os.chown(netctl_file, 0, 0)
return()
return(None)
class Ethernet(Connection):
@@ -300,4 +300,4 @@ class Wireless(Connection):
# if crypto['type'] in ('wep', 'wpa', 'wpa2', 'wpa3'):
if crypto['type'] in ('wpa', 'wpa2'):
self._cfg['BASE']['Key'] = crypto['auth']['psk']
return()
return(None)

View File

@@ -90,13 +90,13 @@ class Connection(_common.BaseConnection):
if 'IPv6AcceptRA' not in self._cfg.keys():
self._cfg['IPv6AcceptRA'] = {'UseDNS': ('true' if self.auto['resolvers']['ipv6'] else 'false')}
self._initConnCfg()
return()
return(None)
def _initJ2(self):
self.j2_env = jinja2.Environment(loader = jinja2.FileSystemLoader(searchpath = './'))
self.j2_env.filters.update(aif.utils.j2_filters)
self.j2_tpl = self.j2_env.get_template('networkd.conf.j2')
return()
return(None)
def writeConf(self, chroot_base):
cfgroot = os.path.join(chroot_base, 'etc', 'systemd', 'network')
@@ -109,7 +109,7 @@ class Connection(_common.BaseConnection):
os.chmod(cfgfile, 0o0644)
os.chown(cfgfile, 0, 0)
self._writeConnCfg(chroot_base)
return()
return(None)
class Ethernet(Connection):
@@ -155,7 +155,7 @@ class Wireless(Connection):
'multi-user.target.wants/'
'wpa_supplicant@'
'{0}.service').format(self.device)
return()
return(None)
def _writeConnCfg(self, chroot_base):
cfgroot = os.path.join(chroot_base, 'etc', 'wpa_supplicant')
@@ -167,4 +167,4 @@ class Wireless(Connection):
fh.write(self.wpasupp_tpl.render(wpa = self._wpasupp))
os.chown(cfgfile, 0, 0)
os.chmod(cfgfile, 0o0640)
return()
return(None)

View File

@@ -89,7 +89,7 @@ class Connection(_common.BaseConnection):
str(net.prefixlen),
str(gw))
self._initConnCfg()
return()
return(None)
def writeConf(self, chroot_base):
cfgroot = os.path.join(chroot_base, 'etc', 'NetworkManager')
@@ -109,7 +109,7 @@ class Connection(_common.BaseConnection):
os.chmod(cfgroot, 0o0755)
os.chmod(cfgdir, 0o0700)
os.chmod(cfgpath, 0o0600)
return()
return(None)
class Ethernet(Connection):
@@ -120,7 +120,7 @@ class Ethernet(Connection):
def _initConnCfg(self):
self._cfg[self.connection_type] = {'mac-address-blacklist': ''}
return()
return(None)
class Wireless(Connection):
@@ -153,4 +153,4 @@ class Wireless(Connection):
# if crypto['type'] in ('wep', 'wpa', 'wpa2', 'wpa3'):
if crypto['type'] in ('wpa', 'wpa2'):
self._cfg['wifi-security']['psk'] = crypto['auth']['psk']
return()
return(None)