On Mon, Jun 03, 2019 at 01:52:05PM +0200, Jan Tluka wrote:
Fri, May 31, 2019 at 11:28:03AM CEST, olichtne(a)redhat.com wrote:
>From: Ondrej Lichtner <olichtne(a)redhat.com>
>
>Moving the device related rpc_calls from the RemoteDevice class into the
>Machine class which already provides abstractions for all the other rpc
>calls that we do. It's also a good place to organize the creation of
>Device related event results and add them to the current run log of the
>recipe.
>
>Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
>---
> lnst/Controller/Machine.py | 56 ++++++++++++++++++++++++++++++++++--
> lnst/Devices/RemoteDevice.py | 19 ++++++------
> 2 files changed, 61 insertions(+), 14 deletions(-)
>
>diff --git a/lnst/Controller/Machine.py b/lnst/Controller/Machine.py
>index a74b5a9..5fd5c88 100644
>--- a/lnst/Controller/Machine.py
>+++ b/lnst/Controller/Machine.py
>@@ -20,7 +20,7 @@
> from lnst.Common.Version import lnst_version
> from lnst.Controller.Common import ControllerError
> from lnst.Controller.CtlSecSocket import CtlSecSocket
>-from lnst.Controller.RecipeResults import JobStartResult, JobFinishResult
>+from lnst.Controller.RecipeResults import JobStartResult, JobFinishResult,
DeviceCreateResult, DeviceMethodCallResult, DeviceAttrSetResult
> from lnst.Controller.SlaveObject import SlaveObject
> from lnst.Devices import device_classes
> from lnst.Devices.Device import Device
>@@ -121,6 +121,14 @@ def remote_device_create(self, dev, netns=None):
> dev_clsname = dev._dev_cls.__name__
> dev_args = dev._dev_args
> dev_kwargs = dev._dev_kwargs
>+
>+ self._add_recipe_result(
>+ DeviceCreateResult(
>+ success=True,
>+ device=dev,
^^^^^
What's the meaning of this trailing comma?
It's a formatting "recommendation" that for longer lists of arguments
(method, list, tuple, dict, etc) you put each argument on it's own line
and put a comma after the last one. The purpose of this recommendation
is to generat shorter patches when something changes here, e.g.:
without comma:
DeviceCreateResult(
success=True,
- device=dev
+ device=dev,
+ some_new_arg
)
with comma:
DeviceCreateResult(
success=True,
device=dev,
+ some_new_arg,
)
It's something that the 'Black' code formatter I started using does
automatically. It looks like it's also a recommendation mentioned in
PEP8:
https://www.python.org/dev/peps/pep-0008/#when-to-use-trailing-commas
-Ondrej