print asset_data_str

now = datetime.datetime.utcnow().replace(tzinfo=pytz.utc)

for section in entry_data.sections:
    if section.get('public', True) is False:
        continue
    if section.get('public-after', now) > now:
        continue
    if len(section['entries']) == 0 and not create_empty_sections:
        continue
    if len(args.only_sections) and section['key'] not in args.only_sections.split(","):
        continue
    section_description = generate_section_description(
        section, args.pms_vote_template)
    print_section(entry_data.year, section, section_description)

    sorted_entries = asmmetadata.sort_entries(section['entries'])

    # Music files have all the same thumbnail.
    if 'music' in section['name'].lower():
        for entry in sorted_entries:
            entry['use-parent-thumbnail'] = True

    entry_position_descriptor = entry_position_description_factory(
        args.pms_vote_template)
    for entry in sorted_entries:
        print_entry(entry_data.year, entry, entry_position_descriptor)

print """</import>"""
    out_filename_png = os.path.join(fileroot, "thumbnails/small/%s.png" % outfile_base)
    out_filename_jpeg = os.path.join(fileroot, "thumbnails/small/%s.jpeg" % outfile_base)
    thumbnail_paths = []
    for entry in entries:
        thumbnail_base = asmmetadata.select_thumbnail_base(entry)
        thumbnail_paths.append(os.path.join(fileroot, thumbnail_base + '.png'))
    print 'mkdir -p "%s"' % os.path.join(fileroot, "thumbnails/merged/")
    print 'convert "%s" +append "%s"' % ('" "'.join(thumbnail_paths), out_filename_png)
    print 'convert "%s" +append "%s"' % ('" "'.join(thumbnail_paths), out_filename_jpeg)
    print 'optipng -o7 "%s"' % out_filename_png
    print 'jpegoptim --strip-all "%s"' % out_filename_jpeg

# def create_merged_entry_groups(entries

for section in entry_data.sections:
    if 'music' in section['name'].lower():
        continue
    merge_entries = []
    start = 1
    for entry in asmmetadata.sort_entries(section['entries']):
        if len(merge_entries) == merge_limit:
            create_merged_image(fileroot, start, merge_entries)
            start += len(merge_entries)
            item_count = 0
            merge_entries = []
        thumbnail = asmmetadata.select_thumbnail_base(entry)
        if thumbnail is not None:
            merge_entries.append(entry)
    if len(merge_entries) > 0:
        create_merged_image(fileroot, start, merge_entries)