Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 1376ab0

Browse files
committed
xml-generator: More Python 3.x compatibility
the izip and imap functions have been removed from the itertools module in Python 3.x. Strangely, this was missed in c04e2f7. Signed-off-by: David Wagner <[email protected]>
1 parent d553cd5 commit 1376ab0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/xmlGenerator/EddParser.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,12 @@
3434
import re
3535
import sys
3636
import copy
37-
from itertools import izip
38-
from itertools import imap
37+
# For Python 2.x/3.x compatibility
38+
try:
39+
from itertools import izip as zip
40+
from itertools import imap as map
41+
except:
42+
pass
3943

4044
# =====================================================================
4145
""" Context classes, used during propagation and the "to PFW script" step """
@@ -113,13 +117,13 @@ def getPathOptions (self):
113117
class Options () :
114118
"""handle element options"""
115119
def __init__(self, options=[], optionNames=[]) :
116-
self.options = dict(izip(optionNames, options))
120+
self.options = dict(zip(optionNames, options))
117121
# print(options,optionNames,self.options)
118122

119123

120124
def __str__(self) :
121125
ops2str = []
122-
for name, argument in self.options.items() :
126+
for name, argument in list(self.options.items()) :
123127
ops2str.append(str(name) + "=\"" + str(argument) + "\"")
124128

125129
return " ".join(ops2str)
@@ -176,7 +180,7 @@ def extractOptions(self, line) :
176180
options = line.split(self.optionDelimiter, len(self.optionNames) - 1)
177181

178182
# get ride of leftover spaces
179-
optionsStrip = list(imap(str.strip, options))
183+
optionsStrip = list(map(str.strip, options))
180184

181185
return optionsStrip
182186

0 commit comments

Comments
 (0)