def get_theme_archive(themeId):
    try:
        theme = Theme.objects.get(id=themeId)
    except __HOLE__:
        return None, None

    theme.downloads = int(theme.downloads) + 1
    theme.save()

    if theme.archive:
        data = theme.archive.read()
    else:
        data = serialize_to_idea_lines(deserialize_from_lines(theme.elements.split(u'\n')), theme.name)
        data = u'\n'.join(data).encode('utf_8')

    options = u"""<?xml version="1.0" encoding="UTF-8"?>
    <application>
      <component name="EditorColorsManagerImpl">
        <option name="USE_ONLY_MONOSPACED_FONTS" value="true" />
        <global_color_scheme name="%s" />
      </component>
    </application>
    """ % theme.name

    resultStream = StringIO()
    archive = ZipFile(resultStream, 'w')

    archive.writestr('IntelliJ IDEA Global Settings', '')
    archive.writestr('options/colors.scheme.xml', options.encode('utf_8'))

    archive.writestr('colors/%s.xml' % theme.name, data)

    archive.close()
    return theme.name.encode('utf_8'), resultStream.getvalue()
dataset/ETHPy150Open y-a-r-g/idea-color-themes/backend/logic/themes/themes.py/get_theme_archive