Esempio n. 1
0
'''In this module the CLI interface is created.'''

import sys
import inspect
from contextlib import contextmanager
from mando import Program

import radon.complexity as cc_mod
from radon.cli.colors import BRIGHT, RED, RESET
from radon.cli.harvest import CCHarvester, RawHarvester, MIHarvester, HCHarvester

program = Program(version=sys.modules['radon'].__version__)


@program.command
@program.arg('paths', nargs='+')
def cc(
    paths,
    min='A',
    max='F',
    show_complexity=False,
    average=False,
    exclude=None,
    ignore=None,
    order='SCORE',
    json=False,
    no_assert=False,
    show_closures=False,
    total_average=False,
    xml=False,
    codeclimate=False,
Esempio n. 2
0
import pytest
from mando import Program

from . import capture

program = Program('example.py', '1.0.10')


@program.command(doctype='google')
def simple_google_docstring(arg1, arg2="string"):
    '''One line summary.

    Extended description.

    Args:
      arg1(int): Description of `arg1`
      arg2(str): Description of `arg2`
    Returns:
      str: Description of return value.
    '''
    return int(arg1) * arg2


GENERIC_COMMAND_CASES = [
    ('simple_google_docstring 2 --arg2=test', 'testtest'),
]


@pytest.mark.parametrize('args,result', GENERIC_COMMAND_CASES)
def test_generic_command(args, result):
    args = args.split()
Esempio n. 3
0
from contextlib import contextmanager
import pytest
from mando import Program


program = Program('example.py', '1.0.10')


def NoopCompleter(prefix, **kwd):
    return []


program.option(
    "-f", "--foo", dest='foo', default='bar', completer=NoopCompleter,
    help="Real programmers don't comment their code. \
          If it was hard to write, it should be hard to read."
)

program.add_subprog('sub')
program.sub.option(
    "-i", "--inc", dest='inc', type=int, default=0,
    help="Some help text."
)


@program.command
def getopt(name):
    '''
        :param name: Name of option to return.
    '''
    # also allows for: Script.foo
Esempio n. 4
0
__version__ = '0.5.1'

RANKS_COLORS = {
    'A': GREEN,
    'B': GREEN,
    'C': YELLOW,
    'D': YELLOW,
    'E': RED,
    'F': RED
}

LETTERS_COLORS = {'F': MAGENTA, 'C': CYAN, 'M': WHITE}

MI_RANKS = {'A': GREEN, 'B': YELLOW, 'C': RED}
TEMPLATE = '{0}{1} {reset}{2}:{3} {4} - {5}{6}{reset}'
program = Program(version=__version__)


def log(msg, *args, **kwargs):
    '''Log a message, passing `*args` to `.format()`.

    `indent`, if present as a keyword argument, specifies the indent level, so
    that `indent=0` will log normally, `indent=1` will indent the message by 4
    spaces, &c..
    `noformat`, if present and True, will cause the message not to be formatted
    in any way.'''
    indent = 4 * kwargs.get('indent', 0)
    m = msg if kwargs.get('noformat', False) else msg.format(*args)
    sys.stdout.write(' ' * indent + m + '\n')

Esempio n. 5
0
import pytest
from mando import Program


program = Program('example.py', '1.0.10')


def NoopCompleter(prefix, **kwd):
    return []


program.option(
    "-f", "--foo", dest='foo', default='bar', completer=NoopCompleter,
    help="Real programmers don't comment their code. \
          If it was hard to write, it should be hard to read."
)

program.add_subprog('sub')
program.sub.option(
    "-i", "--inc", dest='inc', type=int, default=0,
    help="Some help text."
)


@program.command
def getopt(name):
    '''
        :param name: Name of option to return.
    '''
    # also allows for: Script.foo
    return getattr(program, name)
Esempio n. 6
0
# -*- coding: utf-8 -*-

import os.path
import sys
import warnings

from mando import Program
from mando.rst_text_formatter import RSTHelpFormatter
from tstoolbox import tsutils

from . import disaggregate, pet

warnings.filterwarnings("ignore")

program = Program("mettoolbox", "0.0")

program.add_subprog("disaggregate")
program.add_subprog("pet")

_LOCAL_DOCSTRINGS = tsutils.docstrings
_LOCAL_DOCSTRINGS["latitude"] = """latitude:
        The latitude of the location expressed in decimal degrees.  The
        southern hemisphere is expressed as a negative value."""
_LOCAL_DOCSTRINGS["longitude"] = """longitude:
        The longitude of the location expressed in decimal degrees.  The
        western hemisphere is expressed as a negative value."""
_LOCAL_DOCSTRINGS["vardesc"] = """If int or float use the value.  If
        array_like, then convert to numpy array.  If string, then split
        on commas and use as array_like.

        If None (the default) then `input_ts` and `columns` must be set."""