def index(ticket):
    ticket['state'] = 'populating_index'
    ticket.save()
    # Make sure the parsed content is in the cache
    download_cache_directory = config['download_cache_directory']
    in_path = os.path.join(download_cache_directory, ticket['data_json'])
    if not os.path.exists(in_path):
        ticket.fail(in_path % 'Parsed content for %s not found')
        return
    data = open(in_path).read()
    if len(data) < 1:
        raise Exception('The parsed data in this ticket is empty.' )
    
    # TODO check for metadata section to update collection from this?
    owner = bibserver.dao.Account.get(ticket['owner'])
    importer = Importer(owner=owner)
    collection = {
        'label': ticket['collection'],
        'collection': util.slugify(ticket['collection']),
        'description': ticket.get('description'),
        'source': ticket['source_url'],
        'format': ticket['format'],
        'license': ticket.get('license', u"Not specified"),
    }
    collection, records = importer.upload(open(in_path), collection)
    ticket['state'] = 'done'
    ticket.save()
dataset/ETHPy150Open okfn/bibserver/bibserver/ingest.py/index/swapped operands of `%`