Exemple #1
0
def process_license(name, data):
    ORIGIN_NAME = name
    log.info('license', color.cyan(ORIGIN_NAME))
    # reset the name
    name = name.lower()
    if name == 'bsd':
        name = 'bsd3'
    elif name == 'gpl':
        name = 'gpl3'

    if 'organization' not in data:
        username = os.environ.get('USER') or os.environ.get('USERNAME')
        user = data.get('user', username)
        if user:
            data['organization'] = user

    if 'year' not in data:
        data['year'] = str(datetime.datetime.utcnow().year)

    if 'project' not in data and 'name' in data:
        data['project'] = data['name']

    content = license.parse(name, **data)
    if not content:
        return log.warn('license not found', color.cyan(ORIGIN_NAME))
    f = open('LICENSE', 'w')
    f.write(content)
    f.close()
Exemple #2
0
def process_rename(renames, data):
    if not renames:
        return

    c = color.cyan
    for k, v in renames.items():
        t = Template(v)
        v = t.render(**data)
        if '{{' in v:
            log.error('error renaming', c(k), 'to', c(v))
        elif os.path.exists(v):
            log.warn('rewriting', c(v))
            shutil.rmtree(v)
            shutil.move(k, v)
        else:
            log.info('renaming', c(k), 'to', c(v))
            shutil.move(k, v)
def test_log():
    log.info('hello test')

    log.start('start a level')
    log.info('info in a level')
    log.warn('warn in a level')
    log.error('error in a level')
    log.debug('debug info')
    log.verbose.info('will not print this')
    log.config(verbose=True)
    log.verbose.info('will print this')

    log.start('start second level')
    log.verbose.debug('hello debug')
    log.end()
    log.config(quiet=True)
    log.info('will not print')
    log.end('close a level')
    log.message('foo', 'bar')
Exemple #4
0
from terminal.builtin import log

log.start('terminal build')
log.info('build foo')
log.debug('read file foo.py')
log.warn('not found foo.py')
log.info('build bar')
log.debug('read file bar.py')
log.start('sub read')
log.info('parse bar.py')
log.info('bar is python')
log.end('parse end')
log.error('syntax error')
log.end('end build')
Exemple #5
0
from terminal.builtin import log

log.start("terminal build")
log.info("build foo")
log.debug("read file foo.py")
log.warn("not found foo.py")
log.info("build bar")
log.debug("read file bar.py")
log.start("sub read")
log.info("parse bar.py")
log.info("bar is python")
log.end("parse end")
log.error("syntax error")
log.end("end build")