Exemple #1
0
def main(args=None):
    """Generate config YAML for Khaleesi

    :param args: list of arguments to replace sys.argv[1:]
    :return: standard return-code - 0 for success, 1 for failure
    """
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, argv=args, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']

    config_dir = get_config_dir(args)

    logging.debug("config_dir = %s" % config_dir)

    try:
        if cmd == 'help':
            return usage(config_dir)

        if cmd == 'generate':
            return settings.Generator(config_dir, args['<args>']).run()
    except settings.ArgsConflictError as exc:
        logging.error(str(exc))
        return 1

    return 0
Exemple #2
0
def main(args=None):
    """Generate config YAML for Khaleesi

    :param args: list of arguments to replace sys.argv[1:]
    :return: standard return-code - 0 for success, 1 for failure
    """
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, argv=args, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']

    config_dir = get_config_dir(args)
    get_base_dir()

    logging.debug("config_dir = %s" % config_dir)

    try:
        if cmd == 'help':
            return usage(config_dir)

        if cmd == 'generate':
            return settings.Generator(config_dir, args['<args>']).run()
    except settings.ArgsConflictError as exc:
        logging.error(str(exc))
        return 1

    return 0
Exemple #3
0
def main(args=sys.argv):
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']
    config_dir = args['--config-dir']
    if cmd == 'help':
        return usage(config_dir)

    if cmd == 'generate':
        return generate(config_dir, args['<args>'])

    return 0
Exemple #4
0
def main(args=sys.argv):
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']
    config_dir = args['--config-dir']
    if cmd == 'help':
        return usage(config_dir)

    if cmd == 'generate':
        return generate(config_dir, args['<args>'])

    return 0
Exemple #5
0
def main(args=None):
    args = args or sys.argv
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']
    from os.path import abspath
    config_dir = abspath(args['--config-dir'])
    if cmd == 'help':
        return usage(config_dir)

    if cmd == 'generate':
        return settings.Generator(config_dir, args['<args>']).run()

    return 0
Exemple #6
0
def main(args=None):
    args = args or sys.argv
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, options_first=True)
    _setup_logging(args['--log-level'])

    cmd = args['<command>']
    from os.path import abspath
    config_dir = abspath(args['--config-dir'])
    if cmd == 'help':
        return usage(config_dir)

    if cmd == 'generate':
        return settings.Generator(config_dir, args['<args>']).run()

    return 0
Exemple #7
0
def main(args=None):
    args = args or sys.argv
    yaml_utils.register()

    # given a directory tree can you generate docstring?
    args = docopt(__doc__, options_first=True)
    _setup_logging(args["--log-level"])

    cmd = args["<command>"]
    from os.path import abspath

    config_dir = abspath(args["--config-dir"])

    try:
        if cmd == "help":
            return usage(config_dir)

        if cmd == "generate":
            return settings.Generator(config_dir, args["<args>"]).run()
    except settings.ArgsConflictError as exc:
        logging.error(str(exc))
        return 1

    return 0
Exemple #8
0
import logging
from ksgen import yaml_utils
from os.path import dirname, realpath

TEST_DIR = dirname(realpath(__file__))
yaml_utils.register()


def print_yaml(msg, x):
    logging.info(yaml_utils.to_yaml(msg, x))


def verify_key_val(cfg, source_dict, key):
    """ Assuming cfg is created from source_dict, returns true if
    cfg[key] == source_dict[key]"""

    keys = key.split('.')

    leaf_cfg = cfg
    leaf_dict = source_dict
    for k in keys:
        leaf_cfg = leaf_cfg[k]
        leaf_dict = leaf_dict[k]
    return leaf_cfg == leaf_dict


def _enable_logging(level=None):
    level = level or "debug"

    from ksgen import log_color
    log_color.enable()
Exemple #9
0
from ksgen import yaml_utils
from os.path import dirname, realpath

TEST_DIR = dirname(realpath(__file__))
yaml_utils.register()


def print_yaml(msg, x):
    import logging
    logging.info(yaml_utils.to_yaml(msg, x))


def verify_key_val(cfg, source_dict, key):
    """ Assuming cfg is created from source_dict, returns true if
    cfg[key] == source_dict[key]"""

    keys = key.split('.')

    leaf_cfg = cfg
    leaf_dict = source_dict
    for k in keys:
        leaf_cfg = leaf_cfg[k]
        leaf_dict = leaf_dict[k]
    return leaf_cfg == leaf_dict