コード例 #1
0
ファイル: cli.py プロジェクト: score-framework/py.cli
def remove_(name):
    """
    Removes a configuration.
    """
    if re.match('^[a-zA-Z0-9_-]+$', name):
        if name == get_default():
            click.confirm(CONFIRM_DELETE % name, abort=True)
        remove(name)
        return
    # assume *name* is actually the path to a file
    file = name
    file = os.path.realpath(file)
    name = name_from_file(file)
    conf = get_file(name)
    try:
        parsedconf = parse(conf, recurse=False)
    except FileNotFoundError:
        pass
    else:
        configured = parsedconf['score.init']['based_on']
        if file != configured:
            click.confirm(CONFIRM_DELETE_WRONG_PATH.format(
                name=name,
                real=configured,
                provided=file,
            ), abort=True)
    remove(name)
コード例 #2
0
ファイル: conf.py プロジェクト: score-framework/py.cli
def get_origin(file):
    """
    Parses given configuration file and finds the file this one is
    :func:`based_on <score.init.parse_config_file>`.
    """
    parsedconf = parse(file, recurse=False)
    base = parsedconf['score.init']['based_on']
    if '\n' in base:
        base = base.split('\n')[-1]
    return base