From 6b2b1846e6a261e59b1bb721d98f1a680483cff8 Mon Sep 17 00:00:00 2001 From: Pierre NAPOLETANO <56818795+PierreNAPOLETANO@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:44:38 +0200 Subject: [PATCH] make python code a little more pythonic --- proton/api.py | 5 +---- proton/srp/_pysrp.py | 10 ++-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/proton/api.py b/proton/api.py index 2fb810c..d35d621 100644 --- a/proton/api.py +++ b/proton/api.py @@ -197,10 +197,7 @@ def api_request( fct = self.s.post if method is None: - if jsondata is None: - fct = self.s.get - else: - fct = self.s.post + fct = self.s.get if jsondata is None else self.s.post else: fct = { "get": self.s.get, diff --git a/proton/srp/_pysrp.py b/proton/srp/_pysrp.py index 91689af..08ed6f1 100644 --- a/proton/srp/_pysrp.py +++ b/proton/srp/_pysrp.py @@ -67,14 +67,8 @@ def __init__(self, password, n_bin, g_hex=b"2", bytes_a=None, bytes_A=None): # n ) self.p = password.encode() - if bytes_a: - self.a = bytes_to_long(bytes_a) - else: - self.a = get_random_of_length(32) - if bytes_A: - self.A = bytes_to_long(bytes_A) - else: - self.A = pow(self.g, self.a, self.N) + self.a = bytes_to_long(bytes_a) if bytes_a else get_random_of_length(32) + self.A = bytes_to_long(bytes_A) if bytes_A else pow(self.g, self.a, self.N) self.v = None self.M = None self.K = None