diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-09-01 12:16:30 -0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-09-01 12:16:30 -0300 |
commit | 0e5f12f00b3e6bf7b1f3ead30b04876252ea4f1b (patch) | |
tree | 38c4975fa385dcdc1b5f7c92cdc83e06ebf75375 | |
parent | 4c4bf61462191f6af40f88148f8328b948d616ab (diff) | |
download | python-linux-procfs-0e5f12f00b3e6bf7b1f3ead30b04876252ea4f1b.tar.gz |
smaps: Add __getitem__ method
So that we can do:
>>> import procfs
>>> processes = procfs.pidstats()
>>> sshd = processes.find_by_name("sshd")
>>> print sshd_maps[0].perms
>>> sshd_maps = procfs.smaps(sshd[0])
>>> print sshd_maps[0].perms
r-xp
I.e. access it like an array.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rwxr-xr-x | procfs/procfs.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py index 18761fb..dd9778d 100755 --- a/procfs/procfs.py +++ b/procfs/procfs.py @@ -777,6 +777,9 @@ class smaps: self.entries.append(smaps_lib(lines)) return line + def __getitem__(self, index): + return self.entries[index] + def reload(self): f = file("/proc/%d/smaps" % self.pid) line = None |