<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4 ft=python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import sys,os,getopt
from estimate import EstimateParser


class CliRunner(object):


    def __init__(self):
        self.verbose = False
        self.params  = {
            'show': 'all',
            'hours-only': False,
            'hours-done': 0
        }
        self.parser = EstimateParser()


    def usage(self, status = 0):
        """Print usage and exit"""
        filename = os.path.basename(sys.argv[0])
        if not filename:
            filename = 'estimate'
        usageMsg = 'Usage: ' + filename + ' <file>' + "\n"
        usageMsg += self.parser.usage()
        print(usageMsg)
        sys.exit(status)


    def run(self):
        try:
            opts, args = getopt.getopt(
                sys.argv[1:],
                "hdvH",
                ["help", "done", "verbose", "hours-only"]
            )
        except getopt.GetoptError as err:
            # print help information and exit:
            print(str(err)) # will print something like "option -a not recognized"
            self.usage(2)


        for o, a in opts:
            if o == "-v":
                self.verbose = True
            elif o in ("-h", "--help"):
                self.usage()
            elif o in ("-d", "--done"):
                self.params['show'] = 'done'
            elif o in ("-H", "--hours-only"):
                self.params['hours-only'] = True
            else:
                assert False, "unhandled option"
                self.usage()

        # @TODO:  <20-09-21, <NAME> <<EMAIL>>> :
        if args:
            file = args.pop()
            if file in ('-', '/dev/stdin'):
                self.parser.parseText(sys.stdin)
            else:
                with open(file, 'r') as f:
                    self.parser.parseText(f)
        else:
            self.parser.parseText(sys.stdin)


if __name__ == "__main__":<commit_msg>master<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ai ts=4 sts=4 et sw=4 ft=python
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import sys,os,getopt
from estimate import EstimateParser


class CliRunner(object):


    def __init__(self):
        self.verbose = False
        self.params  = {
            'show': 'all',
            'hours-only': False,
            'hours-done': 0
        }
        self.parser = EstimateParser()


    def usage(self, status = 0):
        """Print usage and exit"""
        filename = os.path.basename(sys.argv[0])
        if not filename:
            filename = 'estimate'
        usageMsg = 'Usage: ' + filename + ' <file>' + "\n"
        usageMsg += self.parser.usage()
        print(usageMsg)
        sys.exit(status)


    def run(self):
        try:
            opts, args = getopt.getopt(
                sys.argv[1:],
                "hdvH",
                ["help", "done", "verbose", "hours-only"]
            )
        except getopt.GetoptError as err:
            # print help information and exit:
            print(str(err)) # will print something like "option -a not recognized"
            self.usage(2)


        for o, a in opts:
            if o == "-v":
                self.verbose = True
            elif o in ("-h", "--help"):
                self.usage()
            elif o in ("-d", "--done"):
                self.params['show'] = 'done'
            elif o in ("-H", "--hours-only"):
                self.params['hours-only'] = True
            else:
                assert False, "unhandled option"
                self.usage()

        # @TODO:  <20-09-21, <NAME> <<EMAIL>>> :
        if args:
            file = args.pop()
            if file in ('-', '/dev/stdin'):
                self.parser.parseText(sys.stdin)
            else:
                with open(file, 'r') as f:
                    self.parser.parseText(f)
        else:
            self.parser.parseText(sys.stdin)


def main():
    cli = CliRunner()
    cli.run()

if __name__ == "__main__":
{'fraction_non_alphanumeric': 0.1387409200968523, 'fraction_numerical': 0.007263922518159807, 'mean_word_length': 1.4900542495479205, 'pattern_counts': {'":': 4, '<': 13, '<?xml version=': 0, '>': 13, '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': '4193062', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1210, 'n_words': 316}