]> granicus.if.org Git - libevent/commitdiff
Resolve variable name issues per PEP8
authorEnji Cooper <yaneurabeya@gmail.com>
Fri, 27 Mar 2020 00:13:14 +0000 (17:13 -0700)
committerEnji Cooper <yaneurabeya@gmail.com>
Fri, 27 Mar 2020 17:35:46 +0000 (10:35 -0700)
Move all logic under `if __name__ == "__main__"` to a `main(..)`
function.

The purpose of this is to not only address flake8/pylint reported issues
with variable names, but also to enable testing of the function in
isolation to ensure the logic acts as desired.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
event_rpcgen.py

index c6ddc2a681eaefa92bb2d6654ca5fce34574cfa1..c21222922e444dd3ad6dffe48fad35ec3febdc94 100755 (executable)
@@ -1711,21 +1711,22 @@ class CommandLine:
             entry.PrintCode(impl_fp)
         impl_fp.close()
 
-if __name__ == '__main__':
-    try:
-        CommandLine(sys.argv).run()
-        sys.exit(0)
 
+def main(argv=None):
+    try:
+        CommandLine(argv).run()
+        return 0
     except RpcGenError as e:
         sys.stderr.write(e)
-        sys.exit(1)
-
     except EnvironmentError as e:
         if e.filename and e.strerror:
             sys.stderr.write("%s: %s" % (e.filename, e.strerror))
-            sys.exit(1)
         elif e.strerror:
             sys.stderr.write(e.strerror)
-            sys.exit(1)
         else:
             raise
+    return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main(argv=sys.argv))