Improve data validation, update records after new posts #60

Merged
cmccabe merged 3 commits from data-updates into master 2019-12-14 17:19:57 +00:00
Collaborator

Fixes #53

A new function data.LinkData.add allows you to add new replies and posts. It writes the record to file, and also to link_data before updating categories (if necessary). This accepts the data.LinkDataRecord class, mainly so it's easy to assign. This means any view items like print_categories() show new data after a record is added.

Fixes #3

This uses two regexes to remove characters from a line. This is not very efficient, as there are two passes on the line, so if the regex can be improved that would be cool. There are also some other changes to the loop that reads data in, hopefully to reduce the number of cycles performed on it.

Other

This is fairly big change, and it reverses some previous changes (like posts_link is now back in linkulator for now). While fixing the issues, I was reading about MVC and so the changes are somewhat based on that idea. Data "model" operations take place in the data.LinkData class, "views" are like print_categories(), and "control" in the menu functions. This approach makes sense to me, but let me know if you have different ideas on this.

I've includes a small amount of tests, and have been through it a bit myself, but let me know what you think and if you see any issues.

#### Fixes #53 A new function `data.LinkData.add` allows you to add new replies and posts. It writes the record to file, and also to link_data before updating categories (if necessary). This accepts the data.LinkDataRecord class, mainly so it's easy to assign. This means any view items like `print_categories()` show new data after a record is added. #### Fixes #3 This uses two regexes to remove characters from a line. This is not very efficient, as there are two passes on the line, so if the regex can be improved that would be cool. There are also some other changes to the loop that reads data in, hopefully to reduce the number of cycles performed on it. #### Other This is fairly big change, and it reverses some previous changes (like `posts_link` is now back in `linkulator` for now). While fixing the issues, I was reading about [MVC](https://www.giacomodebidda.com/mvc-pattern-in-python-introduction-and-basicmodel/) and so the changes are somewhat based on that idea. Data "model" operations take place in the `data.LinkData` class, "views" are like `print_categories()`, and "control" in the menu functions. This approach makes sense to me, but let me know if you have different ideas on this. I've includes a small amount of tests, and have been through it a bit myself, but let me know what you think and if you see any issues.
sloum was assigned by asdf 2019-12-14 02:51:31 +00:00
cmccabe was assigned by asdf 2019-12-14 02:51:31 +00:00
asdf added the
bug
enhancement
this release
labels 2019-12-14 02:51:31 +00:00
cmccabe closed this pull request 2019-12-14 17:19:57 +00:00
asdf deleted branch data-updates 2020-01-09 04:17:10 +00:00
Sign in to join this conversation.
No description provided.