Exemple #1
0
def get_global_funcnames(pyfile: fsoopify.FileInfo) -> list:
    'get a list of global funcnames (use for entry_points.console_scripts).'
    assert pyfile.is_file()

    import ast

    funcnames = []
    mod = ast.parse(pyfile.read_text())
    for stmt in mod.body:
        if isinstance(stmt, ast.FunctionDef):
            funcnames.append(stmt.name)
    return funcnames
Exemple #2
0
def configure_gitignore(proj_info: ProjectInfo):
    logger = get_logger()
    gitignore = FileInfo(proj_info.root_dir)

    if not gitignore.is_exists():
        logger.info(f'{lightgreen(gitignore)} does not exists')
        return

    gitignore_text = gitignore.read_text().splitlines()
    gitignore_set = set(gitignore_text)
    appends = []
    for line in GIT_IGNORES_VALUES:
        if line not in gitignore_set:
            appends.append(line)

    if appends:
        if GIT_IGNORES_HEADER in gitignore_set:
            raise NotImplementedError
        else:
            gitignore_text.append('')
            gitignore_text.append(GIT_IGNORES_HEADER)
            gitignore_text.extend(appends)

        gitignore.write_text('\n'.join(gitignore_text), append=False)