]> git.ipfire.org Git - oddments/fireinfo.git/blobdiff - src/fireinfo/system.py
Run 2to3
[oddments/fireinfo.git] / src / fireinfo / system.py
index 73c3882e9d7e80339af96d6fafbd9a7530bf8e9d..cfeb171d60038644f00b37b7eb03fdf2f516a3b1 100644 (file)
@@ -26,11 +26,11 @@ import string
 
 import _fireinfo
 
-import bios
-import cpu
-import device
-import hypervisor
-import network
+from . import bios
+from . import cpu
+from . import device
+from . import hypervisor
+from . import network
 
 PROFILE_VERSION = 0
 
@@ -84,9 +84,7 @@ def read_from_file(filename):
        except IOError:
                pass
 
-class System(object):
-       __metaclass__ = Singleton
-
+class System(object, metaclass=Singleton):
        def __init__(self):
                self.bios = bios.BIOS(self)
 
@@ -338,7 +336,7 @@ class System(object):
                if s is None:
                        return
 
-               return filter(lambda x: x in string.printable, s)
+               return [x for x in s if x in string.printable]
 
        @property
        def vendor(self):
@@ -373,7 +371,7 @@ class System(object):
                ret = read_from_file("/proc/device-tree/model")
                if ret:
                        # replace the NULL byte with which the DT string ends
-                       ret = ret.replace(u"\u0000", "")
+                       ret = ret.replace("\u0000", "")
 
                # Fall back to read /proc/cpuinfo
                if not ret:
@@ -485,13 +483,13 @@ class System(object):
 
 if __name__ == "__main__":
        s=System()
-       print s.arch
-       print s.language
-       print s.release
-       print s.bios_vendor
-       print s.memory
-       print s.kernel
-       print s.root_disk
-       print s.root_size
-       print "------------\n", s.devices, "\n------------\n"
-       print json.dumps(s.profile(), sort_keys=True, indent=4)
+       print(s.arch)
+       print(s.language)
+       print(s.release)
+       print(s.bios_vendor)
+       print(s.memory)
+       print(s.kernel)
+       print(s.root_disk)
+       print(s.root_size)
+       print("------------\n", s.devices, "\n------------\n")
+       print(json.dumps(s.profile(), sort_keys=True, indent=4))