<commit_before>
import argparse
import blessings
import logging
import os

import mesos.cli
from . import config
from .master import current as master
from . import exceptions
from . import log

def init(parser=None):
    cfg = config.Config()
    args = parser.parse_args() if parser else None

    logging.basicConfig(
        level=getattr(logging, cfg.log_level.upper()),
        filename=cfg.log_file
    )

    return (cfg, args)

def parser(**kwargs):
    p = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        **kwargs
    )

    p.add_argument(
        "-v", "--version",
        action="version", version="%(prog)s {0}".format(mesos.cli.__version__)
    )
    return p

def header(name):
    term = blessings.Terminal()
    print "==>" + term.red + str(name) + term.white + "<=="

def cmds(short=False):
    def fltr(cmd):
        if not cmd.startswith("mesos-"):
            return False
        if cmd.endswith(".sh"):
            return False
        return True

    cmds = []
    for path in os.environ.get("PATH").split(os.pathsep):
        try:
            cmds += filter(fltr, os.listdir(path))
        except OSError:
            pass

    if short:
        cmds = [x.split("-", 1)[-1] for x in cmds]

    return cmds

def task_completer(prefix, parsed_args, **kwargs):
    return [x.id for x in master.tasks(prefix)]<commit_msg>don't relist commands if they're on the path more than once<commit_after>
import argparse
import blessings
import logging
import os

import mesos.cli
from . import config
from .master import current as master
from . import exceptions
from . import log

def init(parser=None):
    cfg = config.Config()
    args = parser.parse_args() if parser else None

    logging.basicConfig(
        level=getattr(logging, cfg.log_level.upper()),
        filename=cfg.log_file
    )

    return (cfg, args)

def parser(**kwargs):
    p = argparse.ArgumentParser(
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
        **kwargs
    )

    p.add_argument(
        "-v", "--version",
        action="version", version="%(prog)s {0}".format(mesos.cli.__version__)
    )
    return p

def header(name):
    term = blessings.Terminal()
    print "==>" + term.red + str(name) + term.white + "<=="

def cmds(short=False):
    def fltr(cmd):
        if not cmd.startswith("mesos-"):
            return False
        if cmd.endswith(".sh"):
            return False
        return True

    cmds = set([])
    for path in os.environ.get("PATH").split(os.pathsep):
        try:
            cmds = cmds.union(filter(fltr, os.listdir(path)))
        except OSError:
            pass

    if short:
        cmds = [x.split("-", 1)[-1] for x in cmds]

    return cmds

def task_completer(prefix, parsed_args, **kwargs):
    return [x.id for x in master.tasks(prefix)]
{'fraction_non_alphanumeric': 0.12631578947368421, 'fraction_numerical': 0.002105263157894737, 'mean_word_length': 2.5372208436724564, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4285844', 'n_tokens_mistral': 911, 'n_tokens_neox': 880, 'n_words': 236}