aboutsummaryrefslogtreecommitdiff
path: root/rust_tools/rust_uprev.py
diff options
context:
space:
mode:
authorBob Haarman <inglorion@chromium.org>2024-01-24 17:47:10 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2024-01-25 00:04:06 +0000
commit9f1cac16955bb62fec78664999f55c22eeed499e (patch)
treeb3a356dce0f928514a501b4bbd658dcdffe6e1da /rust_tools/rust_uprev.py
parentda46b24088738464c772eb9b5c00ca80ac91bd1d (diff)
downloadtoolchain-utils-9f1cac16955bb62fec78664999f55c22eeed499e.tar.gz
rust_uprev: rewrite find_rust_versions() to use Path instead of os.*
This is a small refactor ahead of a change to the logic. The rewritten find_rust_versions() returns a list of tuples of (RustVersion, Path) instead of (RustVersion, str) as before, and updates the call sites and test to match. BUG=b:318424456 TEST=presubmit type checks and tests Change-Id: If5e26ee3c40265031c43fe68d921d43405a44e3a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/5233609 Reviewed-by: George Burgess <gbiv@chromium.org> Commit-Queue: Bob Haarman <inglorion@chromium.org> Tested-by: Bob Haarman <inglorion@chromium.org>
Diffstat (limited to 'rust_tools/rust_uprev.py')
-rwxr-xr-xrust_tools/rust_uprev.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/rust_tools/rust_uprev.py b/rust_tools/rust_uprev.py
index c0017186..bc64761c 100755
--- a/rust_tools/rust_uprev.py
+++ b/rust_tools/rust_uprev.py
@@ -401,13 +401,13 @@ def prepare_uprev(
return None
logging.info(
- "Template Rust version is %s (ebuild: %r)",
+ "Template Rust version is %s (ebuild: %s)",
template,
ebuild_path,
)
logging.info("rust-bootstrap version is %s", bootstrap_version)
- return PreparedUprev(template, Path(ebuild_path), bootstrap_version)
+ return PreparedUprev(template, ebuild_path, bootstrap_version)
def create_ebuild(
@@ -933,11 +933,11 @@ def create_rust_uprev(
)
-def find_rust_versions() -> List[Tuple[RustVersion, str]]:
+def find_rust_versions() -> List[Tuple[RustVersion, Path]]:
return [
- (RustVersion.parse_from_ebuild(x), os.path.join(RUST_PATH, x))
- for x in os.listdir(RUST_PATH)
- if x.endswith(".ebuild")
+ (RustVersion.parse_from_ebuild(ebuild), ebuild)
+ for ebuild in RUST_PATH.iterdir()
+ if ebuild.suffix == ".ebuild"
]
@@ -948,7 +948,7 @@ def find_oldest_rust_version() -> RustVersion:
return min(rust_versions)[0]
-def find_ebuild_for_rust_version(version: RustVersion) -> str:
+def find_ebuild_for_rust_version(version: RustVersion) -> Path:
rust_ebuilds = [
ebuild for x, ebuild in find_rust_versions() if x == version
]