# Path: kraken/lib/log.py
# def set_logger(logger=None, level=logging.ERROR):
# 
# Path: kraken/lib/progress.py
# class KrakenProgressBar(Progress):
#     """
#     Adaptation of the default rich progress bar to fit with kraken/ketos output.
#     """
#     def __init__(self, *args, **kwargs):
#         columns = [TextColumn("[progress.description]{task.description}"),
#                    BarColumn(),
#                    TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
#                    BatchesProcessedColumn(),
#                    TimeRemainingColumn(),
#                    TimeElapsedColumn()]
#         kwargs['refresh_per_second'] = 1
#         super().__init__(*columns, *args, **kwargs)
# 
# class KrakenDownloadProgressBar(Progress):
#     """
#     Adaptation of the default rich progress bar to fit with kraken/ketos download output.
#     """
#     def __init__(self, *args, **kwargs):
#         columns = [TextColumn("[progress.description]{task.description}"),
#                    BarColumn(),
#                    TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
#                    DownloadColumn(),
#                    TimeRemainingColumn(),
#                    TimeElapsedColumn()]
#         kwargs['refresh_per_second'] = 1
#         super().__init__(*columns, *args, **kwargs)


import os
import warnings
import logging
import pkg_resources
import click
    import json
    import json
        import torch
    import glob
    import uuid
    import tempfile
        import pyvips
from typing import Dict, Union, List, cast, Any, IO, Callable
from rich.traceback import install
from functools import partial
from PIL import Image
from kraken.lib import log
from kraken.lib.progress import KrakenProgressBar, KrakenDownloadProgressBar
        from kraken.lib.xml import parse_alto
        from kraken.lib.xml import parse_page
        from kraken.lib.xml import parse_xml
    from kraken import binarization
                from kraken import serialization
    from kraken import pageseg
    from kraken import blla
            from kraken import serialization
            from kraken.rpred import ocr_record
    from kraken import rpred
            from kraken import serialization
        from kraken.lib.vgsl import TorchVGSLModel
    from kraken.lib import models
        from collections import defaultdict
    from kraken import repo
    from kraken.lib.util import make_printable, is_printable
    from kraken import repo
    from kraken import repo
@click.argument('model_id')
def show(ctx, model_id):
    """
    Retrieves model metadata from the repository.
    """

    desc = repo.get_description(model_id)

    chars = []
    combining = []
    for char in sorted(desc['graphemes']):
        if not is_printable(char):
            combining.append(make_printable(char))
        else:
            chars.append(char)
    message(
        'name: {}\n\n{}\n\n{}\nscripts: {}\nalphabet: {} {}\naccuracy: {:.2f}%\nlicense: {}\nauthor(s): {}\ndate: {}'.format(
            model_id, desc['summary'], desc['description'], ' '.join(
                desc['script']), ''.join(chars), ', '.join(combining), desc['accuracy'], desc['license']['id'], '; '.join(
                x['name'] for x in desc['creators']), desc['publication_date']))
    ctx.exit(0)


@cli.command('list')
@click.pass_context
def list_models(ctx):
    """
    Lists models in the repository.
    """


# Path: kraken/lib/log.py
# def set_logger(logger=None, level=logging.ERROR):
# 
# Path: kraken/lib/progress.py
# class KrakenProgressBar(Progress):
#     """
#     Adaptation of the default rich progress bar to fit with kraken/ketos output.
#     """
#     def __init__(self, *args, **kwargs):
#         columns = [TextColumn("[progress.description]{task.description}"),
#                    BarColumn(),
#                    TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
#                    BatchesProcessedColumn(),
#                    TimeRemainingColumn(),
#                    TimeElapsedColumn()]
#         kwargs['refresh_per_second'] = 1
#         super().__init__(*columns, *args, **kwargs)
# 
# class KrakenDownloadProgressBar(Progress):
#     """
#     Adaptation of the default rich progress bar to fit with kraken/ketos download output.
#     """
#     def __init__(self, *args, **kwargs):
#         columns = [TextColumn("[progress.description]{task.description}"),
#                    BarColumn(),
#                    TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
#                    DownloadColumn(),
#                    TimeRemainingColumn(),
#                    TimeElapsedColumn()]
#         kwargs['refresh_per_second'] = 1
#         super().__init__(*columns, *args, **kwargs)


# Path: kraken/kraken.py
import os
import warnings
import logging
import pkg_resources
import click
    import json
    import json
        import torch
    import glob
    import uuid
    import tempfile
        import pyvips
from typing import Dict, Union, List, cast, Any, IO, Callable
from rich.traceback import install
from functools import partial
from PIL import Image
from kraken.lib import log
from kraken.lib.progress import KrakenProgressBar, KrakenDownloadProgressBar
        from kraken.lib.xml import parse_alto
        from kraken.lib.xml import parse_page
        from kraken.lib.xml import parse_xml
    from kraken import binarization
                from kraken import serialization
    from kraken import pageseg
    from kraken import blla
            from kraken import serialization
            from kraken.rpred import ocr_record
    from kraken import rpred
            from kraken import serialization
        from kraken.lib.vgsl import TorchVGSLModel
    from kraken.lib import models
        from collections import defaultdict
    from kraken import repo
    from kraken.lib.util import make_printable, is_printable
    from kraken import repo
    from kraken import repo

@click.argument('model_id')
def show(ctx, model_id):
    """
    Retrieves model metadata from the repository.
    """

    desc = repo.get_description(model_id)

    chars = []
    combining = []
    for char in sorted(desc['graphemes']):
        if not is_printable(char):
            combining.append(make_printable(char))
        else:
            chars.append(char)
    message(
        'name: {}\n\n{}\n\n{}\nscripts: {}\nalphabet: {} {}\naccuracy: {:.2f}%\nlicense: {}\nauthor(s): {}\ndate: {}'.format(
            model_id, desc['summary'], desc['description'], ' '.join(
                desc['script']), ''.join(chars), ', '.join(combining), desc['accuracy'], desc['license']['id'], '; '.join(
                x['name'] for x in desc['creators']), desc['publication_date']))
    ctx.exit(0)


@cli.command('list')
@click.pass_context
def list_models(ctx):
    """
    Lists models in the repository.
    """


    with KrakenProgressBar() as progress: