@@ -13,8 +13,7 @@ ctypedef unsigned short uint16_t
13
13
# algorithm. It is partially documented here:
14
14
#
15
15
# https://cran.r-project.org/package=sas7bdat/vignettes/sas7bdat.pdf
16
- cdef const uint8_t[:] rle_decompress(int result_length,
17
- const uint8_t[:] inbuff):
16
+ cdef const uint8_t[:] rle_decompress(int result_length, const uint8_t[:] inbuff):
18
17
19
18
cdef:
20
19
uint8_t control_byte, x
@@ -117,8 +116,7 @@ cdef const uint8_t[:] rle_decompress(int result_length,
117
116
# rdc_decompress decompresses data using the Ross Data Compression algorithm:
118
117
#
119
118
# http://collaboration.cmc.ec.gc.ca/science/rpn/biblio/ddj/Website/articles/CUJ/1992/9210/ross/ross.htm
120
- cdef const uint8_t[:] rdc_decompress(int result_length,
121
- const uint8_t[:] inbuff):
119
+ cdef const uint8_t[:] rdc_decompress(int result_length, const uint8_t[:] inbuff):
122
120
123
121
cdef:
124
122
uint8_t cmd
@@ -233,8 +231,7 @@ cdef class Parser:
233
231
int subheader_pointer_length
234
232
int current_page_type
235
233
bint is_little_endian
236
- const uint8_t[:] (* decompress)(int result_length,
237
- const uint8_t[:] inbuff)
234
+ const uint8_t[:] (* decompress)(int result_length, const uint8_t[:] inbuff)
238
235
object parser
239
236
240
237
def __init__ (self , object parser ):
@@ -267,9 +264,7 @@ cdef class Parser:
267
264
elif column_types[j] == b' s' :
268
265
self .column_types[j] = column_type_string
269
266
else :
270
- raise ValueError (
271
- f" unknown column type: {self.parser.columns[j].ctype}"
272
- )
267
+ raise ValueError (f" unknown column type: {self.parser.columns[j].ctype}" )
273
268
274
269
# compression
275
270
if parser.compression == const.rle_compression:
@@ -296,8 +291,7 @@ cdef class Parser:
296
291
297
292
# update the parser
298
293
self .parser._current_row_on_page_index = self .current_row_on_page_index
299
- self .parser._current_row_in_chunk_index = \
300
- self .current_row_in_chunk_index
294
+ self .parser._current_row_in_chunk_index = self .current_row_in_chunk_index
301
295
self .parser._current_row_in_file_index = self .current_row_in_file_index
302
296
303
297
cdef bint read_next_page(self ):
@@ -318,9 +312,9 @@ cdef class Parser:
318
312
self .current_page_type = self .parser._current_page_type
319
313
self .current_page_block_count = self .parser._current_page_block_count
320
314
self .current_page_data_subheader_pointers_len = len (
321
- self .parser._current_page_data_subheader_pointers)
322
- self .current_page_subheaders_count = \
323
- self .parser._current_page_subheaders_count
315
+ self .parser._current_page_data_subheader_pointers
316
+ )
317
+ self .current_page_subheaders_count = self .parser._current_page_subheaders_count
324
318
325
319
cdef readline(self ):
326
320
@@ -358,31 +352,31 @@ cdef class Parser:
358
352
return False
359
353
elif (self .current_page_type == page_mix_types_0 or
360
354
self .current_page_type == page_mix_types_1):
361
- align_correction = (bit_offset + subheader_pointers_offset +
362
- self .current_page_subheaders_count *
363
- subheader_pointer_length)
355
+ align_correction = (
356
+ bit_offset
357
+ + subheader_pointers_offset
358
+ + self .current_page_subheaders_count * subheader_pointer_length
359
+ )
364
360
align_correction = align_correction % 8
365
361
offset = bit_offset + align_correction
366
362
offset += subheader_pointers_offset
367
- offset += (self .current_page_subheaders_count *
368
- subheader_pointer_length)
363
+ offset += self .current_page_subheaders_count * subheader_pointer_length
369
364
offset += self .current_row_on_page_index * self .row_length
370
- self .process_byte_array_with_data(offset,
371
- self .row_length)
372
- mn = min (self .parser.row_count,
373
- self .parser._mix_page_row_count)
365
+ self .process_byte_array_with_data(offset, self .row_length)
366
+ mn = min (self .parser.row_count, self .parser._mix_page_row_count)
374
367
if self .current_row_on_page_index == mn:
375
368
done = self .read_next_page()
376
369
if done:
377
370
return True
378
371
return False
379
372
elif self .current_page_type & page_data_type == page_data_type:
380
373
self .process_byte_array_with_data(
381
- bit_offset + subheader_pointers_offset +
382
- self .current_row_on_page_index * self .row_length,
383
- self .row_length)
384
- flag = (self .current_row_on_page_index ==
385
- self .current_page_block_count)
374
+ bit_offset
375
+ + subheader_pointers_offset
376
+ + self .current_row_on_page_index * self .row_length,
377
+ self .row_length,
378
+ )
379
+ flag = self .current_row_on_page_index == self .current_page_block_count
386
380
if flag:
387
381
done = self .read_next_page()
388
382
if done:
0 commit comments