GlobalFishingWatch / gpsdio

AIS I/O with Python, dictionaries, and the GPSd AIVDM schema.
Other
6 stars 3 forks source link

Drivers implement an open() method #116

Closed geowurster closed 9 years ago

geowurster commented 9 years ago

Closes #99 and partially addresses #106.

The biggest change here is the implementation of an open() method for each driver, which the BaseDriver() calls on instantiation. This prevents the user from having to manage their own __init__ and is more pythonic. BaseDriver() can now also verify that the I/O mode is valid, although it may crash before it reaches the BaseDriver(). For example, this will raise an exception in the NewlineJSON library rather than in BaseDriver(). We could probably just rely on the underlying opening/closing for handling I/O mode validation but lets keep it to a simple r | w | a for now.

with gpsdio.open('something.json', 'bad-mode') as dst:
    pass
geowurster commented 9 years ago

@redhog ready to merge.