62
62
'crc32_1' : 'crc32' , 'crc32_2' : 'crc32' ,
63
63
}
64
64
65
+
65
66
class YencError (Exception ):
66
67
""" Class for specific yEnc errors
67
68
"""
@@ -91,30 +92,31 @@ def __str__(self):
91
92
# the below code was based on the yEnc libraries. But
92
93
# the part that is blisterily fast (Written in C) will
93
94
# be writting in python (a much slower solution)
94
-
95
95
FAST_YENC_SUPPORT = False
96
96
97
- YENC42 = '' .join (map (lambda x : chr ((x - 42 ) & 255 ), range (256 )))
98
-
99
- # a map that identifies all of the special keywords used by
100
- # yEnc which need a special conversion done to them before
101
- # We use the curses.ascii table to make our code easier to read
102
- from curses import ascii
103
- YENC_DECODE_SPECIAL_MAP = dict ([('=%s' % chr (k + 64 ), chr (k )) for k in (
104
- # Non-Printable
105
- ascii .NUL , ascii .LF , ascii .CR , ascii .SP , ascii .TAB ,
106
-
107
- # Printable
108
- ord ('.' ), ord ('=' ),
109
- )] + [
110
- # Ignore Types (we simply ignore these types if they are found)
111
- (chr (ascii .LF ), '' ), (chr (ascii .CR ), '' ),
112
- ])
113
-
114
- # Compile our map into a decode table
115
- YENC_DECODE_SPECIAL_RE = re .compile (
116
- r'(' + r'|' .join (YENC_DECODE_SPECIAL_MAP .keys ()) + r')' ,
117
- )
97
+ # A Translation Map
98
+ YENC42 = '' .join (map (lambda x : chr ((x - 42 ) & 255 ), range (256 )))
99
+
100
+ # a map that identifies all of the special keywords used by
101
+ # yEnc which need a special conversion done to them before
102
+ # We use the curses.ascii table to make our code easier to read
103
+ from curses import ascii
104
+ YENC_DECODE_SPECIAL_MAP = dict ([('=%s' % chr (k + 64 ), chr (k )) for k in (
105
+ # Non-Printable
106
+ ascii .NUL , ascii .LF , ascii .CR , ascii .SP , ascii .TAB ,
107
+
108
+ # Printable
109
+ ord ('.' ), ord ('=' ),
110
+ )] + [
111
+ # Ignore Types (we simply ignore these types if they are found)
112
+ (chr (ascii .LF ), '' ), (chr (ascii .CR ), '' ),
113
+ ])
114
+
115
+ # Compile our map into a decode table
116
+ YENC_DECODE_SPECIAL_RE = re .compile (
117
+ r'(' + r'|' .join (YENC_DECODE_SPECIAL_MAP .keys ()) + r')' ,
118
+ )
119
+
118
120
119
121
class CodecYenc (CodecBase ):
120
122
@@ -133,7 +135,6 @@ def __init__(self, descriptor=None, tmp_dir=None, *args, **kwargs):
133
135
# content
134
136
self .decoded = None
135
137
136
-
137
138
def detect (self , line , relative = True ):
138
139
"""
139
140
A Simple function that can be used to determine if there is
@@ -186,7 +187,6 @@ def detect(self, line, relative=True):
186
187
187
188
return f_map
188
189
189
-
190
190
def decode (self , stream ):
191
191
""" Decode some data and decode the data
192
192
to descriptor identified (by the stream)
@@ -290,7 +290,7 @@ def decode(self, stream):
290
290
except YencError :
291
291
logger .warning (
292
292
"Corruption on line %d." % \
293
- self ._lines ,
293
+ self ._lines ,
294
294
)
295
295
296
296
# Line Tracking
@@ -334,14 +334,13 @@ def decode(self, stream):
334
334
# Reset part information
335
335
self ._part_no = 1
336
336
337
- if self .decoded :
337
+ if self .decoded :
338
338
# close article when complete
339
339
self .decoded .close ()
340
340
341
341
# Return what we do have
342
342
return self .decoded
343
343
344
-
345
344
def reset (self ):
346
345
"""
347
346
Reset our decoded content
@@ -359,14 +358,12 @@ def reset(self):
359
358
# content
360
359
self .decoded = None
361
360
362
-
363
361
def __lt__ (self , other ):
364
362
"""
365
363
Sorts by part number
366
364
"""
367
365
return self ._part_no < other ._part_no
368
366
369
-
370
367
def __str__ (self ):
371
368
"""
372
369
Return a printable version of the file being read
@@ -382,7 +379,6 @@ def __str__(self):
382
379
fname
383
380
)
384
381
385
-
386
382
def __repr__ (self ):
387
383
"""
388
384
Return a printable object
0 commit comments