# Path: glottolog3/cli_util.py
# def get_releases(args):
#     cfg = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#     with args.pkg_dir.joinpath('releases.ini').open(encoding='utf-8') as f:
#         cfg.read_file(f)
#     return [Release.from_config(cfg, sec) for sec in cfg.sections()]
# 
# Path: glottolog3/static_archive.py
# T = Template("""\
# <!DOCTYPE html>
# <html lang="en">
#     <head>
#         <meta charset="utf-8">
#         <title>Glottolog ${version} - ${lang.text}</title>
#         <link href="/clld-static/css/bootstrap.min.css" rel="stylesheet">
#         <link href="/clld-static/css/bootstrap-responsive.min.css" rel="stylesheet">
#         <link href="/static/project.css" rel="stylesheet">
#     </head>
#     <body>
#         <div class="navbar navbar-static-top navbar-inverse">
#             <div class="navbar-inner">
#                 <div class="container-fluid">
#                     <a class="brand active" style="color: white !important" title="Glottolog ${version}">Glottolog ${version}</a>
#                 </div>
#             </div>
#         </div>
#         <div class="container-fluid">
#             <div class="row-fluid" style="margin-top: 10px;">
#                 <div class="span12">
#                     <div class="alert alert-error">
#                         You are browsing an outdated version of Glottolog. The current
#                         version can be found at
#                         <a href="https://glottolog.org">https://glottolog.org</a>.
#                     </div>
#                 </div>
#             </div>
#             <div class="row-fluid">
#                 <div class="span8">
#                     <h3>${lang.level.capitalize() + ': ' if lang.level else ''}<span class="level-${lang.level}">${lang.name}</span> [${lang.id}]</h3>
# 
#                     % if replacements:
#                     <div class="alert">
#                         This languoid is no longer part of the Glottolog classification.
#                         You may want to look at the following languoids for relevant information.
#                     </div>
#                     <ul>
#                         % for r in replacements:
#                         <li>${r}</li>
#                         % endfor
#                     </ul>
#                     % endif
# 
#                     % if clf:
#                     <h4>Classification</h4>
#                     ${clf|n}
#                     % endif
# 
#                     % if identifiers:
#                     <h4>Identifiers</h4>
#                     <ul>
#                         % for i in identifiers:
#                         <li>${i}</li>
#                         % endfor
#                     </ul>
#                     % endif
#                 </div>
#                 <div class="span4">
#                     <div class="well well-small">
#                         <h4>Other Versions</h4>
#                         <ul>
#                             % for v in versions:
#                             <li>${v|n}</li>
#                             % endfor
#                         </ul>
#                     </div>
#                 </div>
#             </div>
#         </div>
#     </body>
# </html>
# """)
# def wrap(agg, l):
# def link_list(l):
#     def __str__(self):
#     def text(self):
#     def link(self):
#     def cross_version_link(self):
#     def __str__(self):
# def dump(out, version, all_langs, identifiers):
# def aggregate(version, langs, identifiers):
# def create(versions, out=None):
# class L:
# class I:


import pathlib
from glottolog3.cli_util import get_releases
from glottolog3 import static_archive
"""
Create the static HTML archive to lookup old Glottolog releases
"""



def register(parser):  # pragma: no cover
    parser.add_argument(
        '--output',
        type=pathlib.Path,
        default=pathlib.Path('archive'),
    )


def run(args):  # pragma: no cover
    rels = get_releases(args)
    for rel in rels:
        rel.load_sql_dump(args.log)


# Path: glottolog3/cli_util.py
# def get_releases(args):
#     cfg = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
#     with args.pkg_dir.joinpath('releases.ini').open(encoding='utf-8') as f:
#         cfg.read_file(f)
#     return [Release.from_config(cfg, sec) for sec in cfg.sections()]
# 
# Path: glottolog3/static_archive.py
# T = Template("""\
# <!DOCTYPE html>
# <html lang="en">
#     <head>
#         <meta charset="utf-8">
#         <title>Glottolog ${version} - ${lang.text}</title>
#         <link href="/clld-static/css/bootstrap.min.css" rel="stylesheet">
#         <link href="/clld-static/css/bootstrap-responsive.min.css" rel="stylesheet">
#         <link href="/static/project.css" rel="stylesheet">
#     </head>
#     <body>
#         <div class="navbar navbar-static-top navbar-inverse">
#             <div class="navbar-inner">
#                 <div class="container-fluid">
#                     <a class="brand active" style="color: white !important" title="Glottolog ${version}">Glottolog ${version}</a>
#                 </div>
#             </div>
#         </div>
#         <div class="container-fluid">
#             <div class="row-fluid" style="margin-top: 10px;">
#                 <div class="span12">
#                     <div class="alert alert-error">
#                         You are browsing an outdated version of Glottolog. The current
#                         version can be found at
#                         <a href="https://glottolog.org">https://glottolog.org</a>.
#                     </div>
#                 </div>
#             </div>
#             <div class="row-fluid">
#                 <div class="span8">
#                     <h3>${lang.level.capitalize() + ': ' if lang.level else ''}<span class="level-${lang.level}">${lang.name}</span> [${lang.id}]</h3>
# 
#                     % if replacements:
#                     <div class="alert">
#                         This languoid is no longer part of the Glottolog classification.
#                         You may want to look at the following languoids for relevant information.
#                     </div>
#                     <ul>
#                         % for r in replacements:
#                         <li>${r}</li>
#                         % endfor
#                     </ul>
#                     % endif
# 
#                     % if clf:
#                     <h4>Classification</h4>
#                     ${clf|n}
#                     % endif
# 
#                     % if identifiers:
#                     <h4>Identifiers</h4>
#                     <ul>
#                         % for i in identifiers:
#                         <li>${i}</li>
#                         % endfor
#                     </ul>
#                     % endif
#                 </div>
#                 <div class="span4">
#                     <div class="well well-small">
#                         <h4>Other Versions</h4>
#                         <ul>
#                             % for v in versions:
#                             <li>${v|n}</li>
#                             % endfor
#                         </ul>
#                     </div>
#                 </div>
#             </div>
#         </div>
#     </body>
# </html>
# """)
# def wrap(agg, l):
# def link_list(l):
#     def __str__(self):
#     def text(self):
#     def link(self):
#     def cross_version_link(self):
#     def __str__(self):
# def dump(out, version, all_langs, identifiers):
# def aggregate(version, langs, identifiers):
# def create(versions, out=None):
# class L:
# class I:


# Path: glottolog3/commands/create_archive.py
import pathlib
from glottolog3.cli_util import get_releases
from glottolog3 import static_archive

"""
Create the static HTML archive to lookup old Glottolog releases
"""



def register(parser):  # pragma: no cover
    parser.add_argument(
        '--output',
        type=pathlib.Path,
        default=pathlib.Path('archive'),
    )


def run(args):  # pragma: no cover
    rels = get_releases(args)
    for rel in rels:
        rel.load_sql_dump(args.log)


    static_archive.create([rel.version for rel in rels], args.output)