From 99de8c622b70d6e80fc0a85710f84345f3d0e4d8 Mon Sep 17 00:00:00 2001 From: Jordan Bonser Date: Tue, 6 May 2025 16:21:32 +0100 Subject: [PATCH] fix: make it possible to provide one path in `FileTransfer` Instead of repeating the same file name for both remote and local paths, a single path can be provided. --- bazel/labgrid/runner/runner.py | 6 ++++-- examples/custom-runners/archive-transfer/run.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bazel/labgrid/runner/runner.py b/bazel/labgrid/runner/runner.py index d42c658..0a15d9f 100644 --- a/bazel/labgrid/runner/runner.py +++ b/bazel/labgrid/runner/runner.py @@ -30,9 +30,11 @@ class FileTransfer: # FIXME: Decide whether or not to transfer runfiles implicitly instead of using a flag include_runfiles: bool - def __init__(self, remote: str, local: str, optional=False, include_runfiles=False): + def __init__( + self, remote: str, local: str = "", optional=False, include_runfiles=False + ): object.__setattr__(self, "remote", PurePath(remote)) - object.__setattr__(self, "local", Path(local)) + object.__setattr__(self, "local", Path(local if local else remote)) object.__setattr__(self, "optional", optional) object.__setattr__(self, "include_runfiles", include_runfiles) diff --git a/examples/custom-runners/archive-transfer/run.py b/examples/custom-runners/archive-transfer/run.py index 57db657..552256d 100644 --- a/examples/custom-runners/archive-transfer/run.py +++ b/examples/custom-runners/archive-transfer/run.py @@ -21,7 +21,7 @@ def main(): runfiles = Runfiles.Create() unzip = FileTransfer("unzip", runfiles.Rlocation("ape/ape/assimilate/unzip/unzip")) - archive = FileTransfer("archive.zip", "archive.zip") + archive = FileTransfer("archive.zip") with ZipFile(archive.local, "w") as zipfile: zipfile.write(args.program, arcname=args.program.name) -- GitLab