This project will copy blog post images and text from blogger.
Pull down the latest post and images with the flowing:
python main.py --blog_url BLOG_URL --year 2021
Blog slurp doesn't provide too many options. You can list them by running python main.py -h:
usage: main.py [-h] [--blog_url BLOG_URL] [--year YEAR]
Slurp posts and images from blogger.
optional arguments:
-h, --help show this help message and exit
--blog_url BLOG_URL, -b BLOG_URL
Blog Url
--year YEAR, -y YEAR Year to slurp
Setup your dev environment by creating a virtual environment
# virtualenv \path\to\.venv -p path\to\specific_version_python.exe
python -m venv .venv
.venv\scripts\activate
deactivate
Copy the example.env and replace values:
cp example.env .env
This project enforces quite strict PEP8 and PEP257 (Docstring Conventions) compliance on all code submitted.
We use Black for uncompromised code formatting.
Summary of the most relevant points:
- Comments should be full sentences and end with a period.
- Imports should be ordered.
- Constants and the content of lists and dictionaries should be in alphabetical order.
- It is advisable to adjust IDE or editor settings to match those requirements.
Instead of ordering the imports manually, use isort.
pip3 install isort
isort -rc .
Prefer f-strings over %
or str.format
.
#New
f"{some_value} {some_other_value}"
# Old, wrong
"{} {}".format("New", "style")
"%s %s" % ("Old", "style")
One exception is for logging which uses the percentage formatting. This is to avoid formatting the log message when it is suppressed.
_LOGGER.info("Can't connect to the webservice %s at %s", string1, string2)
As it states in the Style Guidelines section all code is checked to verify the following:
- All the unit tests pass
- All code passes the checks from the linting tools
Local testing is done using Tox. To start the tests, activate the virtual environment and simply run the command:
tox
Testing outside of Tox
Running tox
will invoke the full test suite. To be able to run the specific test suites without tox, you'll need to install the test dependencies into your Python environment:
pip3 install -r requirements_test.txt
Now that you have all test dependencies installed, you can run tests on the project:
isort -rc .
codespell main.py
black main.py
flake8 main.py
pylint main.py
pydocstyle main.py