Update exception catching syntax to please pep8
authorMagnus Hagander <magnus@hagander.net>
Thu, 16 Jul 2020 13:46:51 +0000 (15:46 +0200)
committerMagnus Hagander <magnus@hagander.net>
Tue, 11 Aug 2020 10:19:47 +0000 (12:19 +0200)
django/archives/mailarchives/api.py
django/archives/mailarchives/models.py
django/archives/mailarchives/views.py
loader/generate_mbox.py
loader/hide_message.py
loader/lib/parser.py
loader/pglister_sync.py
loader/purge_frontend_message.py
loader/reparse_message.py
loader/tools/edit_raw.py
loader/tools/fix_from.py

index 4afb7f16e46a9089ea4b7dd1346880d85179b28a..420981143765aa613515472c6735f78162456c2c 100644 (file)
@@ -41,7 +41,7 @@ def latest(request, listname):
     if 'n' in request.GET:
         try:
             limit = int(request.GET['n'])
-        except:
+        except Exception:
             limit = 0
     else:
         limit = 50
index 5eeb2cb929cbc269adb79007d1ba7776310a30fa..fd9a017f492ce892b5f671e18dc7e67d876c5655 100644 (file)
@@ -56,7 +56,7 @@ class Message(models.Model):
             return None
         try:
             return hide_reasons[self.hiddenstatus]
-        except:
+        except Exception:
             # Weird value
             return 'This message has been hidden.'
 
index 82e8cef9cedb773d5d99eb9501fdb95c5fca301b..aba82f5eb799ae9532fae373c254942cc03037c7 100644 (file)
@@ -720,7 +720,7 @@ def search(request):
                 'names': request.POST['ln'].split(','),
             })
             lists = [x for x, in curs.fetchall()]
-        except:
+        except Exception:
             # If failing to parse list of lists, just search all
             lists = None
     else:
index dfb8d3d6478a7ac1b68ebe77b9eb48c945b33507..76ce946a6704e6201f16d160c2d17432ee86126e 100755 (executable)
@@ -35,7 +35,7 @@ def generate_single_mbox(conn, listid, year, month, destination):
             try:
                 x = msg.as_string(unixfrom=True)
                 f.write(x)
-            except UnicodeEncodeError as e:
+            except UnicodeEncodeError:
                 print("Not including {0}, unicode error".format(msg['message-id']))
             except Exception as e:
                 print("Not including {0}, exception {1}".format(msg['message-id'], e))
@@ -69,7 +69,7 @@ if __name__ == "__main__":
     cfg.read(os.path.join(os.path.realpath(os.path.dirname(sys.argv[0])), 'archives.ini'))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)
index 4a4d10ac7aeb6f025b5347ed514d9830a9837453..62ac1c93d5b9ee32e162d91ed5edb4f5aaa42bfa 100755 (executable)
@@ -42,7 +42,7 @@ if __name__ == "__main__":
     cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)
@@ -75,7 +75,7 @@ if __name__ == "__main__":
         else:
             try:
                 print("Hiding message for reason: %s" % reasons[reason])
-            except:
+            except Exception:
                 continue
             break
     if previous == reason:
index b9caace0f8bd450ca255c411780d68dde97b2d74..5a02cb477d2536b277aff45867d3543e6388cd19 100644 (file)
@@ -30,7 +30,7 @@ class ArchivesParser(object):
         try:
             if self.clean_messageid(self.decode_mime_header(self.get_mandatory('Message-ID'))) == msgid:
                 return True
-        except Exception as e:
+        except Exception:
             return False
 
     def analyze(self, date_override=None):
@@ -527,7 +527,7 @@ class ArchivesParser(object):
 
         try:
             return " ".join([self._maybe_decode(s, charset) for s, charset in decode_header(hdr)])
-        except HeaderParseError as e:
+        except HeaderParseError:
             # Parser error is typically someone specifying an encoding,
             # but then not actually using that encoding. We'll do the best
             # we can, which is cut it down to ascii and ignore errors
@@ -553,13 +553,13 @@ class ArchivesParser(object):
             if x is None:
                 raise Exception()
             return x
-        except:
+        except Exception:
             raise IgnorableException("Mandatory field '%s' is missing" % fieldname)
 
     def get_optional(self, fieldname):
         try:
             return self.msg[fieldname]
-        except:
+        except Exception:
             return ''
 
     def html_clean(self, html):
@@ -585,7 +585,7 @@ class ArchivesParser(object):
             cleaner = HTMLCleaner()
             cleaner.feed(html)
             return cleaner.get_text()
-        except Exception as e:
+        except Exception:
             # Failed to parse the html, thus failed to clean it. so we must
             # give up...
             return None
index b1944a721f9266dfe6a7ef74fd197080ad473d12..f95d369b92b7f84c77d17aa6b4fce7b898ff990b 100755 (executable)
@@ -20,7 +20,7 @@ if __name__ == "__main__":
     cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     if cfg.has_option('pglister', 'subscribers') and cfg.getint('pglister', 'subscribers'):
index 3a87005c07d36c1f2dcd1e9c036f8326a61529e0..6f051b7d4b47bb231b67785cad8039615016cc0f 100755 (executable)
@@ -34,7 +34,7 @@ if __name__ == "__main__":
     cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)
index 542e84a3fe6ebbaf053cfb4990a3bcee9d57e991..52afe2ff1bcee4efe0f164b8d3d7d60a140d3183 100755 (executable)
@@ -64,7 +64,7 @@ if __name__ == "__main__":
     cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)
index 5387af4599a10c6b1fd3650ad1208c44cee7fb82..13e98c1359c8faafe1812380b33c5ab9c2db3f88 100755 (executable)
@@ -32,7 +32,7 @@ if __name__ == "__main__":
     cfg.read('%s/../archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)
@@ -92,6 +92,6 @@ if __name__ == "__main__":
     finally:
         try:
             f.close()
-        except:
+        except Exception:
             pass
         os.unlink(f.name)
index d262546e87502c3ba4d7c2d2cb7bd223a6802d03..52efec9b4a25a7566823f9933d57191be97ae81b 100755 (executable)
@@ -18,7 +18,7 @@ if __name__ == "__main__":
     cfg.read('%s/../archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
     try:
         connstr = cfg.get('db', 'connstr')
-    except:
+    except Exception:
         connstr = 'need_connstr'
 
     conn = psycopg2.connect(connstr)