comparison env/lib/python3.7/site-packages/webencodings/x_user_defined.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 # coding: utf-8
2 """
3
4 webencodings.x_user_defined
5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
7 An implementation of the x-user-defined encoding.
8
9 :copyright: Copyright 2012 by Simon Sapin
10 :license: BSD, see LICENSE for details.
11
12 """
13
14 from __future__ import unicode_literals
15
16 import codecs
17
18
19 ### Codec APIs
20
21 class Codec(codecs.Codec):
22
23 def encode(self, input, errors='strict'):
24 return codecs.charmap_encode(input, errors, encoding_table)
25
26 def decode(self, input, errors='strict'):
27 return codecs.charmap_decode(input, errors, decoding_table)
28
29
30 class IncrementalEncoder(codecs.IncrementalEncoder):
31 def encode(self, input, final=False):
32 return codecs.charmap_encode(input, self.errors, encoding_table)[0]
33
34
35 class IncrementalDecoder(codecs.IncrementalDecoder):
36 def decode(self, input, final=False):
37 return codecs.charmap_decode(input, self.errors, decoding_table)[0]
38
39
40 class StreamWriter(Codec, codecs.StreamWriter):
41 pass
42
43
44 class StreamReader(Codec, codecs.StreamReader):
45 pass
46
47
48 ### encodings module API
49
50 codec_info = codecs.CodecInfo(
51 name='x-user-defined',
52 encode=Codec().encode,
53 decode=Codec().decode,
54 incrementalencoder=IncrementalEncoder,
55 incrementaldecoder=IncrementalDecoder,
56 streamreader=StreamReader,
57 streamwriter=StreamWriter,
58 )
59
60
61 ### Decoding Table
62
63 # Python 3:
64 # for c in range(256): print(' %r' % chr(c if c < 128 else c + 0xF700))
65 decoding_table = (
66 '\x00'
67 '\x01'
68 '\x02'
69 '\x03'
70 '\x04'
71 '\x05'
72 '\x06'
73 '\x07'
74 '\x08'
75 '\t'
76 '\n'
77 '\x0b'
78 '\x0c'
79 '\r'
80 '\x0e'
81 '\x0f'
82 '\x10'
83 '\x11'
84 '\x12'
85 '\x13'
86 '\x14'
87 '\x15'
88 '\x16'
89 '\x17'
90 '\x18'
91 '\x19'
92 '\x1a'
93 '\x1b'
94 '\x1c'
95 '\x1d'
96 '\x1e'
97 '\x1f'
98 ' '
99 '!'
100 '"'
101 '#'
102 '$'
103 '%'
104 '&'
105 "'"
106 '('
107 ')'
108 '*'
109 '+'
110 ','
111 '-'
112 '.'
113 '/'
114 '0'
115 '1'
116 '2'
117 '3'
118 '4'
119 '5'
120 '6'
121 '7'
122 '8'
123 '9'
124 ':'
125 ';'
126 '<'
127 '='
128 '>'
129 '?'
130 '@'
131 'A'
132 'B'
133 'C'
134 'D'
135 'E'
136 'F'
137 'G'
138 'H'
139 'I'
140 'J'
141 'K'
142 'L'
143 'M'
144 'N'
145 'O'
146 'P'
147 'Q'
148 'R'
149 'S'
150 'T'
151 'U'
152 'V'
153 'W'
154 'X'
155 'Y'
156 'Z'
157 '['
158 '\\'
159 ']'
160 '^'
161 '_'
162 '`'
163 'a'
164 'b'
165 'c'
166 'd'
167 'e'
168 'f'
169 'g'
170 'h'
171 'i'
172 'j'
173 'k'
174 'l'
175 'm'
176 'n'
177 'o'
178 'p'
179 'q'
180 'r'
181 's'
182 't'
183 'u'
184 'v'
185 'w'
186 'x'
187 'y'
188 'z'
189 '{'
190 '|'
191 '}'
192 '~'
193 '\x7f'
194 '\uf780'
195 '\uf781'
196 '\uf782'
197 '\uf783'
198 '\uf784'
199 '\uf785'
200 '\uf786'
201 '\uf787'
202 '\uf788'
203 '\uf789'
204 '\uf78a'
205 '\uf78b'
206 '\uf78c'
207 '\uf78d'
208 '\uf78e'
209 '\uf78f'
210 '\uf790'
211 '\uf791'
212 '\uf792'
213 '\uf793'
214 '\uf794'
215 '\uf795'
216 '\uf796'
217 '\uf797'
218 '\uf798'
219 '\uf799'
220 '\uf79a'
221 '\uf79b'
222 '\uf79c'
223 '\uf79d'
224 '\uf79e'
225 '\uf79f'
226 '\uf7a0'
227 '\uf7a1'
228 '\uf7a2'
229 '\uf7a3'
230 '\uf7a4'
231 '\uf7a5'
232 '\uf7a6'
233 '\uf7a7'
234 '\uf7a8'
235 '\uf7a9'
236 '\uf7aa'
237 '\uf7ab'
238 '\uf7ac'
239 '\uf7ad'
240 '\uf7ae'
241 '\uf7af'
242 '\uf7b0'
243 '\uf7b1'
244 '\uf7b2'
245 '\uf7b3'
246 '\uf7b4'
247 '\uf7b5'
248 '\uf7b6'
249 '\uf7b7'
250 '\uf7b8'
251 '\uf7b9'
252 '\uf7ba'
253 '\uf7bb'
254 '\uf7bc'
255 '\uf7bd'
256 '\uf7be'
257 '\uf7bf'
258 '\uf7c0'
259 '\uf7c1'
260 '\uf7c2'
261 '\uf7c3'
262 '\uf7c4'
263 '\uf7c5'
264 '\uf7c6'
265 '\uf7c7'
266 '\uf7c8'
267 '\uf7c9'
268 '\uf7ca'
269 '\uf7cb'
270 '\uf7cc'
271 '\uf7cd'
272 '\uf7ce'
273 '\uf7cf'
274 '\uf7d0'
275 '\uf7d1'
276 '\uf7d2'
277 '\uf7d3'
278 '\uf7d4'
279 '\uf7d5'
280 '\uf7d6'
281 '\uf7d7'
282 '\uf7d8'
283 '\uf7d9'
284 '\uf7da'
285 '\uf7db'
286 '\uf7dc'
287 '\uf7dd'
288 '\uf7de'
289 '\uf7df'
290 '\uf7e0'
291 '\uf7e1'
292 '\uf7e2'
293 '\uf7e3'
294 '\uf7e4'
295 '\uf7e5'
296 '\uf7e6'
297 '\uf7e7'
298 '\uf7e8'
299 '\uf7e9'
300 '\uf7ea'
301 '\uf7eb'
302 '\uf7ec'
303 '\uf7ed'
304 '\uf7ee'
305 '\uf7ef'
306 '\uf7f0'
307 '\uf7f1'
308 '\uf7f2'
309 '\uf7f3'
310 '\uf7f4'
311 '\uf7f5'
312 '\uf7f6'
313 '\uf7f7'
314 '\uf7f8'
315 '\uf7f9'
316 '\uf7fa'
317 '\uf7fb'
318 '\uf7fc'
319 '\uf7fd'
320 '\uf7fe'
321 '\uf7ff'
322 )
323
324 ### Encoding table
325 encoding_table = codecs.charmap_build(decoding_table)