This class includes a static method that calls a
static method and this fails with:
$ ./swc-installation-test-2.py safari
check Safari (safari)... Traceback (most recent call last):
File "./swc-installation-test-2.py", line 1007, in <module>
passed = check(args)
File "./swc-installation-test-2.py", line 243, in check
version = checker.check()
File "./swc-installation-test-2.py", line 298, in check
return self._check()
File "./swc-installation-test-2.py", line 340, in _check
version = self._get_version()
File "./swc-installation-test-2.py", line 536, in _get_version
return self._get_version_from_plist(path=path)
File "./swc-installation-test-2.py", line 527, in _get_version_from_plist
value = self._get_next(root=tree, element=key)
File "./swc-installation-test-2.py", line 511, in _get_next
parent = self._get_parent(root=root, element=element)
NameError: global name 'self' is not defined
Change the static method _get_next (which is not passed self when
called) to a class method (which is passed the class object) so
that we can call the _get_parent static method (whatever the class is
called).
return node
raise ValueError((root, element))
- @staticmethod
- def _get_next(root, element):
+ @classmethod
+ def _get_next(cls, root, element):
"""Returns the following sibling of this element or None
"""
- parent = self._get_parent(root=root, element=element)
+ parent = cls._get_parent(root=root, element=element)
siblings = iter(parent)
for node in siblings:
if node == element: