Francesco Romani has posted comments on this change.

Change subject: lib: response: helper to detect valid responses
......................................................................


Patch Set 7:

(3 comments)

https://gerrit.ovirt.org/#/c/63760/7/lib/vdsm/response.py
File lib/vdsm/response.py:

Line 85:         else:
Line 86:             return code != doneCode["code"]
Line 87: 
Line 88: 
Line 89: def is_valid(res):
> The name is not very clear - maybe is_response()?
Fully agree for the docs; not sure about the name:

  response.is_response(res)

reads a bit awkward
Line 90:     # catching AttributeError is even uglier
Line 91:     if not isinstance(res, dict):
Line 92:         return False
Line 93:     try:


Line 90:     # catching AttributeError is even uglier
Line 91:     if not isinstance(res, dict):
Line 92:         return False
Line 93:     try:
Line 94:         status = res["status"]
> Lets minimize the try block and move the KeyError here.
Done
Line 95:         return all(k in status for k in
Line 96:                    ("code", "message"))
Line 97:     except KeyError:


Line 92:         return False
Line 93:     try:
Line 94:         status = res["status"]
Line 95:         return all(k in status for k in
Line 96:                    ("code", "message"))
> I guess this would be more clear and faster:
Done
Line 97:     except KeyError:


-- 
To view, visit https://gerrit.ovirt.org/63760
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ifab6a25bea1b4a187d8425275e86bdb2fecf4c7d
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Irit Goihman <igoih...@redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Milan Zamazal <mzama...@redhat.com>
Gerrit-Reviewer: Nir Soffer <nsof...@redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczew...@gmail.com>
Gerrit-Reviewer: gerrit-hooks <automat...@ovirt.org>
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org

Reply via email to