Пример #1
0
from os.path import dirname, join, realpath, sep, abspath

import baker
from voodoo import render_skeleton

from clay.main import Clay, DEFAULT_HOST, DEFAULT_PORT

SKELETON = join(dirname(realpath(__file__)), 'skeleton')

SKELETON_HELP = """
    Done!
    Now go to %s, and do `clay run` to start the server.
"""

manager = baker.Baker()


@manager.command
def new(path='.'):
    """Creates a new project
    """
    path = abspath(path.rstrip(sep))
    render_skeleton(SKELETON, path, include_this=['.gitignore'])
    print(SKELETON_HELP % (path, ))


@manager.command
def run(host=DEFAULT_HOST, port=DEFAULT_PORT, path='.'):
    """Run the development server
    """
Пример #2
0
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}'
BAKER = baker.Baker()


def log(msg, *args, **kwargs):
    '''Log a message, passing `*args` and `**kwargs` to `.format()`.'''
    sys.stdout.write(msg.format(*args, **kwargs) + '\n')


def log_list(lst):
    '''Log an entire list, line by line.'''
    for line in lst:
        log(line)


def walk_paths(paths):
    '''Recursively iter filenames starting from the given *paths*.