Add state file with scanner start time #236
Conversation
- Remove started_at file in config et al. - Add state_fname to config et al. - Remove read/write functions for the started_at file in scanner.py and genearte.py
Regarding |
sbws/lib/v3bwfile.py
Outdated
@@ -210,7 +190,11 @@ def num_lines(self): | |||
|
|||
@staticmethod | |||
def generator_started_from_file(conf): | |||
return read_started_ts(conf) | |||
state = State(conf['paths']['state_fname']) |
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.
I'd just add here a comment (or docstring) about what is supposed to be read here.
Something like "ISO formated timestamp which represents the date and time...."
sbws/util/state.py
Outdated
|
||
|
||
class State: | ||
_ALLOWED_TYPES = (int, float, str, bool, type(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.
i'd add also here a docstring or comment about what is this class for and which format it's supposed to store/read (json)
i'm wondering how easy would be to inherit from json class and overwrite methods. read/write could add just the lock. |
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.
I fold some issues in the tests in addition to needing to acknowledge juga's comments.
tests/unit/util/test_state.py
Outdated
attempt_keys = (15983, None, True, -1.2, [], {}, set()) | ||
for key in attempt_keys: | ||
try: | ||
del state[False] |
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.
This should be state[key]
not state[False]
tests/unit/util/test_state.py
Outdated
for key in d: | ||
state[key] = d[key] | ||
for key in state: | ||
pass |
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.
This should actually test something. Consider checking the length of the iter, as well as making sure the keys in the iter are the same as the keys in d
.
After the above reviews, I plan on:
|
Done with the above mentioned changes. If you approve, let me know and I can resolve the conflict in README.md and merge. Or if you want to, you can. |
i tend to over-engineer things and i think this is a bit doing it, but it's already done, so it's fine |
Closes #166.