I've had two-three nights of "hard refactoring" of pytddmon now, to integrate the Monitor.
Once I started thinking about it, quite a lot of stuff could be removed from the code because of this class:
1. All hashing-stuff was unnecessary
2. That in turn changed all Strategy-classes quite a lot
3. The Regex-strategy really covers all other use cases (static file set, wildcard matching), so I renamed it to "FileFinder" and removed the others
4. Lots of unit tests could be removed (actually only test_monitor and test_color_picker is left. I'm looking at adding unit tests for Pytddmon class though)
5. Lots more small changes, like making the output log more readable.
To make a long story short, "pytddmon.py" went down from 800 lines of
code to 550 lines of code, or more than 30% of the production code
removed. It's probably even more regarding the unit tests. :).
I'm quite happy about that, because suddenly the code is almost possible to grasp again!
Since it was a brutal refactoring, I did it on a separate fork of objarni/pytddmon:
https://bitbucket.org/objarni/pytddmon_monitor_integration
What is left?
- Well the systests are broken at the moment.
- I've tried to write Python3.x compatible code, but I haven't tested it. Tested on 2.7.
Here's an example of the new log output:
"""
Monitoring folder tests.
Found 4 files.
Last change detected at 10:26:07.
Test run took 0.32 seconds.
Log from pytddmon:
.
----------------------------------------------------------------------
Ran 1 test in 0.004s
OK
Log from __init__:
----------------------------------------------------------------------
Ran 0 tests in 0.001s
OK
Log from test_monitor:
......
----------------------------------------------------------------------
Ran 6 tests in 0.001s
OK
Log from test_color_picker:
.........
----------------------------------------------------------------------
Ran 9 tests in 0.000s
OK
"""