|
34 | 34 | import re |
35 | 35 | import sys |
36 | 36 | 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 |
39 | 43 |
|
40 | 44 | # ===================================================================== |
41 | 45 | """ Context classes, used during propagation and the "to PFW script" step """ |
@@ -113,13 +117,13 @@ def getPathOptions (self): |
113 | 117 | class Options () : |
114 | 118 | """handle element options""" |
115 | 119 | def __init__(self, options=[], optionNames=[]) : |
116 | | - self.options = dict(izip(optionNames, options)) |
| 120 | + self.options = dict(zip(optionNames, options)) |
117 | 121 | # print(options,optionNames,self.options) |
118 | 122 |
|
119 | 123 |
|
120 | 124 | def __str__(self) : |
121 | 125 | ops2str = [] |
122 | | - for name, argument in self.options.items() : |
| 126 | + for name, argument in list(self.options.items()) : |
123 | 127 | ops2str.append(str(name) + "=\"" + str(argument) + "\"") |
124 | 128 |
|
125 | 129 | return " ".join(ops2str) |
@@ -176,7 +180,7 @@ def extractOptions(self, line) : |
176 | 180 | options = line.split(self.optionDelimiter, len(self.optionNames) - 1) |
177 | 181 |
|
178 | 182 | # get ride of leftover spaces |
179 | | - optionsStrip = list(imap(str.strip, options)) |
| 183 | + optionsStrip = list(map(str.strip, options)) |
180 | 184 |
|
181 | 185 | return optionsStrip |
182 | 186 |
|
|
0 commit comments