# exts = exts[:10]

files_count = sum(len(ext['files']) for ext in exts)

exts_groups = list(split_list(exts, 1000))

DEST = '../site/chrome-extensions-archive/'

TEST_ONE = False

if not TEST_ONE:
    for i, group in tqdm(enumerate(exts_groups)):
        page = i + 1
        name = ('pages/' + str(page) if page > 1 else 'index') + '.html'
        result = templates.list(exts=group,
            exts_count=len(exts),
            files_count=files_count,
            pages=len(exts_groups),
            total_size=total_size,
            name=name,
            page=page)
        open(DEST + name, 'w').write(result)

files = glob.glob(DEST + 'ext/*')
for f in files:
    os.remove(f)

for ext in tqdm(exts):
    result = templates.ext(ext=ext)
    open(DEST + 'ext/' + ext['ext_id'] + '.html', 'w').write(result)
# exts = exts[:10]

files_count = sum(len(ext['files']) for ext in exts)

exts_groups = list(split_list(exts, 1000))

DEST = '../site/chrome-extensions-archive/'

TEST_ONE = False

if not TEST_ONE:
    for i, group in tqdm(enumerate(exts_groups)):
        page = i + 1
        name = ('pages/' + str(page) if page > 1 else 'index') + '.html'
        result = templates.list(exts=group,
            exts_count=len(exts),
            files_count=files_count,
            pages=len(exts_groups),
            total_size=total_size,
            name=name,
            page=page)
        open(DEST + name, 'w').write(result)

files = glob.glob(DEST + 'ext/*')
for f in files:
    os.remove(f)

for ext in tqdm(exts):
    result = templates.ext(ext=ext)
    open(DEST + 'ext/' + ext['ext_id'] + '.html', 'w').write(result)