chiark / gitweb /
peerdb/tripe-newpeers.in: Abolish `ConfigSection.has_option'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 26 May 2018 13:42:36 +0000 (14:42 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 14 Jun 2018 11:50:38 +0000 (12:50 +0100)
Instead, the caller just catches `MissingKeyException'.

peerdb/tripe-newpeers.in

index ed87189fbda278904d89a993ca651b44afeac7d5..304d34acbac309b5b2feecd53b4ef84f92171bdc 100644 (file)
@@ -199,14 +199,6 @@ class ConfigSection (object):
                               string)
     return string
 
-  def has_option(me, key):
-    """
-    Decide whether this section has a configuration key KEY.
-
-    This version of the method properly handles the @inherit key.
-    """
-    return key == 'name' or me._get(key)[0] is not None
-
   def _get(me, key, map = None, path = None):
     """
     Low-level option-fetching method.
@@ -525,11 +517,13 @@ def output(conf, cdb):
       label = sec.name
     else:
       label = 'P%s' % sec.name
-      if sec.has_option('auto') and \
-         sec.get('auto') in ('y', 'yes', 't', 'true', '1', 'on'):
-        auto.append(sec.name)
-      if sec.has_option('user'):
-        cdb.add('U%s' % sec.get('user'))
+      try: a = sec.get('auto')
+      except MissingKeyException: pass
+      else:
+        if a in ('y', 'yes', 't', 'true', '1', 'on'): auto.append(sec.name)
+      try: u = sec.get('user')
+      except MissingKeyException: pass
+      else: cdb.add('U%s' % u)
     url = M.URLEncode(laxp = True, semip = True)
     for key, value in sorted(sec.items(), key = lambda (k, v): k):
       if not key.startswith('@'):