python-cryptography: bump to version 1.7.2
[buildroot-gz.git] / package / pseudo / 0003-Make-it-compatible-with-python3.patch
blob3bb74deacf94802aaccd7db4e5ba63a259d7a5aa
1 From fcc10b1f4a9968af5cda1adb9e449df92939d5f2 Mon Sep 17 00:00:00 2001
2 From: =?utf-8?q?Ga=C3=ABl=20PORTAY?= <gael.portay@savoirfairelinux.com>
3 Date: Fri, 4 Nov 2016 15:58:46 -0400
4 Subject: [PATCH 3/3] Make it compatible with python3
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=utf-8
7 Content-Transfer-Encoding: 8bit
9 Python scripts are now compatible with both version of python, 2 and 3.
11 Helped-by: Damien Riegel <damien.riegel@savoirfairelinux.com>
12 Helped-by: Alexandre Leblanc <alexandre.leblanc@savoirfairelinux.com>
13 Signed-off-by: Gaƫl PORTAY <gael.portay@savoirfairelinux.com>
14 ---
15 maketables | 135 ++++++++++++++++++++++++++++++-----------------------------
16 makewrappers | 8 ++--
17 2 files changed, 73 insertions(+), 70 deletions(-)
19 diff --git a/maketables b/maketables
20 index 0726485..f74f2b1 100755
21 --- a/maketables
22 +++ b/maketables
23 @@ -51,6 +51,7 @@ value. (This is for consistency with C array bounds.)
24 import glob
25 import sys
26 import string
27 +import os
28 from templatefile import TemplateFile
30 class DataType:
31 @@ -58,74 +59,74 @@ class DataType:
33 def __init__(self, path):
34 """read the first line of path, then make tuples of the rest"""
35 - source = file(path)
36 - definition = source.readline().rstrip()
37 - self.name, qualifiers = string.split(definition, ': ', 2)
38 - if '; ' in qualifiers:
39 - self.prefix, columns = string.split(qualifiers, '; ')
40 - else:
41 - self.prefix = qualifiers
42 - columns = []
43 - self.flags = False
44 - if len(columns):
45 - self.columns = []
46 - columns = string.split(columns, ', ')
47 - for col in columns:
48 - indexed = False
49 - if col.startswith("FLAGS"):
50 - print("Flags: set for %s" % self.name)
51 - self.flags = True
52 + with open(path,'r') as source:
53 + definition = source.readline().rstrip()
54 + self.name, qualifiers = definition.split(': ', 2)
55 + if '; ' in qualifiers:
56 + self.prefix, columns = qualifiers.split('; ')
57 + else:
58 + self.prefix = qualifiers
59 + columns = []
60 + self.flags = False
61 + if len(columns):
62 + self.columns = []
63 + columns = columns.split(', ')
64 + for col in columns:
65 + indexed = False
66 + if col.startswith("FLAGS"):
67 + print("Flags: set for %s" % self.name)
68 + self.flags = True
69 + continue
70 + if col.startswith("INDEXED "):
71 + col = col[8:]
72 + indexed = True
73 + if "=" in col:
74 + name, default = col.split(' = ')
75 + else:
76 + name, default = col, ""
77 + if " " in name:
78 + words = name.split(' ')
79 + name = words[-1]
80 + del words[-1]
81 + type = ' '.join(words)
82 + else:
83 + type = "char *"
84 + self.columns.append({"indexed":indexed, "type":type, "name":name, "value":default})
85 + else:
86 + self.columns = []
87 + self.data = []
88 + self.comments = []
89 + index = 1
90 + for line in source.readlines():
91 + item = {}
92 + if line.startswith('#'):
93 + self.comments.append(line.rstrip().replace('#', ''))
94 continue
95 - if col.startswith("INDEXED "):
96 - col = col[8:]
97 - indexed = True
98 - if "=" in col:
99 - name, default = string.split(col, ' = ')
100 - else:
101 - name, default = col, ""
102 - if " " in name:
103 - words = string.split(name, ' ')
104 - name = words[-1]
105 - del words[-1]
106 - type = ' '.join(words)
107 - else:
108 - type = "char *"
109 - self.columns.append({"indexed":indexed, "type":type, "name":name, "value":default})
110 - else:
111 - self.columns = []
112 - self.data = []
113 - self.comments = []
114 - index = 1
115 - for line in source.readlines():
116 - item = {}
117 - if line.startswith('#'):
118 - self.comments.append(line.rstrip().replace('#', ''))
119 - continue
120 - # first entry on the line is the "real" name/id, following hunks
121 - # are additional columns
122 - cols = string.split(line.rstrip(), ', ')
123 - item["name"] = cols.pop(0)
124 - item["upper"] = item["name"].replace('-', '_').upper()
125 - column_list = []
126 - for col in self.columns:
127 - if len(cols) > 0:
128 - value = cols.pop(0)
129 - if col["indexed"]:
130 - if not "max" in col:
131 - col["max"] = value
132 - if value > col["max"]:
133 - col["max"] = value
134 - if not "min" in col:
135 - col["min"] = value
136 - if value < col["min"]:
137 - col["min"] = value
138 - column_list.append({"name":col["name"], "value":value})
139 - else:
140 - column_list.append({"name":col["name"], "value":col["value"]})
141 - item["cols"] = column_list
142 - item["index"] = index
143 - index = index + 1
144 - self.data.append(item)
145 + # first entry on the line is the "real" name/id, following hunks
146 + # are additional columns
147 + cols = line.rstrip().split(', ')
148 + item["name"] = cols.pop(0)
149 + item["upper"] = item["name"].replace('-', '_').upper()
150 + column_list = []
151 + for col in self.columns:
152 + if len(cols) > 0:
153 + value = cols.pop(0)
154 + if col["indexed"]:
155 + if not "max" in col:
156 + col["max"] = value
157 + if value > col["max"]:
158 + col["max"] = value
159 + if not "min" in col:
160 + col["min"] = value
161 + if value < col["min"]:
162 + col["min"] = value
163 + column_list.append({"name":col["name"], "value":value})
164 + else:
165 + column_list.append({"name":col["name"], "value":col["value"]})
166 + item["cols"] = column_list
167 + item["index"] = index
168 + index = index + 1
169 + self.data.append(item)
171 def __getitem__(self, key):
172 """Make this object look like a dict for Templates to use"""
173 diff --git a/makewrappers b/makewrappers
174 index bac856b..ff08ba0 100755
175 --- a/makewrappers
176 +++ b/makewrappers
177 @@ -453,6 +453,8 @@ additional ports to include.
180 def __init__(self, port, sources):
181 + if type(port) is not str:
182 + port = str(port, encoding="ascii")
183 self.name = port
184 self.subports = []
185 self.preports = []
186 @@ -483,7 +485,7 @@ additional ports to include.
187 if retcode:
188 raise Exception("preports script failed for port %s" % self.name)
190 - for preport in string.split(portlist):
191 + for preport in portlist.split():
192 next = Port(preport, sources)
193 self.preports.append(next)
195 @@ -494,7 +496,7 @@ additional ports to include.
196 if retcode:
197 raise Exception("subports script failed for port %s" % self.name)
199 - for subport in string.split(portlist):
200 + for subport in portlist.split():
201 next = Port(subport, sources)
202 self.subports.append(next)
204 @@ -519,7 +521,7 @@ additional ports to include.
205 return mergedfuncs
207 def define(self):
208 - return '#define PSEUDO_PORT_%s 1' % string.upper(self.name).replace('/', '_')
209 + return '#define PSEUDO_PORT_%s 1' % self.name.upper().replace('/', '_')
211 def portdeps(self):
212 deps = []
214 2.10.1