INNER CODE UNIT · Python

read_pubspec_version

fluxerapp/flutter_client · .github/scripts/app_version.py:52

def read_pubspec_version(path: Path = PUBSPEC_PATH) -> AppVersion:
    for raw_line in path.read_text(encoding="utf-8").splitlines():
        match = VERSION_LINE_PATTERN.match(raw_line)
        if match is not None:
            return AppVersion(
                year=int(match.group(2)),
                month=int(match.group(3)),
                public_release=int(match.group(4)),
                build=match.group(5),
            )
    raise ValueError(f"Could not find version in {path}")


def write_pubspec_version(version: AppVersion, path: Path = PUBSPEC_PATH) -> None:
    lines = path.read_text(encoding="utf-8").splitlines(keepends=True)
    replaced = False
    for index, raw_line in enumerate(lines):
        stripped = raw_line.rstrip("\r\n")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…