diff options
author | Julien Pagès <j.parkouss@gmail.com> | 2016-12-21 14:11:17 +0100 |
---|---|---|
committer | Julien Pagès <j.parkouss@gmail.com> | 2016-12-21 14:11:17 +0100 |
commit | c3fdbf3567b3767b3570fde48b5331a8f680ee82 (patch) | |
tree | 2a664b27d3afc7693470a1b116ebee23e21c4f5f | |
parent | 646472c951df82e632d3b5d9d74571749a26981d (diff) |
fix empty list/None/iterator incompatibility
See https://github.com/parkouss/pyewmh/issues/6.
-rw-r--r-- | ewmh/ewmh.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/ewmh/ewmh.py b/ewmh/ewmh.py index 77b771c..e5ffb18 100644 --- a/ewmh/ewmh.py +++ b/ewmh/ewmh.py @@ -245,7 +245,8 @@ class EWMH: :return: list of Window objects """ - return map(self._createWindow, self._getProperty('_NET_CLIENT_LIST')) + return [self._createWindow(w) + for w in self._getProperty('_NET_CLIENT_LIST')] def getClientListStacking(self): """ @@ -253,8 +254,8 @@ class EWMH: property _NET_CLIENT_LIST_STACKING. :return: list of Window objects""" - return map(self._createWindow, - self._getProperty('_NET_CLIENT_LIST_STACKING')) + return [self._createWindow(w) + for w in self._getProperty('_NET_CLIENT_LIST_STACKING')] def getNumberOfDesktops(self): """ @@ -356,10 +357,10 @@ class EWMH: :param str: True to get a list of string types instead of int :return: list of (int|str) """ - types = self._getProperty('_NET_WM_WINDOW_TYPE', win) + types = self._getProperty('_NET_WM_WINDOW_TYPE', win) or [] if not str: return types - return map(self._getAtomName, types) + return [self._getAtomName(t) for t in types] def getWmState(self, win, str=False): """ @@ -369,10 +370,10 @@ class EWMH: :param str: True to get a list of string states instead of int :return: list of (int|str) """ - states = self._getProperty('_NET_WM_STATE', win) + states = self._getProperty('_NET_WM_STATE', win) or [] if not str: return states - return map(self._getAtomName, states) + return [self._getAtomName(s) for s in states] def getWmAllowedActions(self, win, str=False): """ @@ -383,10 +384,11 @@ class EWMH: :param str: True to get a list of string allowed actions instead of int :return: list of (int|str) """ - wAllowedActions = self._getProperty('_NET_WM_ALLOWED_ACTIONS', win) + wAllowedActions = ( + self._getProperty('_NET_WM_ALLOWED_ACTIONS', win) or []) if not str: return wAllowedActions - return map(self._getAtomName, wAllowedActions) + return [self._getAtomName(a) for a in wAllowedActions] def getWmPid(self, win): """ |