Merge ~cjwatson/launchpad:py3only-drop-py3ish-repr into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 514557d70383de57e0ad633ee5ef182a78ccdb79
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3only-drop-py3ish-repr
Merge into: launchpad:master
Diff against target: 123 lines (+15/-37)
1 file modified
lib/lp/services/database/postgresql.py (+15/-37)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+406963@code.launchpad.net

Commit message

Drop lp.services.database.postgresql._py3ish_repr

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/database/postgresql.py b/lib/lp/services/database/postgresql.py
2index 462edc6..d36c374 100644
3--- a/lib/lp/services/database/postgresql.py
4+++ b/lib/lp/services/database/postgresql.py
5@@ -19,28 +19,6 @@ from lp.services.database.sqlbase import (
6 )
7
8
9-def _py3ish_repr(value):
10- """Like `repr`, but uses Python 3 spelling of text.
11-
12- This is a local helper for doctests.
13- """
14- if isinstance(value, six.text_type):
15- value = value.encode('unicode_escape').decode('ASCII')
16- if "'" in value and '"' not in value:
17- return '"%s"' % value
18- else:
19- return "'%s'" % value.replace("'", "\\'")
20- elif isinstance(value, tuple):
21- if len(value) == 1:
22- return '(' + _py3ish_repr(value[0]) + ',)'
23- else:
24- return '(' + ', '.join(_py3ish_repr(item) for item in value) + ')'
25- elif isinstance(value, list):
26- return '[' + ', '.join(_py3ish_repr(item) for item in value) + ']'
27- else:
28- return repr(value)
29-
30-
31 def listReferences(cur, table, column, indirect=True, _state=None):
32 """Return a list of all foreign key references to the given table column
33
34@@ -63,7 +41,7 @@ def listReferences(cur, table, column, indirect=True, _state=None):
35 to change keys.
36
37 >>> for r in listReferences(cur, 'a', 'aid'):
38- ... print(_py3ish_repr(r))
39+ ... print(repr(r))
40 ('a', 'selfref', 'a', 'aid', 'a', 'a')
41 ('b', 'aid', 'a', 'aid', 'c', 'c')
42 ('c', 'aid', 'b', 'aid', 'a', 'a')
43@@ -135,32 +113,32 @@ def listIndexes(cur, table, column, only_unique=False):
44
45 Simple indexes
46
47- >>> print(_py3ish_repr(listIndexes(cur, 'b', 'aid')))
48+ >>> listIndexes(cur, 'b', 'aid')
49 [('aid',)]
50- >>> print(_py3ish_repr(listIndexes(cur, 'a', 'name')))
51+ >>> listIndexes(cur, 'a', 'name')
52 [('name',)]
53
54 Primary keys are indexes too
55
56- >>> print(_py3ish_repr(listIndexes(cur, 'a', 'aid')))
57+ >>> listIndexes(cur, 'a', 'aid')
58 [('aid',)]
59
60 Compound indexes
61
62- >>> print(_py3ish_repr(listIndexes(cur, 'c', 'aid')))
63+ >>> listIndexes(cur, 'c', 'aid')
64 [('aid', 'bid')]
65- >>> print(_py3ish_repr(listIndexes(cur, 'c', 'bid')))
66+ >>> listIndexes(cur, 'c', 'bid')
67 [('aid', 'bid')]
68- >>> print(_py3ish_repr(listIndexes(cur, 'c', 'name')))
69+ >>> listIndexes(cur, 'c', 'name')
70 [('name', 'description')]
71- >>> print(_py3ish_repr(listIndexes(cur, 'c', 'description')))
72+ >>> listIndexes(cur, 'c', 'description')
73 [('name', 'description')]
74
75 And any combination
76
77 >>> l = listIndexes(cur, 'd', 'aid')
78 >>> l.sort()
79- >>> print(_py3ish_repr(l))
80+ >>> l
81 [('aid',), ('aid', 'bid')]
82
83 If there are no indexes using the secified column
84@@ -225,26 +203,26 @@ def listUniques(cur, table, column):
85
86 Simple UNIQUE index
87
88- >>> print(_py3ish_repr(listUniques(cur, 'b', 'aid')))
89+ >>> listUniques(cur, 'b', 'aid')
90 [('aid',)]
91
92 Primary keys are UNIQUE indexes too
93
94- >>> print(_py3ish_repr(listUniques(cur, 'a', 'aid')))
95+ >>> listUniques(cur, 'a', 'aid')
96 [('aid',)]
97
98 Compound indexes
99
100- >>> print(_py3ish_repr(listUniques(cur, 'c', 'aid')))
101+ >>> listUniques(cur, 'c', 'aid')
102 [('aid', 'bid')]
103- >>> print(_py3ish_repr(listUniques(cur, 'c', 'bid')))
104+ >>> listUniques(cur, 'c', 'bid')
105 [('aid', 'bid')]
106
107 And any combination
108
109 >>> l = listUniques(cur, 'd', 'aid')
110 >>> l.sort()
111- >>> print(_py3ish_repr(l))
112+ >>> l
113 [('aid',), ('aid', 'bid')]
114
115 If there are no UNIQUE indexes using the secified column
116@@ -270,7 +248,7 @@ def listSequences(cur):
117 standalone.
118
119 >>> for r in listSequences(cur):
120- ... print(_py3ish_repr(r))
121+ ... print(repr(r))
122 ('public', 'a_aid_seq', 'a', 'aid')
123 ('public', 'standalone', None, None)
124

Subscribers

People subscribed via source and target branches

to status/vote changes: