pawelad / pymonzo

Modern Python API client for Monzo public API.
https://pymonzo.pawelad.dev/
Mozilla Public License 2.0
21 stars 21 forks source link

Token file has `.db` extension on OS X #3

Closed pawelad closed 7 years ago

pawelad commented 7 years ago

Per comments in #2 , the token file (~/.pymonzo-token) for some reason has a .db extension on OS X which makes pymonzo think it does not exist.

pawelad commented 7 years ago

I believe this is the reason:

There is quite some indirection here. Follow me carefully.

The shelve module is implemented on top of the anydbm module. This module acts as a facade for 4 different specific DBM implementations, and it will pick the first module available when creating a new database, in the following order:

dbhash (deprecated but still the first anydbm choice). This is a proxy for the bsddb module, .open() is really bsddb.hashopen() gdbm, Python module for the GNU DBM library, offering more functionality than the dbm module can offer when used with this same lbrary. dbm, a proxy module using either the ndbm, BSD DB and GNU DBM libraries (choosen when Python is compiled). dumbdbm, a pure-python implementation. It is this range of choices that makes shelve files appear to grow extra extensions on different platforms.

The dumbdbm module is the one that adds the .bak, .dat and .dir extensions:

Open a dumbdbm database and return a dumbdbm object. The filename argument is the basename of the database file (without any specific extensions). When a dumbdbm database is created, files with .dat and .dir extensions are created. The .dir file is moved to .bak as new index dicts are committed for changes made to the data structures.

It means that the other three options for anydbm are not available on your platform.

The other formats may give you other extensions. The dbm module may use .dir, .pag or .db, depending on what library was used for that module.

Source


I think I had it with shelve and will just switch to a regular JSON file.

pawelad commented 7 years ago

This should be resolved in v0.10.0