Skip to content

Conversation

@rgaudin
Copy link
Member

@rgaudin rgaudin commented Jun 16, 2020

Here's a collection of individual small fixes for identified issues:

Please look at them individually and let me know which would make sense to push as separate PRs.

@rgaudin rgaudin marked this pull request as draft June 16, 2020 13:57
Copy link
Contributor

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

There is a lot of few things to change, and some other that may lead to discussion.
It may be better to split the changes in several PR to not block everything while we are discussing only one or two points.

@rgaudin rgaudin force-pushed the rgaudin/various_impr branch from 1e65ca5 to 036e3a7 Compare June 19, 2020 22:12
@rgaudin
Copy link
Member Author

rgaudin commented Jun 19, 2020

@mgautierfr , all your comments have been addressed. There isn't much actual code
change beside moving blocks around in the whole PR so I kept it all here.

You can look at individual commits for a quick lookup.

What's changed since last review:

  • main_page is now mandatory on Creator
  • test on default params for Creator don't inclue dummy assert True
  • get_article_by_id() now raises RuntimeError on out-of-bound – actually anything but not art.is_good(), the try block have been removed.
  • get_article_by_id()'s id param was renamed article_id to not use reserved keyword
  • has_article() method have been removed
  • get_metadata() returns bytes of content of a single metadata article and not the discussed dict.
  • all references to mandatory metadata are gone
  • Creator former methods which had been moved inside close() (as used there and once) have now been put inline, still in that close() method.
  • All docstrings were fixed for the reader API
  • added __enter__ and __exit__ (does nothing) on reader so it can be used as a context manager (syntax sugar only)

@rgaudin rgaudin marked this pull request as ready for review June 19, 2020 22:25
@rgaudin rgaudin requested a review from mgautierfr June 19, 2020 22:25
Copy link
Contributor

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

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

The final code is good.

However, I would prefer to merge the "review changes" into the other commits. At least :

  • It is useless to add a default value to the main page and remove it later.
  • Same for changing the behavior of mandotory_data_ok (or move MANDOTORY_METADATA_KEYS) and remove it.

I think it is pretty difficult to understand correctly the changes when you are exploring the git history to find a bug with this kind of commits in "contradiction".

@rgaudin
Copy link
Member Author

rgaudin commented Jun 23, 2020

OK thanks ; will do soon

@rgaudin rgaudin force-pushed the rgaudin/various_impr branch 2 times, most recently from b062ce6 to b1d3aa3 Compare June 23, 2020 17:16
@rgaudin
Copy link
Member Author

rgaudin commented Jun 23, 2020

Sorry about the delay, was a bit of a pain to reconcile but it's now clean and ready.

@rgaudin rgaudin requested a review from mgautierfr June 23, 2020 17:20
@mgautierfr
Copy link
Contributor

I'm sorry but it is not totally clean yet :)
Commit ed2267b (#47) remove the str in the test, but the acceptance of pathlib as argument come in the commit just after (5ecfab6)

About the execption, maybe we could return KeyError and IndexError instead of NotFound or RuntimeError. But we could change this in another PR, this one is long enough.

@rgaudin
Copy link
Member Author

rgaudin commented Jun 24, 2020

Ah! right, don't be sorry for my mistakes. Will do.

@rgaudin rgaudin force-pushed the rgaudin/various_impr branch from b1d3aa3 to 26d98ba Compare June 24, 2020 20:32
renaud gaudin added 7 commits June 24, 2020 20:32
raise RuntimeError on out-of-bound get_article_by_id()
changed get_article_by_id signature to not use the reserved python keyword `id`
mandatory metadata references gone, as per the spec
Creator converts passed filename to str before passing it to wrapper.
This allows transparent use of pathlib.Path

Also, Creator.filename now returns a pathlib.Path, created on __init__ from the
wrapper returned filename.

Tests updated to use pathlib by default and check .filename type.
Test ensures passing regular str still works.
- fixed, added or updated docstrings
- added type annotations to ease self-discovery
- made `mandatory_metadata_ok` a property
- added a `_closed` boolean prop in creator to record finalization status
- fixed the deletion issue after a contextmanager auto-close (using `self._closed`)
- simplify public API by moving single-use method:
 - `_get_counter_string()` and `write_metadata()` to `close()`
 - `_update_article_counter()` to `add_article()`
 - `pascalize()` to `update_metadata()`
- `write_metadata()` to autmatically convert Date from datetime.datetime as well
- added types annotations in docstring as cython doesn't forward it to gen code
- added a dummy __enter__ and __exit__ so user can use it as a contextmanager for clarity
@rgaudin rgaudin force-pushed the rgaudin/various_impr branch from 26d98ba to 52e9e38 Compare June 24, 2020 20:35
@rgaudin
Copy link
Member Author

rgaudin commented Jun 24, 2020

@mgautierfr That should be good now. Rebased on master. Tests pass on every single commit.

@mgautierfr
Copy link
Contributor

We are good !

@mgautierfr mgautierfr merged commit 9b20717 into master Jun 25, 2020
@mgautierfr mgautierfr deleted the rgaudin/various_impr branch June 25, 2020 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants