mirror of
https://opendev.org/x/pyghmi
synced 2025-01-27 19:37:44 +00:00
Normalize spaces in values and candidates
There are some uefi configuration options that have a confusing yet specific number of spaces in the setting. Improve the experience by normalizing all whitespace to single space in the candidate and the value to select the correct one that will make it to the system. Change-Id: I6b3e162fbaff342077bb16ebcdf492a84dd67529
This commit is contained in:
parent
237cf886ac
commit
758507764a
@ -29,6 +29,7 @@ import pyghmi.media as media
|
||||
import pyghmi.storage as storage
|
||||
import pyghmi.util.webclient as webclient
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import struct
|
||||
import threading
|
||||
@ -178,14 +179,16 @@ class IMMClient(object):
|
||||
newvalues = [newvalue]
|
||||
newnewvalues = []
|
||||
for newvalue in newvalues:
|
||||
newv = re.sub('\s+', ' ', newvalue)
|
||||
if (self.fwo[key]['possible'] and
|
||||
newvalue not in self.fwo[key]['possible']):
|
||||
candlist = []
|
||||
for candidate in self.fwo[key]['possible']:
|
||||
if newvalue.lower().startswith(candidate.lower()):
|
||||
candid = re.sub('\s+', ' ', candidate)
|
||||
if newv.lower().startswith(candid.lower()):
|
||||
newvalue = candidate
|
||||
break
|
||||
if candidate.lower().startswith(newvalue.lower()):
|
||||
if candid.lower().startswith(newv.lower()):
|
||||
candlist.append(candidate)
|
||||
else:
|
||||
if len(candlist) == 1:
|
||||
|
Loading…
x
Reference in New Issue
Block a user