diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2017-11-06 10:46:16 +0100 |
---|---|---|
committer | Jiri Kastner <jkastner@redhat.com> | 2017-11-20 13:59:01 +0100 |
commit | 204797fd049c6d9a72646e1f0028fcede1249f37 (patch) | |
tree | a440ad5d8eb753730fd5d0e0b2edfbafea047c1c | |
parent | 2cf2e01a7155e9e2ca6bdb03a1b746eaf88cefd8 (diff) | |
download | python-linux-procfs-204797fd049c6d9a72646e1f0028fcede1249f37.tar.gz |
python3: Fix usage of `map()` function
Signed-off-by: Lumir Balhar <lbalhar@redhat.com>
Signed-off-by: Jiri Kastner <jkastner@redhat.com>
-rwxr-xr-x | pflags-cmd.py | 7 | ||||
-rwxr-xr-x | procfs/procfs.py | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/pflags-cmd.py b/pflags-cmd.py index 6dfa184..391420c 100755 --- a/pflags-cmd.py +++ b/pflags-cmd.py @@ -16,6 +16,7 @@ import procfs, re, fnmatch, sys from functools import reduce +from six.moves import map ps = None @@ -37,12 +38,12 @@ def main(argv): ps = procfs.pidstats() if (len(argv) > 1): - pids = reduce(lambda i, j: i + j, map(thread_mapper, argv[1].split(","))) + pids = reduce(lambda i, j: i + j, list(map(thread_mapper, argv[1].split(",")))) else: pids = list(ps.processes.keys()) pids.sort() - len_comms = map(lambda pid: len(ps[pid]["stat"]["comm"]), pids) + len_comms = [len(ps[pid]["stat"]["comm"]) for pid in pids] max_comm_len = max(len_comms) del(len_comms) @@ -59,7 +60,7 @@ def main(argv): flags.remove("PF_FREEZER_NOSIG") comm = ps[pid].stat["comm"] flags.sort() - sflags = reduce(lambda i, j: "%s|%s" % (i, j), map(lambda a: a[3:],flags)) + sflags = reduce(lambda i, j: "%s|%s" % (i, j), [a[3:] for a in flags]) print "%6d %*s %s" %(pid, max_comm_len, comm, sflags) if __name__ == '__main__': diff --git a/procfs/procfs.py b/procfs/procfs.py index bc78b75..c669275 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -814,7 +814,7 @@ class smaps_lib: """ def __init__(self, lines): fields = lines[0].split() - self.vm_start, self.vm_end = map(lambda a: int(a, 16), fields[0].split("-")) + self.vm_start, self.vm_end = [int(a, 16) for a in fields[0].split("-")] self.perms = fields[1] self.offset = int(fields[2], 16) self.major, self.minor = fields[3].split(":") |