i2mint / py2store

Tools to create simple and consistent interfaces to complicated and varied data sources.
MIT License
11 stars 2 forks source link

KV perspectives for standard libs #53

Open thorwhalen opened 4 years ago

thorwhalen commented 4 years ago

Lots of the standard libs that come for free with python have, or could have, one or several read or read/write k/v perspectives.

We covered zipfile module with ZipReader already (still need to extend to ZipPersister), the csv module, but there's many more...

And of course, there's subsets of the modules that could use some kv interfaces. For example, consider inspect.Signature which contains some inspect.Parameter elements. Both dict-like.

As always, start as close to wrapped module as possible first, then transform/subclass/layer to create easier interfaces, consistency groups, or useful extensions.

Consider consistency groups of extensions. For example, any SpecificKvFileReader that takes a file as an input could be extended to a 'SpecificKvDirReaderwhose keys are the file paths or names of the directory and whose values areSpecificKvFileReader(file)`. It's a common useful pattern, so should be implemented as such.

thorwhalen commented 4 years ago

linecache: Wrap to create list-like interface to file lines. If lines themselves are structured (such as csv), can go deeper in the list-like interface.