Skip to content
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

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open

Release 0.1.0 #1

wants to merge 66 commits into from

Conversation

thawes-rse
Copy link
Member

No description provided.

File creation now occurs at the first call to open().
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.
@thawes-rse
Copy link
Member Author

@stephenpcook Note an extra few commits have been added, from merging #3 into dev.

Copy link
Member

@stephenpcook stephenpcook left a 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.

Copy link
Member

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.

Copy link
Member

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",
Copy link
Member

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" },
Copy link
Member

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):
Copy link
Member

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)

Copy link
Member

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()
Copy link
Member

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."
)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: explicit return None ?

Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants