#!python
import argparse

import importlib
import pkgutil

from startme import StartMe
import startme.mods

def iter_namespace(ns_pkg):
    # Specifying the second argument (prefix) to iter_modules makes the
    # returned name an absolute name instead of a relative one. This allows
    # import_module to work without having to do additional modification to
    # the name.
    return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".")


def main():
    print("startme")

    mods = {
        name: importlib.import_module(name)
        for finder, name, ispkg
        in iter_namespace(startme.mods)
    }

    print("mods:")
    print(mods)


    for cls in StartMe.__subclasses__():
        print("cls:", cls)
        c = cls()
        if c.onstart:
            c.run()



main()