<commit_before># Copyright (C) 2015 SEE AUTHORS FILE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
Command line interface for ocupado.
"""

import argparse
import platform

from ocupado import __version__, PluginManager
from ocupado.config.ini import INIConfig


def main():
    """
    Handler for the CLI interface.
    """
    if int(platform.python_version_tuple()[0]) == 2:
        parser = argparse.ArgumentParser(version=__version__)
    else:
        parser = argparse.ArgumentParser()

    parser.add_argument(
        'config', metavar='CONFIG', type=str,
        nargs=1, help='Path to the config file.')
    parser.add_argument(
        '-V', '--verbose', action='store_true',
        help='Enables verbose output.')

    args = parser.parse_args()

    conf = INIConfig(args.config[0])

    # Load plugins for use
    plugin_manager = PluginManager()
    plugin_manager.set_up_authoritative(conf.authoritative)
    plugin_manager.set_up_outputs(conf.outputs)
    plugin_manager.load_dict(conf.plugins)

    if args.verbose:
        print('- Plugins loaded: %s' % plugin_manager.plugins.keys())
    plugin_manager.set_up_plugins(conf.plugins)
    if args.verbose:
        print('- Plugins initialized: %s' % plugin_manager.instances.keys())

    unmatched = []
    # Run through all the plugin instances looking for users
    for name in plugin_manager.instances:
        if args.verbose:
            print('- Getting users for plugin %s' % name)
        for username in plugin_manager.instances[name].get_all_usernames():
            exists, details = plugin_manager.authoritative_instance.exists(
                username)
            if exists is False:
                if args.verbose:
                    print(
                        '- Could not find user %s in the authoritative '
                        'plugin' % username)<commit_msg>auth: Authenticate before calling a plugin.<commit_after># Copyright (C) 2015 SEE AUTHORS FILE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
Command line interface for ocupado.
"""

import argparse
import platform

from ocupado import __version__, PluginManager
from ocupado.config.ini import INIConfig


def main():
    """
    Handler for the CLI interface.
    """
    if int(platform.python_version_tuple()[0]) == 2:
        parser = argparse.ArgumentParser(version=__version__)
    else:
        parser = argparse.ArgumentParser()

    parser.add_argument(
        'config', metavar='CONFIG', type=str,
        nargs=1, help='Path to the config file.')
    parser.add_argument(
        '-V', '--verbose', action='store_true',
        help='Enables verbose output.')

    args = parser.parse_args()

    conf = INIConfig(args.config[0])

    # Load plugins for use
    plugin_manager = PluginManager()
    plugin_manager.set_up_authoritative(conf.authoritative)
    plugin_manager.set_up_outputs(conf.outputs)
    plugin_manager.load_dict(conf.plugins)

    if args.verbose:
        print('- Plugins loaded: %s' % plugin_manager.plugins.keys())
    plugin_manager.set_up_plugins(conf.plugins)
    if args.verbose:
        print('- Plugins initialized: %s' % plugin_manager.instances.keys())

    unmatched = []
    # Run through all the plugin instances looking for users
    for name in plugin_manager.instances:
        if args.verbose:
            print('- Authenticating for plugin %s' % name)
        plugin_manager.instances[name].authenticate()
        if args.verbose:
            print('- Getting users for plugin %s' % name)
        for username in plugin_manager.instances[name].get_all_usernames():
            exists, details = plugin_manager.authoritative_instance.exists(
                username)
            if exists is False:
                if args.verbose:
                    print(
                        '- Could not find user %s in the authoritative '
                        'plugin' % username)
{'fraction_non_alphanumeric': 0.0885803676183027, 'fraction_numerical': 0.0035197497066875244, 'mean_word_length': 2.9135424636572305, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1259802', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1352, 'n_words': 483}