[PATCH] examples: sms: resolve PEP8 issues

yegorslists at googlemail.com yegorslists at googlemail.com
Wed Feb 24 15:43:48 UTC 2021


From: Yegor Yefremov <yegorslists at googlemail.com>

Use autopep8 utility to resolve issues like spaces before brackets
and wrong hanging indentation.

Also treat objects like boolean variables to check whether they are
None or not.
---
 examples/sms-python/sms-python | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/examples/sms-python/sms-python b/examples/sms-python/sms-python
index 569db376..46d5e692 100755
--- a/examples/sms-python/sms-python
+++ b/examples/sms-python/sms-python
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 #
 # This program is free software; you can redistribute it and/or modify it under
@@ -25,7 +25,8 @@ gi.require_version('ModemManager', '1.0')
 from gi.repository import Gio, GLib, GObject, ModemManager
 
 
-if __name__ == "__main__":
+def main():
+    """Main routine."""
 
     # Process input arguments
     if len(sys.argv) != 3:
@@ -34,14 +35,15 @@ if __name__ == "__main__":
         sys.exit(1)
 
     # Prepare SMS properties
-    sms_properties = ModemManager.SmsProperties.new ()
+    sms_properties = ModemManager.SmsProperties.new()
     sms_properties.set_number(sys.argv[1])
     sms_properties.set_text(sys.argv[2])
 
     # Connection to ModemManager
-    connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
-    manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
-    if manager.get_name_owner() is None:
+    connection = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
+    manager = ModemManager.Manager.new_sync(
+        connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
+    if not manager.get_name_owner():
         sys.stderr.write('ModemManager not found in bus')
         sys.exit(2)
 
@@ -51,3 +53,7 @@ if __name__ == "__main__":
         sms = messaging.create_sync(sms_properties)
         sms.send_sync()
         print('%s: sms sent' % messaging.get_object_path())
+
+
+if __name__ == "__main__":
+    main()
-- 
2.17.0



More information about the ModemManager-devel mailing list