1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-09-23 12:21:54 +01:00

Add support for Python 3

Add support for running on Python 3 while maintaining Python 2
compatibility.
This commit is contained in:
Sergei Trofimov
2018-05-30 15:58:32 +01:00
committed by Marc Bonnici
parent 0d63386343
commit 5cafd2ec4d
35 changed files with 298 additions and 172 deletions

View File

@@ -19,6 +19,8 @@ import time
import logging
from copy import copy
from past.builtins import basestring
from devlib.utils.serial_port import write_characters, TIMEOUT
from devlib.utils.types import boolean
@@ -193,14 +195,14 @@ class UefiMenu(object):
is not in the current menu, ``LookupError`` will be raised."""
if not self.prompt:
self.read_menu(timeout)
return self.options.items()
return list(self.options.items())
def get_option_index(self, text, timeout=default_timeout):
"""Returns the menu index of the specified option text (uses regex matching). If the option
is not in the current menu, ``LookupError`` will be raised."""
if not self.prompt:
self.read_menu(timeout)
for k, v in self.options.iteritems():
for k, v in self.options.items():
if re.search(text, v):
return k
raise LookupError(text)