From 2e637b5631ac1fdb17192f8ebd4f99608b73f84f Mon Sep 17 00:00:00 2001 From: GammaSQ Date: Mon, 3 Dec 2018 15:29:06 +0100 Subject: [PATCH 1/5] get_label now accepts integer and has correct return-type --- qubesadmin/app.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index ffeb287..e5f2244 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -216,10 +216,8 @@ class QubesBase(qubesadmin.base.PropertyHolder): pass # then search for index - if label.isdigit(): - for i in self.labels: - if i.index == int(label): - return i + if type(label) == int or label.isdigit(): + return self.labels.values[int(label)] raise KeyError(label) From 8b590bce862c0259300bb678feabd4f38b8ea565 Mon Sep 17 00:00:00 2001 From: GammaSQ Date: Mon, 3 Dec 2018 15:41:42 +0100 Subject: [PATCH 2/5] forgot braces --- qubesadmin/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index e5f2244..5815c56 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -217,7 +217,7 @@ class QubesBase(qubesadmin.base.PropertyHolder): # then search for index if type(label) == int or label.isdigit(): - return self.labels.values[int(label)] + return self.labels.values()[int(label)] raise KeyError(label) From 39c2c7bcd2d47aba6e0ec42ecfe443cbe1257009 Mon Sep 17 00:00:00 2001 From: GammaSQ Date: Mon, 3 Dec 2018 15:41:42 +0100 Subject: [PATCH 3/5] forgot braces --- qubesadmin/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index e5f2244..5815c56 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -217,7 +217,7 @@ class QubesBase(qubesadmin.base.PropertyHolder): # then search for index if type(label) == int or label.isdigit(): - return self.labels.values[int(label)] + return self.labels.values()[int(label)] raise KeyError(label) From aebc944704f8f0b46039140b7e580cd2174b3f28 Mon Sep 17 00:00:00 2001 From: GammaSQ Date: Tue, 4 Dec 2018 09:40:54 +0100 Subject: [PATCH 4/5] reverted to comparing .index --- qubesadmin/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index 5815c56..8c6b749 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -217,7 +217,9 @@ class QubesBase(qubesadmin.base.PropertyHolder): # then search for index if type(label) == int or label.isdigit(): - return self.labels.values()[int(label)] + for i in self.labels.values(): + if i.index == int(label): + return i raise KeyError(label) From 2c836c5adc0d7af196f7a147e1acdc161be91322 Mon Sep 17 00:00:00 2001 From: GammaSQ Date: Sat, 8 Dec 2018 12:00:15 +0100 Subject: [PATCH 5/5] isinstance instead of type --- qubesadmin/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/qubesadmin/app.py b/qubesadmin/app.py index 8c6b749..a88d0e4 100644 --- a/qubesadmin/app.py +++ b/qubesadmin/app.py @@ -216,11 +216,10 @@ class QubesBase(qubesadmin.base.PropertyHolder): pass # then search for index - if type(label) == int or label.isdigit(): + if isinstance(label, int) or label.isdigit(): for i in self.labels.values(): if i.index == int(label): return i - raise KeyError(label) @staticmethod