<commit_before>#! /usr/bin/env python

"""Admin scripting.
"""

import sys, inspect

import skytools

__all__ = ['AdminScript']

class AdminScript(skytools.DBScript):
    """Contains common admin script tools.

    Second argument (first is .ini file) is takes as command
    name.  If class method 'cmd_' + arg exists, it is called,
    otherwise error is given.
    """
    def __init__(self, service_name, args):
        """AdminScript init."""
        skytools.DBScript.__init__(self, service_name, args)
        if self.pidfile:
            self.pidfile = self.pidfile + ".admin"

        if len(self.args) < 2:
            self.log.error("need command")
            sys.exit(1)

    def work(self):
        """Non-looping work function, calls command function."""

        self.set_single_loop(1)

        cmd = self.args[1]
        cmdargs = self.args[2:]

        # find function
        fname = "cmd_" + cmd.replace('-', '_')
        if not hasattr(self, fname):
            self.log.error('bad subcommand, see --help for usage')
            sys.exit(1)
        fn = getattr(self, fname)<commit_msg>skytools.AdminScript: fix typo<commit_after>#! /usr/bin/env python

"""Admin scripting.
"""

import sys, inspect

import skytools

__all__ = ['AdminScript']

class AdminScript(skytools.DBScript):
    """Contains common admin script tools.

    Second argument (first is .ini file) is taken as command
    name.  If class method 'cmd_' + arg exists, it is called,
    otherwise error is given.
    """
    def __init__(self, service_name, args):
        """AdminScript init."""
        skytools.DBScript.__init__(self, service_name, args)
        if self.pidfile:
            self.pidfile = self.pidfile + ".admin"

        if len(self.args) < 2:
            self.log.error("need command")
            sys.exit(1)

    def work(self):
        """Non-looping work function, calls command function."""

        self.set_single_loop(1)

        cmd = self.args[1]
        cmdargs = self.args[2:]

        # find function
        fname = "cmd_" + cmd.replace('-', '_')
        if not hasattr(self, fname):
            self.log.error('bad subcommand, see --help for usage')
            sys.exit(1)
        fn = getattr(self, fname)
{'fraction_non_alphanumeric': 0.12718316166592028, 'fraction_numerical': 0.005373936408419167, 'mean_word_length': 2.304733727810651, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6487409', 'n_tokens_mistral': 691, 'n_tokens_neox': 675, 'n_words': 191}