# Path: seeker/registry.py
# def register(doc_class, app_label=None):
# 
# Path: seeker/utils.py
# def progress(iterator, count=None, label='', size=40, chars='# ', output=sys.stdout, frequency=1.0):
#     """
#     An iterator wrapper that writes/updates a progress bar to an output stream (stdout by default).
#     Based on http://code.activestate.com/recipes/576986-progress-bar-for-console-programs-as-iterator/
#     """
#     assert len(chars) >= 2
#     if label:
#         label = force_text(label) + ' '
# 
#     try:
#         count = len(iterator)
#     except:
#         pass
# 
#     start = time.time()
# 
#     def show(i):
#         if count:
#             x = int(size * i / count)
#             bar = '[%s%s]' % (chars[0] * x, chars[1] * (size - x))
#             pct = int((100.0 * i) / count)
#             status = '%s/%s %s%%' % (i, count, pct)
#         else:
#             bar = ''
#             status = str(i)
#         e = time.time() - start
#         mins, s = divmod(int(e), 60)
#         h, m = divmod(mins, 60)
#         elapsed = '%d:%02d:%02d' % (h, m, s) if h else '%02d:%02d' % (m, s)
#         speed = '%.2f iters/sec' % (i / e) if e > 0 else ''
#         output.write('%s%s %s - %s, %s\r' % (label, bar, status, elapsed, speed))
#         output.flush()
# 
#     show(0)
#     last_update = 0.0
#     processed = 0
#     for item in iterator:
#         yield item
#         processed += 1
#         since = time.time() - last_update
#         if since >= frequency:
#             show(processed)
#             last_update = time.time()
#     show(processed)
# 
#     output.write('\n')
#     output.flush()


import argparse
from django.conf import settings
from django.core.management.base import BaseCommand
from elasticsearch.helpers import bulk
from elasticsearch_dsl.connections import connections
from seeker.registry import app_documents, documents
from seeker.utils import progress
        parser.add_argument('--drop',
            action='store_true',
            dest='drop',
            default=False,
            help='Drops the index before re-indexing'
        )
        parser.add_argument('--clear',
            action='store_true',
            dest='clear',
            default=False,
            help='Deletes all documents before re-indexing'
        )
        parser.add_argument('--no-data',
            action='store_false',
            dest='data',
            default=True,
            help='Only create the mappings, do not index any data'
        )
        parser.add_argument('--cursor',
            action='store_true',
            dest='cursor',
            default=False,
            help='Use a server-side cursor when fetching data for indexing')
        parser.add_argument('args', nargs=argparse.REMAINDER)

    def handle(self, *args, **options):
        doc_classes = []
        for label in args:
            doc_classes.extend(app_documents.get(label, []))
        if not args:

# Path: seeker/registry.py
# def register(doc_class, app_label=None):
# 
# Path: seeker/utils.py
# def progress(iterator, count=None, label='', size=40, chars='# ', output=sys.stdout, frequency=1.0):
#     """
#     An iterator wrapper that writes/updates a progress bar to an output stream (stdout by default).
#     Based on http://code.activestate.com/recipes/576986-progress-bar-for-console-programs-as-iterator/
#     """
#     assert len(chars) >= 2
#     if label:
#         label = force_text(label) + ' '
# 
#     try:
#         count = len(iterator)
#     except:
#         pass
# 
#     start = time.time()
# 
#     def show(i):
#         if count:
#             x = int(size * i / count)
#             bar = '[%s%s]' % (chars[0] * x, chars[1] * (size - x))
#             pct = int((100.0 * i) / count)
#             status = '%s/%s %s%%' % (i, count, pct)
#         else:
#             bar = ''
#             status = str(i)
#         e = time.time() - start
#         mins, s = divmod(int(e), 60)
#         h, m = divmod(mins, 60)
#         elapsed = '%d:%02d:%02d' % (h, m, s) if h else '%02d:%02d' % (m, s)
#         speed = '%.2f iters/sec' % (i / e) if e > 0 else ''
#         output.write('%s%s %s - %s, %s\r' % (label, bar, status, elapsed, speed))
#         output.flush()
# 
#     show(0)
#     last_update = 0.0
#     processed = 0
#     for item in iterator:
#         yield item
#         processed += 1
#         since = time.time() - last_update
#         if since >= frequency:
#             show(processed)
#             last_update = time.time()
#     show(processed)
# 
#     output.write('\n')
#     output.flush()


# Path: seeker/management/commands/reindex.py
import argparse
from django.conf import settings
from django.core.management.base import BaseCommand
from elasticsearch.helpers import bulk
from elasticsearch_dsl.connections import connections
from seeker.registry import app_documents, documents
from seeker.utils import progress

        parser.add_argument('--drop',
            action='store_true',
            dest='drop',
            default=False,
            help='Drops the index before re-indexing'
        )
        parser.add_argument('--clear',
            action='store_true',
            dest='clear',
            default=False,
            help='Deletes all documents before re-indexing'
        )
        parser.add_argument('--no-data',
            action='store_false',
            dest='data',
            default=True,
            help='Only create the mappings, do not index any data'
        )
        parser.add_argument('--cursor',
            action='store_true',
            dest='cursor',
            default=False,
            help='Use a server-side cursor when fetching data for indexing')
        parser.add_argument('args', nargs=argparse.REMAINDER)

    def handle(self, *args, **options):
        doc_classes = []
        for label in args:
            doc_classes.extend(app_documents.get(label, []))
        if not args:

            doc_classes.extend(documents)