URL Grabber Is Mostly Working
`youtube: https://www.youtube.com/watch?v=eCPD_9_PDek`
### [Start: 00:00:00] - Refactoring My Daily URL Grabber
I spent this stream making progress on my URL Grabber. Most of the time was spent refactoring. I switched to sending values into instance methods instead of pulling data from instance variables. It makes the tests look nicer. But, I don't like the overhead it adds when using the class (e.g. I'd rather call [TODO: Code shorthand span ] and `ua.method(ua.variable)`).
I've done very little OOP. I'm not sure what the best practice is. I'm guessing it's to use instance variables directly, since, you know, they're there. I'll do some more looking at that. (I wouldn't be surprised to find a religious war between the two approaches.) In the mean time, I'm going to go back to using the instance variable as local variables inside the methods instead of passing them in. It won't make the test code that much uglier and it'll clean up the main running of the script.
The new code I put in place is to store the data storage JSONs and final output .md files in date specific locations. There's some hard coding, but the script is working.
Next steps:
- Alphabetize output - Setup RegEx patterns to filter out localhost domains, work domains, etc... - Move hard coded variables into a config file - Make any directories that don't exist when saving outputs (i.e. `mkdir -p`) - Setup a blog post template to put the links in - Build the launchd script that triggers the process every ten minutes
And, that should do it for the first version.
Here's the script in it's current state:
And, here's the tests:
### Links From The Stream
- datetime — Basic date and time types — Python 3.9.0 documentation - Example Domain - Exercism - Getting today's date in YYYY-MM-DD in Python? - Stack Overflow - How do I mock the filesystem in Python unit tests? - Stack Overflow - How to get current date and time in Python? - How to replace file-access references for a module under test - Stack Overflow - jmcgeheeiv/pyfakefs: pyfakefs implements a fake file system that mocks the Python file system modules. - jmcgeheeiv/pyfakefs: pyfakefs implements a fake file system that mocks the Python file system modules. - Nature - pyfakefs · PyPI - Reverse a string in Python - Stack Overflow - Video List - Google Sheets - Yea Alabama! - YouTube