INNER CODE UNIT · Python
capture
XRPLF/rippled · package/build_pkg.py:71
def capture(*command: object) -> str:
"""Run a command and return its stdout, stripped."""
argv = [str(part) for part in command]
# stderr is left alone so a failing command explains itself.
return subprocess.run(
argv, stdout=subprocess.PIPE, text=True, check=True
).stdout.strip()
def package_version(reported: str, channel: str) -> str:
"""Normalise a reported version into one the package formats accept.
- Release: unchanged (3.2.0 -> 3.2.0).
- bN/rcN pre-release: '-' becomes '~', to sort before the release
(3.2.0-b1 -> 3.2.0~b1).
- custom, private: any version, '-' inside the pre-release and build
metadata becomes '.' (3.4.0-custom-1 -> 3.4.0~custom.1).
- develop, UNRELEASED: 0.0.0-dev without build metadata, so builds sort by