<commit_before>import optparse
import sys

import config
from paletti import get_palette, print_palette, create_palette


class PalettiApp(object):
    def __init__(self):
        self.parser = self.get_parser()

    def get_parser(self):
        usage = 'python %prog [options]'
        parser = optparse.OptionParser(usage=usage)

        parser.add_option(
            '-k',
            '--num-colors',
            action='store',
            dest='num_colors',
            type='int',
            default=config.NUM_COLORS,
            help='The maximum number of colors to output per palette [{}]'
                 .format(config.NUM_COLORS))
        parser.add_option(
            '-o',
            '--output',
            action='store_true',
            dest='save_palette',
            default=False,
            help="Plot and store the palette in an image file")
        parser.add_option(
            '-m',
            '--method',
            action='store',
            dest='method',
            default=config.METHOD,
            help="The method used to extract the color palette [{}]".format(
                config.METHOD))

        return parser

    def run(self):
        argv = sys.argv[1:]
        options, args = self.parser.parse_args(argv)
        if args:
            for fname in args:
                try:
                    palette = get_palette(
                        fname, k=options.num_colors, method=options.method)
                except Exception as e:
                    print >> sys.stderr, fname, e
                    continue
                print_palette(fname, palette, method=options.method)<commit_msg>Options parser text update.<commit_after>import optparse
import sys

import config
from paletti import get_palette, print_palette, create_palette


class PalettiApp(object):
    def __init__(self):
        self.parser = self.get_parser()

    def get_parser(self):
        usage = 'python %prog [options] IMAGE_FILE'
        parser = optparse.OptionParser(usage=usage)

        parser.add_option(
            '-k',
            '--num-colors',
            action='store',
            dest='num_colors',
            type='int',
            default=config.NUM_COLORS,
            help='The maximum number of colors per palette [{}].'
                 .format(config.NUM_COLORS))
        parser.add_option(
            '-o',
            '--output',
            action='store_true',
            dest='save_palette',
            default=False,
            help="Plot and store the palette in an image file.")
        parser.add_option(
            '-m',
            '--method',
            action='store',
            dest='method',
            default=config.METHOD,
            help="The method used to extract the color palette. Can be 'k-"
                 "means', 'colorific', 'pil', or 'pictaculous'. Default is 'k-"
                 "means'.".format(config.METHOD))

        return parser

    def run(self):
        argv = sys.argv[1:]
        options, args = self.parser.parse_args(argv)
        if args:
            for fname in args:
                try:
                    palette = get_palette(
                        fname, k=options.num_colors, method=options.method)
                except Exception as e:
                    print >> sys.stderr, fname, e
                    continue
                print_palette(fname, palette, method=options.method)
{'fraction_non_alphanumeric': 0.10327677004095963, 'fraction_numerical': 0.0005851375073142189, 'mean_word_length': 1.5648912228057015, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5458723', 'n_tokens_mistral': 929, 'n_tokens_neox': 880, 'n_words': 225}