EpocDotFr / todotxtio

Simple Python module to parse, manipulate and write Todo.txt data
https://epocdotfr.github.io/todotxtio/
Other
15 stars 9 forks source link

Make Todo's comparable to allow for sorting? #8

Open lordminx opened 6 years ago

lordminx commented 6 years ago

First: Thanks for writing and publishing a cool package!

I started using todotxtio for a little project of mine where I needed something to parse my todo.txt and while playing around with it I noticed that Todo objects are not comparable and thus can't easily be sorted using list.sort() or sorted(). Since this was functionality I was missing I implemented a very rough and NOT production/pull ready sketch of this using functools total_ordering decorator.

Only afterwards I read Issue #2, which I interpret to mean that not adding comparability was intentional and so I figured I open up a new issue and, well, ask:

Is the fact that Todo objects are not comparable to each other the way things are supposed to work or would you accept a PR to add that functionality?

EpocDotFr commented 6 years ago

Hi Lordminx and thank you for your interest in Todo.txt I/O!

Only afterwards I read Issue #2, which I interpret to mean that not adding comparability was intentional and so I figured I open up a new issue and, well, ask: Is the fact that Todo objects are not comparable to each other the way things are supposed to work or would you accept a PR to add that functionality?

That's a good question. When I was developing Web Todo.txt I figured out it was easier to sort tasks on the client-side rather than in the server-side (in fact, it was useless to sort those tasks server-side because the client-side may change the order of the tasks for several reasons at any time without making any request to get a frest tasks list).

Of course there isn't any reason a list of Todo objects cannot be sorted using native Python methods. So yes, your PR is welcome!

EpocDotFr commented 6 years ago

If you make a PR, please create a Contributors section in the readme (just like here) 😄

Also don't forget to write docs (everything is located in the docs folder), it's ReStructuredText files. And of course, docstrings!