Skip to content

Commit

Permalink
Add wandio options parameter (#10)
Browse files Browse the repository at this point in the history
Add wandio options parameter.

Allows wandio options to be passed in when creating an AvroRsdosReader object to allow for accessing multiple swift projects in the same code.

---------

Co-authored-by: Nicholas264 <[email protected]>
  • Loading branch information
nick-ls and nick-ls authored Jun 26, 2023
1 parent 957a3a0 commit 7ab082d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/pyavro_stardust/baseavro.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ cdef class AvroReader:
cdef bytes unzipped
cdef AvroRecord currentrec
cdef dict schemajson
cdef dict options

cpdef void _readAvroFileHeader(self)
cdef int _parseNextRecord(self, const unsigned char[:] buf,
Expand Down
5 changes: 3 additions & 2 deletions src/pyavro_stardust/baseavro.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,9 @@ cdef class AvroRecord:
self.schemaversion = schemaversion

cdef class AvroReader:
def __init__(self, filepath):
def __init__(self, filepath, options=None):
self.filepath = filepath
self.options = options
self.syncmarker = None
self.fh = None
self.bufrin = bytearray()
Expand Down Expand Up @@ -397,7 +398,7 @@ cdef class AvroReader:
saved = None
while mode != 'fail':
try:
self.fh = wandio.open(self.filepath, mode=mode)
self.fh = wandio.open(self.filepath, mode=mode, options=self.options)
except ValueError as e:
if mode == 'rb':
mode = 'r'
Expand Down
4 changes: 2 additions & 2 deletions src/pyavro_stardust/rsdos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ cdef class AvroRsdos(AvroRecord):
@cython.final
cdef class AvroRsdosReader(AvroReader):

def __init__(self, filepath):
super().__init__(filepath)
def __init__(self, filepath, options=None):
super().__init__(filepath, options)
self.currentrec = AvroRsdos()

cdef int _parseNextRecord(self, const unsigned char[:] buf,
Expand Down

0 comments on commit 7ab082d

Please sign in to comment.