Skip to content

Commit 3dda0ef

Browse files
author
James William Pye
committed
random cleanups
1 parent 06a841c commit 3dda0ef

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

postgresql/iri.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
pq://user@host/?[driver_param]=value&[other_param]=value?setting=val
1919
"""
2020
from .resolved import riparse as ri
21-
from . import string as pg_str
22-
import operator
23-
import re
21+
from .string import split_ident
22+
23+
from operator import itemgetter
24+
get0 = itemgetter(0)
25+
del itemgetter
2426

27+
import re
2528
escape_path_re = re.compile('[%s]' %(re.escape(ri.unescaped + ','),))
2629

2730
def structure(d, fieldproc = ri.unescape):
@@ -85,9 +88,7 @@ def construct_path(x, re = escape_path_re):
8588
"""
8689
Join a path sequence using ',' and escaping ',' in the pieces.
8790
"""
88-
return ','.join((
89-
re.sub(ri.re_pct_encode, y) for y in x
90-
))
91+
return ','.join((re.sub(ri.re_pct_encode, y) for y in x))
9192

9293
def construct(x, obscure_password = False):
9394
'Construct a RI dictionary from a clientparams dictionary'
@@ -111,7 +112,7 @@ def construct(x, obscure_password = False):
111112

112113
# It could be a string search_path, split if it is.
113114
if search_path is not None and isinstance(search_path, str):
114-
search_path = pg_str.split_ident(search_path, sep = ',')
115+
search_path = split_ident(search_path, sep = ',')
115116

116117
port = None
117118
if 'unix' in x:
@@ -142,7 +143,7 @@ def construct(x, obscure_password = False):
142143
'path', 'host', 'unix', 'ipv','settings'
143144
)
144145
}.items())
145-
driver_params.sort(key=operator.itemgetter(0))
146+
driver_params.sort(key=get0)
146147

147148
return (
148149
'pqs' if x.get('ssl', False) is True else 'pq',

0 commit comments

Comments
 (0)