Пример #1
0
def update_requirements(path: PathLike, pipfile: TOMLDocument) -> None:
    sources = list(filterfalse(is_default, pipfile.get("source", [])))
    packages = pipfile.get("packages", {})
    requirements = list(starmap(Requirement.from_pipfile, packages.items()))
    requirements.sort(key=requirement_sort_key)
    lines = [r.as_line(sources) + os.linesep for r in requirements]

    with open(path, "w") as fp:
        fp.writelines(lines)
Пример #2
0
def _verify_journal_paths(config: TOMLDocument) -> None:
    missing = []

    for journal_name, journal_config in config["pen"].get("journals",
                                                          {}).items():
        if "path" in journal_config:
            path = Path(journal_config["path"])
            if not path.exists():
                print_err(
                    f"Journal at {path} does not seem to exist anymore. If you"
                    f" moved it, use 'pen import <path>' so that Pen can find it"
                    f" again.")
                missing.append(journal_name)

    for journal in missing:
        del config.get("journals")[journal]