# Path: statirator/core/utils.py
# def find_readers():
#     """Auto discover readers in installed apps.
# 
#     Each readers.py should have the READERS list with reader classes
#     """
# 
#     from django.conf import settings
#     from django.utils.importlib import import_module
#     from django.utils.module_loading import module_has_submodule
# 
#     readers = []
#     for app in settings.INSTALLED_APPS:
#         mod = import_module(app)
#         # Attempt to import the app's admin module.
#         try:
#             walk_mod = import_module('%s.readers' % app)
#             if hasattr(walk_mod, 'READERS'):
#                 readers.extend(walk_mod.READERS)
#             else:
#                 logging.warn(
#                     'readers found in app %s, but has no READERS attrib',
#                     app)
#         except:
#             # Decide whether to bubble up this error. If the app just
#             # doesn't have an readers module, we can ignore the error
#             # attempting to import it, otherwise we want it to bubble up.
#             if module_has_submodule(mod, 'readers'):
#                 raise
# 
#     return readers


import logging
from django.core.management import call_command
from django.core.management.base import BaseCommand
from statirator.core.utils import find_readers
        from django.conf import settings
        from django.contrib.sites.models import Site
    def handle(self, *args, **options):

        self.syncdb()
        self.create_sites()
        self.read_resources()
        self.gen_static()
        self.collect_static_media()

    def print_title(self, title):
        print()
        print(title)
        print(len(title) * '-')

    def syncdb(self):
        self.print_title('Syncing in memory db')
        # make sure we have the db
        call_command('syncdb', load_initial_data=False, interactive=False)

    def create_sites(self):
        "Make sure we have the site framework setup correctly"

        Site.objects.all().delete()

        for idx, (domain, lang, title) in enumerate(settings.SITES, 1):
            site = Site(domain=domain, name=title, pk=idx)
            site.save()

    def read_resources(self):
        """Walk to readers to populate the db"""


# Path: statirator/core/utils.py
# def find_readers():
#     """Auto discover readers in installed apps.
# 
#     Each readers.py should have the READERS list with reader classes
#     """
# 
#     from django.conf import settings
#     from django.utils.importlib import import_module
#     from django.utils.module_loading import module_has_submodule
# 
#     readers = []
#     for app in settings.INSTALLED_APPS:
#         mod = import_module(app)
#         # Attempt to import the app's admin module.
#         try:
#             walk_mod = import_module('%s.readers' % app)
#             if hasattr(walk_mod, 'READERS'):
#                 readers.extend(walk_mod.READERS)
#             else:
#                 logging.warn(
#                     'readers found in app %s, but has no READERS attrib',
#                     app)
#         except:
#             # Decide whether to bubble up this error. If the app just
#             # doesn't have an readers module, we can ignore the error
#             # attempting to import it, otherwise we want it to bubble up.
#             if module_has_submodule(mod, 'readers'):
#                 raise
# 
#     return readers


# Path: statirator/core/management/commands/generate.py
import logging
from django.core.management import call_command
from django.core.management.base import BaseCommand
from statirator.core.utils import find_readers
        from django.conf import settings
        from django.contrib.sites.models import Site

    def handle(self, *args, **options):

        self.syncdb()
        self.create_sites()
        self.read_resources()
        self.gen_static()
        self.collect_static_media()

    def print_title(self, title):
        print()
        print(title)
        print(len(title) * '-')

    def syncdb(self):
        self.print_title('Syncing in memory db')
        # make sure we have the db
        call_command('syncdb', load_initial_data=False, interactive=False)

    def create_sites(self):
        "Make sure we have the site framework setup correctly"

        Site.objects.all().delete()

        for idx, (domain, lang, title) in enumerate(settings.SITES, 1):
            site = Site(domain=domain, name=title, pk=idx)
            site.save()

    def read_resources(self):
        """Walk to readers to populate the db"""


        readers = find_readers()