<commit_before>__all__ = [
    'main',
]

from g1 import scripts
from g1.bases import argparses
from g1.bases import oses
from g1.bases.assertions import ASSERT

from . import bases
from . import pod_ops_dirs
from . import tokens
from . import xar_ops_dirs


@argparses.begin_parser(
    'init',
    **argparses.make_help_kwargs('initialize operations repository'),
)
@argparses.end
def cmd_init():
    oses.assert_root_privilege()
    scripts.assert_command_exist('ctr')
    scripts.assert_command_exist('systemctl')
    scripts.assert_command_exist('tar')
    bases.make_dir(bases.get_repo_path(), parents=True)
    pod_ops_dirs.init()
    xar_ops_dirs.init()
    tokens.init()
    return 0


@argparses.begin_parser(
    'cleanup',
    **argparses.make_help_kwargs('clean up operations repository'),
)
@argparses.end
def cmd_cleanup():
    oses.assert_root_privilege()
    ops_dirs = pod_ops_dirs.make_ops_dirs()
    ops_dirs.cleanup()
    xar_ops_dirs.make_ops_dirs().cleanup()
    tokens.make_tokens_database().cleanup(ops_dirs)
    return 0


@argparses.begin_parser(
    'repos',
    **argparses.make_help_kwargs('manage operations repository'),
)
@argparses.begin_subparsers_for_subcmds(dest='command')
@argparses.include(cmd_init)
@argparses.include(cmd_cleanup)
@argparses.end
@argparses.end
def main(args):
    if args.command == 'init':
        return cmd_init()
    elif args.command == 'cleanup':
        return cmd_cleanup()
    else:
        return ASSERT.unreachable('unknown command: {}', args.command)<commit_msg>Add bootstrap mode to ops repos init command<commit_after>__all__ = [
    'main',
]

from g1 import scripts
from g1.bases import argparses
from g1.bases import oses
from g1.bases.assertions import ASSERT

from . import bases
from . import pod_ops_dirs
from . import tokens
from . import xar_ops_dirs


@argparses.begin_parser(
    'init',
    **argparses.make_help_kwargs('initialize operations repository'),
)
@argparses.argument(
    '--bootstrap',
    action=argparses.StoreBoolAction,
    default=False,
    help='enable bootstrap mode (default: %(default_string)s)',
)
@argparses.end
def cmd_init(args):
    oses.assert_root_privilege()
    if not args.bootstrap:
        scripts.assert_command_exist('ctr')
    scripts.assert_command_exist('systemctl')
    scripts.assert_command_exist('tar')
    bases.make_dir(bases.get_repo_path(), parents=True)
    pod_ops_dirs.init()
    xar_ops_dirs.init()
    tokens.init()
    return 0


@argparses.begin_parser(
    'cleanup',
    **argparses.make_help_kwargs('clean up operations repository'),
)
@argparses.end
def cmd_cleanup():
    oses.assert_root_privilege()
    ops_dirs = pod_ops_dirs.make_ops_dirs()
    ops_dirs.cleanup()
    xar_ops_dirs.make_ops_dirs().cleanup()
    tokens.make_tokens_database().cleanup(ops_dirs)
    return 0


@argparses.begin_parser(
    'repos',
    **argparses.make_help_kwargs('manage operations repository'),
)
@argparses.begin_subparsers_for_subcmds(dest='command')
@argparses.include(cmd_init)
@argparses.include(cmd_cleanup)
@argparses.end
@argparses.end
def main(args):
    if args.command == 'init':
        return cmd_init(args)
    elif args.command == 'cleanup':
        return cmd_cleanup()
    else:
        return ASSERT.unreachable('unknown command: {}', args.command)
{'fraction_non_alphanumeric': 0.11586290567182286, 'fraction_numerical': 0.003639672429481347, 'mean_word_length': 4.4243421052631575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3868024', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1136, 'n_words': 204}