From d8a8fe9a804d3214a6f88c2ae2a9dc92e2bf6c25 Mon Sep 17 00:00:00 2001 From: Oleksii Kliukin Date: Tue, 24 Nov 2015 16:40:18 +0100 Subject: [PATCH] Convert build_connstring into a one-liner, per code review by Alex. --- patroni/postgresql.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/patroni/postgresql.py b/patroni/postgresql.py index 47fd53d3..a760e879 100644 --- a/patroni/postgresql.py +++ b/patroni/postgresql.py @@ -230,14 +230,10 @@ class Postgresql: @staticmethod def build_connstring(conn): """ - >>> Postgresql.build_connstring({'host': '127.0.0.1', 'port': '5432'}) == 'host=127.0.0.1 port=5432 ' + >>> Postgresql.build_connstring({'host': '127.0.0.1', 'port': '5432'}) == 'host=127.0.0.1 port=5432' True """ - mconn = "" - for param, val in sorted(conn.items()): - mconn = mconn + "{0}={1} ".format(param, val) - - return mconn + return ' '.join('{}={}'.format(param, val) for param, val in sorted(conn.items())) def create_replica(self, leader, env): # create the replica according to the replica_method