Merge lp:~wgrant/launchpad/delete-more into lp:launchpad
- delete-more
- Merge into devel
Proposed by
William Grant
Status: | Merged |
---|---|
Approved by: | Curtis Hovey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 13950 |
Proposed branch: | lp:~wgrant/launchpad/delete-more |
Merge into: | lp:launchpad |
Diff against target: |
479 lines (+11/-363) 8 files modified
lib/canonical/launchpad/components/storm_operators.py (+0/-68) lib/canonical/launchpad/configure.zcml (+0/-1) lib/canonical/launchpad/datetimeutils.py (+0/-96) lib/canonical/launchpad/doc/helpers.txt (+0/-29) lib/canonical/launchpad/helpers.py (+0/-126) lib/canonical/launchpad/links.zcml (+0/-7) lib/canonical/launchpad/tests/test_datetimeutils.py (+0/-10) lib/canonical/launchpad/tests/test_helpers.py (+11/-26) |
To merge this branch: | bzr merge lp:~wgrant/launchpad/delete-more |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | code | Approve | |
Review via email: mp+75179@code.launchpad.net |
Commit message
[r=sinzui][no-qa] Delete some unused code from canonical.*.
Description of the change
Delete some unused code from canonical.*.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'lib/canonical/launchpad/components/storm_operators.py' | |||
2 | --- lib/canonical/launchpad/components/storm_operators.py 2010-08-20 20:31:18 +0000 | |||
3 | +++ lib/canonical/launchpad/components/storm_operators.py 1970-01-01 00:00:00 +0000 | |||
4 | @@ -1,68 +0,0 @@ | |||
5 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
6 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
7 | 3 | |||
8 | 4 | """Operators and functions for Storm queries that are not in Storm. | ||
9 | 5 | |||
10 | 6 | You can use these to do FTI queries like this: | ||
11 | 7 | |||
12 | 8 | >>> search_vector_column = <table.column> | ||
13 | 9 | >>> query_function = FTQ(search_term) | ||
14 | 10 | >>> rank = RANK(search_vector_column, query_function) | ||
15 | 11 | >>> select_spec = <required_columns, rank> | ||
16 | 12 | >>> results = store.find( | ||
17 | 13 | ... (select_spec), | ||
18 | 14 | ... Match(search_vector_column, query_function)) | ||
19 | 15 | >>> results.order_by(Desc(rank)) | ||
20 | 16 | |||
21 | 17 | """ | ||
22 | 18 | |||
23 | 19 | __metaclass__ = type | ||
24 | 20 | |||
25 | 21 | __all__ = [ | ||
26 | 22 | 'FTQ', | ||
27 | 23 | 'Match', | ||
28 | 24 | 'RANK', | ||
29 | 25 | ] | ||
30 | 26 | |||
31 | 27 | from storm.expr import ( | ||
32 | 28 | CompoundOper, | ||
33 | 29 | NamedFunc, | ||
34 | 30 | ) | ||
35 | 31 | |||
36 | 32 | |||
37 | 33 | class FTQ(NamedFunc): | ||
38 | 34 | """Full Text Query function. | ||
39 | 35 | |||
40 | 36 | Implements the PostgreSQL ftq() function: ftq(search_string) | ||
41 | 37 | Returns a ts_query | ||
42 | 38 | """ | ||
43 | 39 | __slots__ = () | ||
44 | 40 | name = "FTQ" | ||
45 | 41 | |||
46 | 42 | |||
47 | 43 | class RANK(NamedFunc): | ||
48 | 44 | """Full text rank function. | ||
49 | 45 | |||
50 | 46 | Implements the PostgreSQL ts_rank() function: | ||
51 | 47 | ts_rank( | ||
52 | 48 | [ weights float4[], ] | ||
53 | 49 | vector tsvector, | ||
54 | 50 | query tsquery [, | ||
55 | 51 | normalization integer ]) | ||
56 | 52 | |||
57 | 53 | Returns a float4. | ||
58 | 54 | """ | ||
59 | 55 | __slots__ = () | ||
60 | 56 | name = "TS_RANK" | ||
61 | 57 | |||
62 | 58 | |||
63 | 59 | class Match(CompoundOper): | ||
64 | 60 | """Full text match operator. | ||
65 | 61 | |||
66 | 62 | The full text match operator is used to compare a compiled search | ||
67 | 63 | (tsquery) expression to a text search vector (tsvector). In PostgreSQL, the | ||
68 | 64 | operator returns a "true" value if the tsvector matches the tsquery. | ||
69 | 65 | """ | ||
70 | 66 | __slots__ = () | ||
71 | 67 | oper = "@@" | ||
72 | 68 | |||
73 | 69 | 0 | ||
74 | === modified file 'lib/canonical/launchpad/configure.zcml' | |||
75 | --- lib/canonical/launchpad/configure.zcml 2011-07-07 19:41:46 +0000 | |||
76 | +++ lib/canonical/launchpad/configure.zcml 2011-09-14 01:26:41 +0000 | |||
77 | @@ -12,7 +12,6 @@ | |||
78 | 12 | 12 | ||
79 | 13 | <include package="canonical.launchpad.webapp" /> | 13 | <include package="canonical.launchpad.webapp" /> |
80 | 14 | <include package="canonical.launchpad.vocabularies" /> | 14 | <include package="canonical.launchpad.vocabularies" /> |
81 | 15 | <include file="links.zcml" /> | ||
82 | 16 | <include package="canonical.launchpad.zcml" /> | 15 | <include package="canonical.launchpad.zcml" /> |
83 | 17 | <authorizations module="canonical.launchpad.security" /> | 16 | <authorizations module="canonical.launchpad.security" /> |
84 | 18 | <include package="canonical.launchpad.xmlrpc" /> | 17 | <include package="canonical.launchpad.xmlrpc" /> |
85 | 19 | 18 | ||
86 | === removed file 'lib/canonical/launchpad/datetimeutils.py' | |||
87 | --- lib/canonical/launchpad/datetimeutils.py 2010-08-20 20:31:18 +0000 | |||
88 | +++ lib/canonical/launchpad/datetimeutils.py 1970-01-01 00:00:00 +0000 | |||
89 | @@ -1,96 +0,0 @@ | |||
90 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
91 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
92 | 3 | |||
93 | 4 | """Various functions that are useful for handling dates/datetimes.""" | ||
94 | 5 | |||
95 | 6 | __metaclass__ = type | ||
96 | 7 | |||
97 | 8 | from datetime import ( | ||
98 | 9 | date, | ||
99 | 10 | timedelta, | ||
100 | 11 | ) | ||
101 | 12 | |||
102 | 13 | |||
103 | 14 | def make_mondays_between(start, end): | ||
104 | 15 | """Iteration of dates that are mondays between start and end dates. | ||
105 | 16 | |||
106 | 17 | A friday to a monday. | ||
107 | 18 | |||
108 | 19 | >>> for monday in make_mondays_between( | ||
109 | 20 | ... date(2005, 11, 25), date(2006, 1, 9)): | ||
110 | 21 | ... print monday.isocalendar() | ||
111 | 22 | (2005, 48, 1) | ||
112 | 23 | (2005, 49, 1) | ||
113 | 24 | (2005, 50, 1) | ||
114 | 25 | (2005, 51, 1) | ||
115 | 26 | (2005, 52, 1) | ||
116 | 27 | (2006, 1, 1) | ||
117 | 28 | (2006, 2, 1) | ||
118 | 29 | |||
119 | 30 | Test from Tuesday to Monday. | ||
120 | 31 | |||
121 | 32 | >>> for day in range(22, 30): | ||
122 | 33 | ... mondays = make_mondays_between( | ||
123 | 34 | ... date(2005, 11, day), date(2005, 12, day)) | ||
124 | 35 | ... print date(2005, 11, day).isocalendar(), mondays.next().isoformat() | ||
125 | 36 | (2005, 47, 2) 2005-11-28 | ||
126 | 37 | (2005, 47, 3) 2005-11-28 | ||
127 | 38 | (2005, 47, 4) 2005-11-28 | ||
128 | 39 | (2005, 47, 5) 2005-11-28 | ||
129 | 40 | (2005, 47, 6) 2005-11-28 | ||
130 | 41 | (2005, 47, 7) 2005-11-28 | ||
131 | 42 | (2005, 48, 1) 2005-11-28 | ||
132 | 43 | (2005, 48, 2) 2005-12-05 | ||
133 | 44 | """ | ||
134 | 45 | assert isinstance(start, date) | ||
135 | 46 | assert isinstance(end, date) | ||
136 | 47 | mondaystart = start + timedelta(days=(8 - start.isoweekday()) % 7) | ||
137 | 48 | currentdate = mondaystart | ||
138 | 49 | while currentdate <= end: | ||
139 | 50 | yield currentdate | ||
140 | 51 | currentdate += timedelta(days=7) | ||
141 | 52 | |||
142 | 53 | def get_date_for_monday(year, week): | ||
143 | 54 | """Return the date of monday for the given iso week in the given year. | ||
144 | 55 | |||
145 | 56 | >>> get_date_for_monday(2005, 48).isoformat() | ||
146 | 57 | '2005-11-28' | ||
147 | 58 | >>> get_date_for_monday(2005, 50).isoformat() | ||
148 | 59 | '2005-12-12' | ||
149 | 60 | >>> get_date_for_monday(2005, 51).isoformat() | ||
150 | 61 | '2005-12-19' | ||
151 | 62 | >>> get_date_for_monday(2005, 52).isoformat() | ||
152 | 63 | '2005-12-26' | ||
153 | 64 | >>> get_date_for_monday(2005, 53).isoformat() | ||
154 | 65 | '2006-01-02' | ||
155 | 66 | >>> get_date_for_monday(2005, 54).isoformat() | ||
156 | 67 | '2006-01-09' | ||
157 | 68 | >>> get_date_for_monday(2006, 1).isoformat() | ||
158 | 69 | '2006-01-02' | ||
159 | 70 | >>> get_date_for_monday(2006, 2).isoformat() | ||
160 | 71 | '2006-01-09' | ||
161 | 72 | """ | ||
162 | 73 | first_monday = first_monday_in_year(year) | ||
163 | 74 | fm_y, fm_w, fm_d = first_monday.isocalendar() | ||
164 | 75 | weeks_to_add = week - fm_w | ||
165 | 76 | assert weeks_to_add >= 0 | ||
166 | 77 | return first_monday + timedelta(weeks=weeks_to_add) | ||
167 | 78 | |||
168 | 79 | def first_monday_in_year(year): | ||
169 | 80 | """Return the date of the first monday in the year. | ||
170 | 81 | |||
171 | 82 | >>> for year in range(1999, 2009): | ||
172 | 83 | ... first_monday_in_year(year).isoformat() | ||
173 | 84 | '1999-01-04' | ||
174 | 85 | '2000-01-03' | ||
175 | 86 | '2001-01-01' | ||
176 | 87 | '2002-01-07' | ||
177 | 88 | '2003-01-06' | ||
178 | 89 | '2004-01-05' | ||
179 | 90 | '2005-01-03' | ||
180 | 91 | '2006-01-02' | ||
181 | 92 | '2007-01-01' | ||
182 | 93 | '2008-01-07' | ||
183 | 94 | """ | ||
184 | 95 | return date(year, 1, (8 - date(year, 1, 1).isoweekday()) % 7 + 1) | ||
185 | 96 | |||
186 | 97 | 0 | ||
187 | === modified file 'lib/canonical/launchpad/doc/helpers.txt' | |||
188 | --- lib/canonical/launchpad/doc/helpers.txt 2009-01-13 16:56:48 +0000 | |||
189 | +++ lib/canonical/launchpad/doc/helpers.txt 2011-09-14 01:26:41 +0000 | |||
190 | @@ -5,35 +5,6 @@ | |||
191 | 5 | duplicating code in different parts of Launchpad. | 5 | duplicating code in different parts of Launchpad. |
192 | 6 | 6 | ||
193 | 7 | 7 | ||
194 | 8 | == Getting a valid name as our database asks for from a string == | ||
195 | 9 | |||
196 | 10 | >>> from canonical.launchpad.helpers import getValidNameFromString | ||
197 | 11 | |||
198 | 12 | The string has capital letters. | ||
199 | 13 | |||
200 | 14 | >>> original_string = 'EvilStringNotFollowingOurRules' | ||
201 | 15 | >>> getValidNameFromString(original_string) | ||
202 | 16 | 'evilstringnotfollowingourrules' | ||
203 | 17 | |||
204 | 18 | The string has underscores. | ||
205 | 19 | |||
206 | 20 | >>> original_string = 'evil_string_not_following_our_rules' | ||
207 | 21 | >>> getValidNameFromString(original_string) | ||
208 | 22 | 'evil-string-not-following-our-rules' | ||
209 | 23 | |||
210 | 24 | The string has white spaces. | ||
211 | 25 | |||
212 | 26 | >>> original_string = 'evil string not following our rules' | ||
213 | 27 | >>> getValidNameFromString(original_string) | ||
214 | 28 | 'evil-string-not-following-our-rules' | ||
215 | 29 | |||
216 | 30 | A mix of all previous cases. | ||
217 | 31 | |||
218 | 32 | >>> original_string = 'Evil String Not_Following_our rUles' | ||
219 | 33 | >>> getValidNameFromString(original_string) | ||
220 | 34 | 'evil-string-not-following-our-rules' | ||
221 | 35 | |||
222 | 36 | |||
223 | 37 | == Concatenating lists English-style == | 8 | == Concatenating lists English-style == |
224 | 38 | 9 | ||
225 | 39 | The english_list function takes a list of strings and concatenates | 10 | The english_list function takes a list of strings and concatenates |
226 | 40 | 11 | ||
227 | === modified file 'lib/canonical/launchpad/helpers.py' | |||
228 | --- lib/canonical/launchpad/helpers.py 2011-06-08 05:43:21 +0000 | |||
229 | +++ lib/canonical/launchpad/helpers.py 2011-09-14 01:26:41 +0000 | |||
230 | @@ -12,7 +12,6 @@ | |||
231 | 12 | 12 | ||
232 | 13 | from difflib import unified_diff | 13 | from difflib import unified_diff |
233 | 14 | import os | 14 | import os |
234 | 15 | import random | ||
235 | 16 | import re | 15 | import re |
236 | 17 | from StringIO import StringIO | 16 | from StringIO import StringIO |
237 | 18 | import subprocess | 17 | import subprocess |
238 | @@ -95,83 +94,12 @@ | |||
239 | 95 | return str.decode('UTF-8').encode('ASCII', 'backslashreplace') | 94 | return str.decode('UTF-8').encode('ASCII', 'backslashreplace') |
240 | 96 | 95 | ||
241 | 97 | 96 | ||
242 | 98 | def join_lines(*lines): | ||
243 | 99 | """Concatenate a list of strings, adding a newline at the end of each.""" | ||
244 | 100 | |||
245 | 101 | return ''.join([x + '\n' for x in lines]) | ||
246 | 102 | |||
247 | 103 | |||
248 | 104 | def string_to_tarfile(s): | 97 | def string_to_tarfile(s): |
249 | 105 | """Convert a binary string containing a tar file into a tar file obj.""" | 98 | """Convert a binary string containing a tar file into a tar file obj.""" |
250 | 106 | 99 | ||
251 | 107 | return tarfile.open('', 'r', StringIO(s)) | 100 | return tarfile.open('', 'r', StringIO(s)) |
252 | 108 | 101 | ||
253 | 109 | 102 | ||
254 | 110 | def shortest(sequence): | ||
255 | 111 | """Return a list with the shortest items in sequence. | ||
256 | 112 | |||
257 | 113 | Return an empty list if the sequence is empty. | ||
258 | 114 | """ | ||
259 | 115 | shortest_list = [] | ||
260 | 116 | shortest_length = None | ||
261 | 117 | |||
262 | 118 | for item in list(sequence): | ||
263 | 119 | new_length = len(item) | ||
264 | 120 | |||
265 | 121 | if shortest_length is None: | ||
266 | 122 | # First item. | ||
267 | 123 | shortest_list.append(item) | ||
268 | 124 | shortest_length = new_length | ||
269 | 125 | elif new_length == shortest_length: | ||
270 | 126 | # Same length than shortest item found, we append it to the list. | ||
271 | 127 | shortest_list.append(item) | ||
272 | 128 | elif min(new_length, shortest_length) != shortest_length: | ||
273 | 129 | # Shorter than our shortest length found, discard old values. | ||
274 | 130 | shortest_list = [item] | ||
275 | 131 | shortest_length = new_length | ||
276 | 132 | |||
277 | 133 | return shortest_list | ||
278 | 134 | |||
279 | 135 | |||
280 | 136 | def getRosettaBestBinaryPackageName(sequence): | ||
281 | 137 | """Return the best binary package name from a list. | ||
282 | 138 | |||
283 | 139 | It follows the Rosetta policy: | ||
284 | 140 | |||
285 | 141 | We don't need a concrete value from binary package name, we use shortest | ||
286 | 142 | function as a kind of heuristic to choose the shortest binary package | ||
287 | 143 | name that we suppose will be the more descriptive one for our needs with | ||
288 | 144 | PO templates. That's why we get always the first element. | ||
289 | 145 | """ | ||
290 | 146 | return shortest(sequence)[0] | ||
291 | 147 | |||
292 | 148 | |||
293 | 149 | def getRosettaBestDomainPath(sequence): | ||
294 | 150 | """Return the best path for a concrete .pot file from a list of paths. | ||
295 | 151 | |||
296 | 152 | It follows the Rosetta policy for this path: | ||
297 | 153 | |||
298 | 154 | We don't need a concrete value from domain_paths list, we use shortest | ||
299 | 155 | function as a kind of heuristic to choose the shortest path if we have | ||
300 | 156 | more than one, usually, we will have only one element. | ||
301 | 157 | """ | ||
302 | 158 | return shortest(sequence)[0] | ||
303 | 159 | |||
304 | 160 | |||
305 | 161 | def getValidNameFromString(invalid_name): | ||
306 | 162 | """Return a valid name based on a string. | ||
307 | 163 | |||
308 | 164 | A name in launchpad has a set of restrictions that not all strings follow. | ||
309 | 165 | This function converts any string in another one that follows our name | ||
310 | 166 | restriction rules. | ||
311 | 167 | |||
312 | 168 | To know more about all restrictions, please, look at valid_name function | ||
313 | 169 | in the database. | ||
314 | 170 | """ | ||
315 | 171 | # All chars should be lower case, underscores and spaces become dashes. | ||
316 | 172 | return text_replaced(invalid_name.lower(), {'_': '-', ' ': '-'}) | ||
317 | 173 | |||
318 | 174 | |||
319 | 175 | def browserLanguages(request): | 103 | def browserLanguages(request): |
320 | 176 | """Return a list of Language objects based on the browser preferences.""" | 104 | """Return a list of Language objects based on the browser preferences.""" |
321 | 177 | return IRequestPreferredLanguages(request).getPreferredLanguages() | 105 | return IRequestPreferredLanguages(request).getPreferredLanguages() |
322 | @@ -214,36 +142,6 @@ | |||
323 | 214 | for mail_person in get_recipients(person)) | 142 | for mail_person in get_recipients(person)) |
324 | 215 | 143 | ||
325 | 216 | 144 | ||
326 | 217 | replacements = {0: {'.': ' |dot| ', | ||
327 | 218 | '@': ' |at| '}, | ||
328 | 219 | 1: {'.': ' ! ', | ||
329 | 220 | '@': ' {} '}, | ||
330 | 221 | 2: {'.': ' , ', | ||
331 | 222 | '@': ' % '}, | ||
332 | 223 | 3: {'.': ' (!) ', | ||
333 | 224 | '@': ' (at) '}, | ||
334 | 225 | 4: {'.': ' {dot} ', | ||
335 | 226 | '@': ' {at} '}, | ||
336 | 227 | } | ||
337 | 228 | |||
338 | 229 | |||
339 | 230 | def obfuscateEmail(emailaddr, idx=None): | ||
340 | 231 | """Return an obfuscated version of the provided email address. | ||
341 | 232 | |||
342 | 233 | Randomly chose a set of replacements for some email address characters and | ||
343 | 234 | replace them. This will make harder for email harvesters to fetch email | ||
344 | 235 | address from launchpad. | ||
345 | 236 | |||
346 | 237 | >>> obfuscateEmail('foo@bar.com', 0) | ||
347 | 238 | 'foo |at| bar |dot| com' | ||
348 | 239 | >>> obfuscateEmail('foo.bar@xyz.com.br', 1) | ||
349 | 240 | 'foo ! bar {} xyz ! com ! br' | ||
350 | 241 | """ | ||
351 | 242 | if idx is None: | ||
352 | 243 | idx = random.randint(0, len(replacements) - 1) | ||
353 | 244 | return text_replaced(emailaddr, replacements[idx]) | ||
354 | 245 | |||
355 | 246 | |||
356 | 247 | class ShortListTooBigError(Exception): | 145 | class ShortListTooBigError(Exception): |
357 | 248 | """This error is raised when the shortlist hardlimit is reached""" | 146 | """This error is raised when the shortlist hardlimit is reached""" |
358 | 249 | 147 | ||
359 | @@ -433,30 +331,6 @@ | |||
360 | 433 | return 0 | 331 | return 0 |
361 | 434 | 332 | ||
362 | 435 | 333 | ||
363 | 436 | def positiveIntOrZero(value): | ||
364 | 437 | """Return 0 if int(value) fails or if int(value) is less than 0. | ||
365 | 438 | |||
366 | 439 | Return int(value) otherwise. | ||
367 | 440 | |||
368 | 441 | >>> positiveIntOrZero(None) | ||
369 | 442 | 0 | ||
370 | 443 | >>> positiveIntOrZero(-9) | ||
371 | 444 | 0 | ||
372 | 445 | >>> positiveIntOrZero(1) | ||
373 | 446 | 1 | ||
374 | 447 | >>> positiveIntOrZero('-3') | ||
375 | 448 | 0 | ||
376 | 449 | >>> positiveIntOrZero('5') | ||
377 | 450 | 5 | ||
378 | 451 | >>> positiveIntOrZero(3.1415) | ||
379 | 452 | 3 | ||
380 | 453 | """ | ||
381 | 454 | value = intOrZero(value) | ||
382 | 455 | if value < 0: | ||
383 | 456 | return 0 | ||
384 | 457 | return value | ||
385 | 458 | |||
386 | 459 | |||
387 | 460 | def get_email_template(filename, app=None): | 334 | def get_email_template(filename, app=None): |
388 | 461 | """Returns the email template with the given file name. | 335 | """Returns the email template with the given file name. |
389 | 462 | 336 | ||
390 | 463 | 337 | ||
391 | === removed file 'lib/canonical/launchpad/links.zcml' | |||
392 | --- lib/canonical/launchpad/links.zcml 2009-07-13 18:15:02 +0000 | |||
393 | +++ lib/canonical/launchpad/links.zcml 1970-01-01 00:00:00 +0000 | |||
394 | @@ -1,7 +0,0 @@ | |||
395 | 1 | <!-- Copyright 2009 Canonical Ltd. This software is licensed under the | ||
396 | 2 | GNU Affero General Public License version 3 (see the file LICENSE). | ||
397 | 3 | --> | ||
398 | 4 | |||
399 | 5 | <configure xmlns:browser="http://namespaces.zope.org/browser"> | ||
400 | 6 | |||
401 | 7 | </configure> | ||
402 | 8 | 0 | ||
403 | === removed file 'lib/canonical/launchpad/tests/test_datetimeutils.py' | |||
404 | --- lib/canonical/launchpad/tests/test_datetimeutils.py 2010-10-12 01:11:41 +0000 | |||
405 | +++ lib/canonical/launchpad/tests/test_datetimeutils.py 1970-01-01 00:00:00 +0000 | |||
406 | @@ -1,10 +0,0 @@ | |||
407 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | ||
408 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | ||
409 | 3 | |||
410 | 4 | from doctest import DocTestSuite | ||
411 | 5 | |||
412 | 6 | from canonical.launchpad import datetimeutils | ||
413 | 7 | |||
414 | 8 | |||
415 | 9 | def test_suite(): | ||
416 | 10 | return DocTestSuite(datetimeutils) | ||
417 | 11 | 0 | ||
418 | === modified file 'lib/canonical/launchpad/tests/test_helpers.py' | |||
419 | --- lib/canonical/launchpad/tests/test_helpers.py 2011-03-30 20:08:42 +0000 | |||
420 | +++ lib/canonical/launchpad/tests/test_helpers.py 2011-09-14 01:26:41 +0000 | |||
421 | @@ -2,6 +2,7 @@ | |||
422 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
423 | 3 | 3 | ||
424 | 4 | from doctest import DocTestSuite | 4 | from doctest import DocTestSuite |
425 | 5 | from textwrap import dedent | ||
426 | 5 | import unittest | 6 | import unittest |
427 | 6 | 7 | ||
428 | 7 | from zope.interface import implements | 8 | from zope.interface import implements |
429 | @@ -67,17 +68,17 @@ | |||
430 | 67 | '# Test PO file.\n' | 68 | '# Test PO file.\n' |
431 | 68 | ''' | 69 | ''' |
432 | 69 | 70 | ||
438 | 70 | pot = helpers.join_lines( | 71 | pot = dedent(""" |
439 | 71 | '# Test POT file.', | 72 | # Test POT file. |
440 | 72 | 'msgid "foo"', | 73 | msgid "foo" |
441 | 73 | 'msgstr ""', | 74 | msgstr "" |
442 | 74 | ), | 75 | """).strip() |
443 | 75 | 76 | ||
449 | 76 | po = helpers.join_lines( | 77 | po = dedent(""" |
450 | 77 | '# Test PO file.', | 78 | # Test PO file. |
451 | 78 | 'msgid "foo"', | 79 | msgid "foo" |
452 | 79 | 'msgstr "bar"', | 80 | msgstr "bar" |
453 | 80 | ) | 81 | """).strip() |
454 | 81 | 82 | ||
455 | 82 | return LaunchpadWriteTarFile.files_to_tarfile({ | 83 | return LaunchpadWriteTarFile.files_to_tarfile({ |
456 | 83 | 'test/test.pot': pot, | 84 | 'test/test.pot': pot, |
457 | @@ -86,22 +87,6 @@ | |||
458 | 86 | }) | 87 | }) |
459 | 87 | 88 | ||
460 | 88 | 89 | ||
461 | 89 | def test_join_lines(): | ||
462 | 90 | r""" | ||
463 | 91 | >>> helpers.join_lines('foo', 'bar', 'baz') | ||
464 | 92 | 'foo\nbar\nbaz\n' | ||
465 | 93 | """ | ||
466 | 94 | |||
467 | 95 | |||
468 | 96 | def test_shortest(): | ||
469 | 97 | """ | ||
470 | 98 | >>> helpers.shortest(['xyzzy', 'foo', 'blah']) | ||
471 | 99 | ['foo'] | ||
472 | 100 | >>> helpers.shortest(['xyzzy', 'foo', 'bar']) | ||
473 | 101 | ['foo', 'bar'] | ||
474 | 102 | """ | ||
475 | 103 | |||
476 | 104 | |||
477 | 105 | class DummyLanguage: | 90 | class DummyLanguage: |
478 | 106 | 91 | ||
479 | 107 | def __init__(self, code, pluralforms): | 92 | def __init__(self, code, pluralforms): |
Thank you very much!