Skip to content

Commit e5df238

Browse files
qinz0822minglumlu
authored andcommitted
Misc changes
Signed-off-by: Qin Zhang (张琴) <[email protected]>
1 parent d16b593 commit e5df238

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

XSConsoleData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ def Match(self, inLine, inRegExp, inKey):
623623
def MultipleMatch(self, inLine, inRegExp, inKey):
624624
match = re.match(inRegExp, inLine)
625625
if match:
626-
if not self.data['dmi'].has_key(inKey):
626+
if inKey not in self.data['dmi']:
627627
self.data['dmi'][inKey] = []
628628
self.data['dmi'][inKey].append(match.group(1))
629629

XSConsoleHotData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __iter__(self):
7171

7272
# This method will hide fields called 'next' in the xapi database. If any appear, __iter__ will need to
7373
# return a new object type and this method will need to be moved into that
74-
def next(self):
74+
def __next__(self):
7575
if len(self.iterKeys) <= 0:
7676
raise StopIteration
7777
retVal = HotAccessor(self.name[:], self.refs[:]) # [:] copies the array

XSConsoleMenus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def Reset(self):
187187
self.CurrentMenu().HandleEnter()
188188

189189
def AddChoice(self, inMenuName, inChoiceDef, inPriority = None):
190-
if not self.menus.has_key(inMenuName):
190+
if inMenuName not in self.menus:
191191
raise Exception(Lang("Unknown menu '")+inMenuName+"'")
192192

193193
self.menus[inMenuName].AddChoiceDef(inChoiceDef, inPriority)

XSConsoleState.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def SaveIfRequired(self):
136136
self.MakeSane()
137137
try:
138138
if not os.path.isdir(self.savePath):
139-
os.mkdir(self.savePath, 0700)
139+
os.mkdir(self.savePath, 0o700)
140140

141141
saveFile = open(self.SaveFilename(), "w")
142142
pickler = pickle.Pickler(saveFile)

simpleconfig.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,32 @@
1818
import os
1919
import shutil
2020

21+
2122
# use our own ASCII only uppercase function to avoid locale issues
2223
# not going to be fast but not important
2324
def uppercase_ASCII_string(str):
2425
newstr = ""
25-
for i in range(0,len(str)):
26-
if str[i] in string.lowercase:
27-
newstr += chr(ord(str[i])-32)
28-
else:
29-
newstr += str[i]
26+
for i in range(0, len(str)):
27+
if str[i] in string.lowercase:
28+
newstr += chr(ord(str[i]) - 32)
29+
else:
30+
newstr += str[i]
3031

3132
return newstr
3233

34+
3335
class SimpleConfigFile:
34-
def __str__ (self):
36+
def __str__(self):
3537
s = ""
36-
keys = self.info.keys ()
37-
keys.sort ()
38+
keys = list(self.info.keys())
39+
keys.sort()
3840
for key in keys:
3941
# FIXME - use proper escaping
40-
if type (self.info[key]) == type(""):
42+
if type(self.info[key]) == type(""):
4143
s = s + key + "=\"" + self.info[key] + "\"\n"
4244
return s
4345

44-
def __init__ (self):
46+
def __init__(self):
4547
self.info = {}
4648

4749
def write(self, file):
@@ -69,17 +71,17 @@ def read(self, file):
6971
value = value.replace("'", '')
7072
self.info[key] = value
7173

72-
def set (self, *args):
74+
def set(self, *args):
7375
for (key, data) in args:
7476
self.info[uppercase_ASCII_string(key)] = data
7577

76-
def unset (self, *keys):
78+
def unset(self, *keys):
7779
for key in keys:
7880
key = uppercase_ASCII_string(key)
79-
if self.info.has_key (key):
80-
del self.info[key]
81+
if key in self.info:
82+
del self.info[key]
8183

82-
def get (self, key):
84+
def get(self, key):
8385
key = uppercase_ASCII_string(key)
8486
return self.info.get(key, "")
8587

@@ -132,4 +134,3 @@ def write(self, dir=None):
132134
path = os.path.join(dir, os.path.basename(self.path))
133135

134136
SimpleConfigFile.write(self, path)
135-

0 commit comments

Comments
 (0)