Skip to content

Standardize remaining import scripts with main() #58

@aquarion

Description

@aquarion

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions