-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 0.1.0 #1
base: main
Are you sure you want to change the base?
Conversation
File creation now occurs at the first call to open().
Not needed yet.
Not needed.
No longer uses manual management of the underlying file but instead uses a context manager.
The _Fields class is intended to define a collection of fields, while making sure that there are no repeated fields. Equality of fields is also tested independent of the order in which the fields occur.
The error handling got too messy when using a different class.
Now avoids using the deprecated assertRaisesRegexp.
These are immutable and we prefer to return immutable objects to a user and let them convert these to mutable objects if they wish.
Now raise a ValueError if the supplied fields argument contains repetitions.
Test for create() now includes checking the case where None is the value of a field.
Make the names more agnostic to the fact that they are applied to field names.
The changed order is more in keeping with thinking about lookups as 'field'='value'.
Fix some formatting that was causing the start to render incorrectly. Also add some material about using CsvDB in try-catch blocks.
The fields stored in the CsvDB instance will now be ordered as per the csv file, if this exists. This ensures that reading and writing records from/to the file correctly aligns record values with the corresponding fields.
Issue 2: field ordering
@stephenpcook Note an extra few commits have been added, from merging #3 into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work Tom! Some suggestions following on from our discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a short "QUICKSTART" at the head of the documentation demonstrating the minimal most-useful use case.
for interfacing with such a csv file, equipped with methods for creating, retrieving and | ||
updating records in the file. It has no dependencies other than the Python standard | ||
library. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slightly alluded to "focus on simplicity" but worth mentioning here that it's probably inappropriate to work with "big" CSV files (tens of thousands of rows?).
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 3.12?
license = {file = "LICENCE.txt"} | ||
keywords = [] | ||
authors = [ | ||
{ name = "Thomas Hawes" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add e-mail address to authors section?
def tearDown(self) -> None: | ||
self._dir.cleanup() | ||
|
||
def test_initialise_existing_file(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: i18n? initialise vs initialize (multiple places)
writer = csv.DictWriter(csvfile, self._fields) | ||
writer.writeheader() | ||
writer.writerows(records) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider explicit return None
""" | ||
|
||
if not self._path.exists(): | ||
return tuple() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alternatives to returning a tuple? (I don't have strong feelings here.)
if field not in self._fields: | ||
raise DatabaseLookupError( | ||
f"'{field}' does not define a field in the database." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Explicit return None
?
writer = csv.DictWriter(csvfile, self._fields) | ||
if mode == "x": | ||
writer.writeheader() | ||
writer.writerow(record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: explicit return None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Check mypy errors (but probably not a good use of time chasing all these warnings away).
No description provided.