Continue standardizing import scripts to use main() functions instead of executing at import time.
Completed (examples)
lastfm.py - Simple pattern
atom.py - With custom arguments
flickr.py - Complex with DB access
Remaining scripts (~20)
Run grep -L 'def main' imports/*.py to see the full list.
Scripts to update include:
- atproto_posts.py
- destiny2.py
- facebook_page.py
- facebook_posts.py
- fitbit_day.py
- foursquare.py
- github_commits.py
- historic.py
- instagram.py
- mailbox-stats.py
- mastodon_toots.py
- oyster_csv.py
- oyster.py
- steambadges.py
- switchbot.py
- tumblr.py
- tweets.py
- wordpress.py
- wow.py
Pattern to follow
"""Module docstring."""
import logging
import lifestream
from lifestream.db import EntryStore
logger = logging.getLogger('ModuleName')
def main():
"""Main function docstring."""
args = lifestream.parse_args()
# ... logic here ...
if __name__ == '__main__':
main()
Benefits
- Scripts can be imported without side effects
- Easier to test
- Consistent structure across codebase
Continue standardizing import scripts to use
main()functions instead of executing at import time.Completed (examples)
lastfm.py- Simple patternatom.py- With custom argumentsflickr.py- Complex with DB accessRemaining scripts (~20)
Run
grep -L 'def main' imports/*.pyto see the full list.Scripts to update include:
Pattern to follow
Benefits