Merge ~cjwatson/launchpad:services-worlddata-future-imports into launchpad:master
- Git
- lp:~cjwatson/launchpad
- services-worlddata-future-imports
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | ab261f9b0b6521da2c21bed81feef983c8c641ae |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:services-worlddata-future-imports |
Merge into: | launchpad:master |
Diff against target: |
559 lines (+87/-57) 17 files modified
lib/lp/services/worlddata/browser/country.py (+2/-0) lib/lp/services/worlddata/doc/language.txt (+23/-23) lib/lp/services/worlddata/doc/vocabularies.txt (+8/-8) lib/lp/services/worlddata/helpers.py (+2/-0) lib/lp/services/worlddata/interfaces/country.py (+2/-0) lib/lp/services/worlddata/interfaces/language.py (+2/-0) lib/lp/services/worlddata/interfaces/spokenin.py (+2/-0) lib/lp/services/worlddata/interfaces/timezone.py (+2/-0) lib/lp/services/worlddata/interfaces/webservice.py (+2/-0) lib/lp/services/worlddata/model/country.py (+5/-2) lib/lp/services/worlddata/model/language.py (+5/-3) lib/lp/services/worlddata/model/spokenin.py (+2/-0) lib/lp/services/worlddata/stories/webservice/xx-country.txt (+6/-6) lib/lp/services/worlddata/stories/webservice/xx-language.txt (+9/-9) lib/lp/services/worlddata/tests/test_doc.py (+7/-2) lib/lp/services/worlddata/tests/test_helpers.py (+6/-4) lib/lp/services/worlddata/tests/test_language.py (+2/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thiago F. Pappacena (community) | Approve | ||
Review via email:
|
Commit message
Convert lp.services.
Description of the change
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 | diff --git a/lib/lp/services/worlddata/browser/country.py b/lib/lp/services/worlddata/browser/country.py | |||
2 | index 61cb1be..0641ff1 100644 | |||
3 | --- a/lib/lp/services/worlddata/browser/country.py | |||
4 | +++ b/lib/lp/services/worlddata/browser/country.py | |||
5 | @@ -1,6 +1,8 @@ | |||
6 | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the |
7 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | 3 | 3 | ||
9 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
10 | 5 | |||
11 | 4 | from lp.services.webapp import GetitemNavigation | 6 | from lp.services.webapp import GetitemNavigation |
12 | 5 | from lp.services.worlddata.interfaces.country import ICountrySet | 7 | from lp.services.worlddata.interfaces.country import ICountrySet |
13 | 6 | 8 | ||
14 | diff --git a/lib/lp/services/worlddata/doc/language.txt b/lib/lp/services/worlddata/doc/language.txt | |||
15 | index fdca7f3..4e36fd2 100644 | |||
16 | --- a/lib/lp/services/worlddata/doc/language.txt | |||
17 | +++ b/lib/lp/services/worlddata/doc/language.txt | |||
18 | @@ -24,12 +24,12 @@ canonicalise_language_code | |||
19 | 24 | 24 | ||
20 | 25 | We can convert language codes to standard form. | 25 | We can convert language codes to standard form. |
21 | 26 | 26 | ||
28 | 27 | >>> language_set.canonicalise_language_code('pt') | 27 | >>> print(language_set.canonicalise_language_code('pt')) |
29 | 28 | 'pt' | 28 | pt |
30 | 29 | >>> language_set.canonicalise_language_code('pt_BR') | 29 | >>> print(language_set.canonicalise_language_code('pt_BR')) |
31 | 30 | 'pt_BR' | 30 | pt_BR |
32 | 31 | >>> language_set.canonicalise_language_code('pt-br') | 31 | >>> print(language_set.canonicalise_language_code('pt-br')) |
33 | 32 | 'pt_BR' | 32 | pt_BR |
34 | 33 | 33 | ||
35 | 34 | codes_to_languages | 34 | codes_to_languages |
36 | 35 | ================== | 35 | ================== |
37 | @@ -50,9 +50,9 @@ createLanguage | |||
38 | 50 | This method creates a new language. | 50 | This method creates a new language. |
39 | 51 | 51 | ||
40 | 52 | >>> foos = language_set.createLanguage('foos', 'Foo language') | 52 | >>> foos = language_set.createLanguage('foos', 'Foo language') |
42 | 53 | >>> print foos.code | 53 | >>> print(foos.code) |
43 | 54 | foos | 54 | foos |
45 | 55 | >>> print foos.englishname | 55 | >>> print(foos.englishname) |
46 | 56 | Foo language | 56 | Foo language |
47 | 57 | 57 | ||
48 | 58 | search | 58 | search |
49 | @@ -62,7 +62,7 @@ We are able to search languages with this method. | |||
50 | 62 | 62 | ||
51 | 63 | >>> languages = language_set.search('Spanish') | 63 | >>> languages = language_set.search('Spanish') |
52 | 64 | >>> for language in languages: | 64 | >>> for language in languages: |
54 | 65 | ... print language.code, language.englishname | 65 | ... print(language.code, language.englishname) |
55 | 66 | es Spanish | 66 | es Spanish |
56 | 67 | es_AR Spanish (Argentina) | 67 | es_AR Spanish (Argentina) |
57 | 68 | es_BO Spanish (Bolivia) | 68 | es_BO Spanish (Bolivia) |
58 | @@ -90,7 +90,7 @@ It's case insensitive: | |||
59 | 90 | 90 | ||
60 | 91 | >>> languages = language_set.search('spanish') | 91 | >>> languages = language_set.search('spanish') |
61 | 92 | >>> for language in languages: | 92 | >>> for language in languages: |
63 | 93 | ... print language.code, language.englishname | 93 | ... print(language.code, language.englishname) |
64 | 94 | es Spanish | 94 | es Spanish |
65 | 95 | es_AR Spanish (Argentina) | 95 | es_AR Spanish (Argentina) |
66 | 96 | es_BO Spanish (Bolivia) | 96 | es_BO Spanish (Bolivia) |
67 | @@ -118,7 +118,7 @@ And it even does substring searching! | |||
68 | 118 | 118 | ||
69 | 119 | >>> languages = language_set.search('panis') | 119 | >>> languages = language_set.search('panis') |
70 | 120 | >>> for language in languages: | 120 | >>> for language in languages: |
72 | 121 | ... print language.code, language.englishname | 121 | ... print(language.code, language.englishname) |
73 | 122 | es Spanish | 122 | es Spanish |
74 | 123 | es_AR Spanish (Argentina) | 123 | es_AR Spanish (Argentina) |
75 | 124 | es_BO Spanish (Bolivia) | 124 | es_BO Spanish (Bolivia) |
76 | @@ -147,14 +147,14 @@ matching any string: | |||
77 | 147 | 147 | ||
78 | 148 | >>> languages = language_set.search('%') | 148 | >>> languages = language_set.search('%') |
79 | 149 | >>> for language in languages: | 149 | >>> for language in languages: |
81 | 150 | ... print language.code, language.englishname | 150 | ... print(language.code, language.englishname) |
82 | 151 | 151 | ||
83 | 152 | Or '_', which means any character match, but we only get strings | 152 | Or '_', which means any character match, but we only get strings |
84 | 153 | that contain the 'e_' substring: | 153 | that contain the 'e_' substring: |
85 | 154 | 154 | ||
86 | 155 | >>> languages = language_set.search('e_') | 155 | >>> languages = language_set.search('e_') |
87 | 156 | >>> for language in languages: | 156 | >>> for language in languages: |
89 | 157 | ... print language.code, language.englishname | 157 | ... print(language.code, language.englishname) |
90 | 158 | de_AT German (Austria) | 158 | de_AT German (Austria) |
91 | 159 | de_BE German (Belgium) | 159 | de_BE German (Belgium) |
92 | 160 | de_DE German (Germany) | 160 | de_DE German (Germany) |
93 | @@ -177,23 +177,23 @@ second language. They might not be perfect but they are useful nonetheless. | |||
94 | 177 | pt_BR is not a descendent of pt: | 177 | pt_BR is not a descendent of pt: |
95 | 178 | 178 | ||
96 | 179 | >>> pt_BR = language_set.getLanguageByCode('pt_BR') | 179 | >>> pt_BR = language_set.getLanguageByCode('pt_BR') |
98 | 180 | >>> print pt_BR.alt_suggestion_language | 180 | >>> print(pt_BR.alt_suggestion_language) |
99 | 181 | None | 181 | None |
100 | 182 | 182 | ||
101 | 183 | However, es_MX would find es useful: | 183 | However, es_MX would find es useful: |
102 | 184 | 184 | ||
103 | 185 | >>> language = language_set.getLanguageByCode('es_MX') | 185 | >>> language = language_set.getLanguageByCode('es_MX') |
105 | 186 | >>> print language.alt_suggestion_language.code | 186 | >>> print(language.alt_suggestion_language.code) |
106 | 187 | es | 187 | es |
107 | 188 | 188 | ||
108 | 189 | And Nynorsk and Bokmal have a special relationship: | 189 | And Nynorsk and Bokmal have a special relationship: |
109 | 190 | 190 | ||
110 | 191 | >>> language = language_set.getLanguageByCode('nn') | 191 | >>> language = language_set.getLanguageByCode('nn') |
112 | 192 | >>> print language.alt_suggestion_language.code | 192 | >>> print(language.alt_suggestion_language.code) |
113 | 193 | nb | 193 | nb |
114 | 194 | 194 | ||
115 | 195 | >>> language = language_set.getLanguageByCode('nb') | 195 | >>> language = language_set.getLanguageByCode('nb') |
117 | 196 | >>> print language.alt_suggestion_language.code | 196 | >>> print(language.alt_suggestion_language.code) |
118 | 197 | nn | 197 | nn |
119 | 198 | 198 | ||
120 | 199 | English and non-visible languages are not translatable, so there | 199 | English and non-visible languages are not translatable, so there |
121 | @@ -224,7 +224,7 @@ represent, for instance pt_BR, when used on web pages, it should use | |||
122 | 224 | instead a dash char. This method does it automatically: | 224 | instead a dash char. This method does it automatically: |
123 | 225 | 225 | ||
124 | 226 | >>> pt_BR = language_set.getLanguageByCode('pt_BR') | 226 | >>> pt_BR = language_set.getLanguageByCode('pt_BR') |
126 | 227 | >>> print pt_BR.dashedcode | 227 | >>> print(pt_BR.dashedcode) |
127 | 228 | pt-BR | 228 | pt-BR |
128 | 229 | 229 | ||
129 | 230 | 230 | ||
130 | @@ -271,7 +271,7 @@ have the language among their preferred languages. | |||
131 | 271 | ... karmavalue=40) | 271 | ... karmavalue=40) |
132 | 272 | >>> switch_dbuser('launchpad') | 272 | >>> switch_dbuser('launchpad') |
133 | 273 | >>> for translator in sr.translators: | 273 | >>> for translator in sr.translators: |
135 | 274 | ... print translator.name | 274 | ... print(translator.name) |
136 | 275 | serbian-translator-karma-40 | 275 | serbian-translator-karma-40 |
137 | 276 | serbian-translator-karma-30 | 276 | serbian-translator-karma-30 |
138 | 277 | serbian-translator-karma-20 | 277 | serbian-translator-karma-20 |
139 | @@ -286,7 +286,7 @@ Property holding a list of countries a language is spoken in, and allowing | |||
140 | 286 | reading and setting them. | 286 | reading and setting them. |
141 | 287 | 287 | ||
142 | 288 | >>> es = language_set.getLanguageByCode('es') | 288 | >>> es = language_set.getLanguageByCode('es') |
144 | 289 | >>> print [country.name for country in es.countries] | 289 | >>> print([country.name for country in es.countries]) |
145 | 290 | [u'Argentina', u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', | 290 | [u'Argentina', u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', |
146 | 291 | u'Dominican Republic', u'Ecuador', u'El Salvador', u'Guatemala', | 291 | u'Dominican Republic', u'Ecuador', u'El Salvador', u'Guatemala', |
147 | 292 | u'Honduras', u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', | 292 | u'Honduras', u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', |
148 | @@ -298,7 +298,7 @@ We can add countries using `ILanguage.addCountry` method. | |||
149 | 298 | >>> country_set = getUtility(ICountrySet) | 298 | >>> country_set = getUtility(ICountrySet) |
150 | 299 | >>> germany = country_set['DE'] | 299 | >>> germany = country_set['DE'] |
151 | 300 | >>> es.addCountry(germany) | 300 | >>> es.addCountry(germany) |
153 | 301 | >>> print [country.name for country in es.countries] | 301 | >>> print([country.name for country in es.countries]) |
154 | 302 | [u'Argentina', u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', | 302 | [u'Argentina', u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', |
155 | 303 | u'Dominican Republic', u'Ecuador', u'El Salvador', u'Germany', u'Guatemala', | 303 | u'Dominican Republic', u'Ecuador', u'El Salvador', u'Germany', u'Guatemala', |
156 | 304 | u'Honduras', u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', | 304 | u'Honduras', u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', |
157 | @@ -308,7 +308,7 @@ Or, we can remove countries using `ILanguage.removeCountry` method. | |||
158 | 308 | 308 | ||
159 | 309 | >>> argentina = country_set['AR'] | 309 | >>> argentina = country_set['AR'] |
160 | 310 | >>> es.removeCountry(argentina) | 310 | >>> es.removeCountry(argentina) |
162 | 311 | >>> print [country.name for country in es.countries] | 311 | >>> print([country.name for country in es.countries]) |
163 | 312 | [u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', u'Dominican Republic', | 312 | [u'Bolivia', u'Chile', u'Colombia', u'Costa Rica', u'Dominican Republic', |
164 | 313 | u'Ecuador', u'El Salvador', u'Germany', u'Guatemala', u'Honduras', | 313 | u'Ecuador', u'El Salvador', u'Germany', u'Guatemala', u'Honduras', |
165 | 314 | u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', u'Puerto Rico', | 314 | u'Mexico', u'Nicaragua', u'Panama', u'Paraguay', u'Peru', u'Puerto Rico', |
166 | @@ -319,5 +319,5 @@ but we need to log in as a translations administrator first. | |||
167 | 319 | 319 | ||
168 | 320 | >>> login('carlos@canonical.com') | 320 | >>> login('carlos@canonical.com') |
169 | 321 | >>> es.countries = set([argentina, germany]) | 321 | >>> es.countries = set([argentina, germany]) |
171 | 322 | >>> print [country.name for country in es.countries] | 322 | >>> print([country.name for country in es.countries]) |
172 | 323 | [u'Argentina', u'Germany'] | 323 | [u'Argentina', u'Germany'] |
173 | diff --git a/lib/lp/services/worlddata/doc/vocabularies.txt b/lib/lp/services/worlddata/doc/vocabularies.txt | |||
174 | index 2800395..ab100ea 100644 | |||
175 | --- a/lib/lp/services/worlddata/doc/vocabularies.txt | |||
176 | +++ b/lib/lp/services/worlddata/doc/vocabularies.txt | |||
177 | @@ -34,20 +34,20 @@ All the languages known by Launchpad. | |||
178 | 34 | 34 | ||
179 | 35 | >>> es = language_set['es'] | 35 | >>> es = language_set['es'] |
180 | 36 | >>> term = language_vocabulary.getTerm(es) | 36 | >>> term = language_vocabulary.getTerm(es) |
182 | 37 | >>> print term.token, term.value.displayname, term.title | 37 | >>> print(term.token, term.value.displayname, term.title) |
183 | 38 | es Spanish (es) Spanish (es) | 38 | es Spanish (es) Spanish (es) |
184 | 39 | 39 | ||
185 | 40 | >>> pt_BR = language_set['pt_BR'] | 40 | >>> pt_BR = language_set['pt_BR'] |
186 | 41 | >>> term = language_vocabulary.getTerm(pt_BR) | 41 | >>> term = language_vocabulary.getTerm(pt_BR) |
188 | 42 | >>> print term.token, term.value.displayname, term.title | 42 | >>> print(term.token, term.value.displayname, term.title) |
189 | 43 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) | 43 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) |
190 | 44 | 44 | ||
191 | 45 | >>> term = language_vocabulary.getTermByToken('es') | 45 | >>> term = language_vocabulary.getTermByToken('es') |
193 | 46 | >>> print term.token, term.value.displayname, term.title | 46 | >>> print(term.token, term.value.displayname, term.title) |
194 | 47 | es Spanish (es) Spanish (es) | 47 | es Spanish (es) Spanish (es) |
195 | 48 | 48 | ||
196 | 49 | >>> term = language_vocabulary.getTermByToken('pt_BR') | 49 | >>> term = language_vocabulary.getTermByToken('pt_BR') |
198 | 50 | >>> print term.token, term.value.displayname, term.title | 50 | >>> print(term.token, term.value.displayname, term.title) |
199 | 51 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) | 51 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) |
200 | 52 | 52 | ||
201 | 53 | A language token/code may not be used with 'in' tests. | 53 | A language token/code may not be used with 'in' tests. |
202 | @@ -81,20 +81,20 @@ when the language is not English and is visible. | |||
203 | 81 | 81 | ||
204 | 82 | >>> es = language_set['es'] | 82 | >>> es = language_set['es'] |
205 | 83 | >>> term = translatable_language_vocabulary.getTerm(es) | 83 | >>> term = translatable_language_vocabulary.getTerm(es) |
207 | 84 | >>> print term.token, term.value.displayname, term.title | 84 | >>> print(term.token, term.value.displayname, term.title) |
208 | 85 | es Spanish (es) Spanish (es) | 85 | es Spanish (es) Spanish (es) |
209 | 86 | 86 | ||
210 | 87 | >>> pt_BR = language_set['pt_BR'] | 87 | >>> pt_BR = language_set['pt_BR'] |
211 | 88 | >>> term = translatable_language_vocabulary.getTerm(pt_BR) | 88 | >>> term = translatable_language_vocabulary.getTerm(pt_BR) |
213 | 89 | >>> print term.token, term.value.displayname, term.title | 89 | >>> print(term.token, term.value.displayname, term.title) |
214 | 90 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) | 90 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) |
215 | 91 | 91 | ||
216 | 92 | >>> term = translatable_language_vocabulary.getTermByToken('es') | 92 | >>> term = translatable_language_vocabulary.getTermByToken('es') |
218 | 93 | >>> print term.token, term.value.displayname, term.title | 93 | >>> print(term.token, term.value.displayname, term.title) |
219 | 94 | es Spanish (es) Spanish (es) | 94 | es Spanish (es) Spanish (es) |
220 | 95 | 95 | ||
221 | 96 | >>> term = translatable_language_vocabulary.getTermByToken('pt_BR') | 96 | >>> term = translatable_language_vocabulary.getTermByToken('pt_BR') |
223 | 97 | >>> print term.token, term.value.displayname, term.title | 97 | >>> print(term.token, term.value.displayname, term.title) |
224 | 98 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) | 98 | pt_BR Portuguese (Brazil) (pt_BR) Portuguese (Brazil) (pt_BR) |
225 | 99 | 99 | ||
226 | 100 | >>> es in translatable_language_vocabulary | 100 | >>> es in translatable_language_vocabulary |
227 | diff --git a/lib/lp/services/worlddata/helpers.py b/lib/lp/services/worlddata/helpers.py | |||
228 | index 18c38c4..4c7643d 100644 | |||
229 | --- a/lib/lp/services/worlddata/helpers.py | |||
230 | +++ b/lib/lp/services/worlddata/helpers.py | |||
231 | @@ -3,6 +3,8 @@ | |||
232 | 3 | 3 | ||
233 | 4 | """Worlddata helper functions.""" | 4 | """Worlddata helper functions.""" |
234 | 5 | 5 | ||
235 | 6 | from __future__ import absolute_import, print_function, unicode_literals | ||
236 | 7 | |||
237 | 6 | __metaclass__ = type | 8 | __metaclass__ = type |
238 | 7 | __all__ = [ | 9 | __all__ = [ |
239 | 8 | 'browser_languages', | 10 | 'browser_languages', |
240 | diff --git a/lib/lp/services/worlddata/interfaces/country.py b/lib/lp/services/worlddata/interfaces/country.py | |||
241 | index a7e087a..1ded91a 100644 | |||
242 | --- a/lib/lp/services/worlddata/interfaces/country.py | |||
243 | +++ b/lib/lp/services/worlddata/interfaces/country.py | |||
244 | @@ -3,6 +3,8 @@ | |||
245 | 3 | 3 | ||
246 | 4 | """Country interfaces.""" | 4 | """Country interfaces.""" |
247 | 5 | 5 | ||
248 | 6 | from __future__ import absolute_import, print_function, unicode_literals | ||
249 | 7 | |||
250 | 6 | __metaclass__ = type | 8 | __metaclass__ = type |
251 | 7 | 9 | ||
252 | 8 | __all__ = [ | 10 | __all__ = [ |
253 | diff --git a/lib/lp/services/worlddata/interfaces/language.py b/lib/lp/services/worlddata/interfaces/language.py | |||
254 | index a283c97..c2ba6af 100644 | |||
255 | --- a/lib/lp/services/worlddata/interfaces/language.py | |||
256 | +++ b/lib/lp/services/worlddata/interfaces/language.py | |||
257 | @@ -3,6 +3,8 @@ | |||
258 | 3 | 3 | ||
259 | 4 | """Language interfaces.""" | 4 | """Language interfaces.""" |
260 | 5 | 5 | ||
261 | 6 | from __future__ import absolute_import, print_function, unicode_literals | ||
262 | 7 | |||
263 | 6 | __metaclass__ = type | 8 | __metaclass__ = type |
264 | 7 | 9 | ||
265 | 8 | __all__ = [ | 10 | __all__ = [ |
266 | diff --git a/lib/lp/services/worlddata/interfaces/spokenin.py b/lib/lp/services/worlddata/interfaces/spokenin.py | |||
267 | index d9d5818..6546067 100644 | |||
268 | --- a/lib/lp/services/worlddata/interfaces/spokenin.py | |||
269 | +++ b/lib/lp/services/worlddata/interfaces/spokenin.py | |||
270 | @@ -5,6 +5,8 @@ | |||
271 | 5 | countries.. | 5 | countries.. |
272 | 6 | """ | 6 | """ |
273 | 7 | 7 | ||
274 | 8 | from __future__ import absolute_import, print_function, unicode_literals | ||
275 | 9 | |||
276 | 8 | __metaclass__ = type | 10 | __metaclass__ = type |
277 | 9 | 11 | ||
278 | 10 | __all__ = ['ISpokenIn'] | 12 | __all__ = ['ISpokenIn'] |
279 | diff --git a/lib/lp/services/worlddata/interfaces/timezone.py b/lib/lp/services/worlddata/interfaces/timezone.py | |||
280 | index 435e503..25ed2ab 100644 | |||
281 | --- a/lib/lp/services/worlddata/interfaces/timezone.py | |||
282 | +++ b/lib/lp/services/worlddata/interfaces/timezone.py | |||
283 | @@ -1,6 +1,8 @@ | |||
284 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the |
285 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
286 | 3 | 3 | ||
287 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
288 | 5 | |||
289 | 4 | __metaclass__ = type | 6 | __metaclass__ = type |
290 | 5 | __all__ = [ | 7 | __all__ = [ |
291 | 6 | 'ITimezoneNameVocabulary', | 8 | 'ITimezoneNameVocabulary', |
292 | diff --git a/lib/lp/services/worlddata/interfaces/webservice.py b/lib/lp/services/worlddata/interfaces/webservice.py | |||
293 | index 009ffca..dc3b900 100644 | |||
294 | --- a/lib/lp/services/worlddata/interfaces/webservice.py | |||
295 | +++ b/lib/lp/services/worlddata/interfaces/webservice.py | |||
296 | @@ -9,6 +9,8 @@ There is a declaration in ZCML somewhere that looks like: | |||
297 | 9 | which tells `lazr.restful` that it should look for webservice exports here. | 9 | which tells `lazr.restful` that it should look for webservice exports here. |
298 | 10 | """ | 10 | """ |
299 | 11 | 11 | ||
300 | 12 | from __future__ import absolute_import, print_function, unicode_literals | ||
301 | 13 | |||
302 | 12 | __all__ = [ | 14 | __all__ = [ |
303 | 13 | 'ICountry', | 15 | 'ICountry', |
304 | 14 | 'ICountrySet', | 16 | 'ICountrySet', |
305 | diff --git a/lib/lp/services/worlddata/model/country.py b/lib/lp/services/worlddata/model/country.py | |||
306 | index 55ca6dd..387a84a 100644 | |||
307 | --- a/lib/lp/services/worlddata/model/country.py | |||
308 | +++ b/lib/lp/services/worlddata/model/country.py | |||
309 | @@ -1,9 +1,12 @@ | |||
310 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the |
311 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
312 | 3 | 3 | ||
313 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
314 | 5 | |||
315 | 4 | __metaclass__ = type | 6 | __metaclass__ = type |
316 | 5 | __all__ = ['Country', 'CountrySet', 'Continent'] | 7 | __all__ = ['Country', 'CountrySet', 'Continent'] |
317 | 6 | 8 | ||
318 | 9 | import six | ||
319 | 7 | from sqlobject import ( | 10 | from sqlobject import ( |
320 | 8 | ForeignKey, | 11 | ForeignKey, |
321 | 9 | SQLRelatedJoin, | 12 | SQLRelatedJoin, |
322 | @@ -42,8 +45,8 @@ class Country(SQLBase): | |||
323 | 42 | continent = ForeignKey( | 45 | continent = ForeignKey( |
324 | 43 | dbName='continent', foreignKey='Continent', default=None) | 46 | dbName='continent', foreignKey='Continent', default=None) |
325 | 44 | languages = SQLRelatedJoin( | 47 | languages = SQLRelatedJoin( |
328 | 45 | 'Language', joinColumn='country', otherColumn='language', | 48 | six.ensure_str('Language'), joinColumn='country', |
329 | 46 | intermediateTable='SpokenIn') | 49 | otherColumn='language', intermediateTable='SpokenIn') |
330 | 47 | 50 | ||
331 | 48 | 51 | ||
332 | 49 | @implementer(ICountrySet) | 52 | @implementer(ICountrySet) |
333 | diff --git a/lib/lp/services/worlddata/model/language.py b/lib/lp/services/worlddata/model/language.py | |||
334 | index 245a686..9142207 100644 | |||
335 | --- a/lib/lp/services/worlddata/model/language.py | |||
336 | +++ b/lib/lp/services/worlddata/model/language.py | |||
337 | @@ -2,6 +2,8 @@ | |||
338 | 2 | # the GNU Affero General Public License version 3 (see the file | 2 | # the GNU Affero General Public License version 3 (see the file |
339 | 3 | # LICENSE). | 3 | # LICENSE). |
340 | 4 | 4 | ||
341 | 5 | from __future__ import absolute_import, print_function, unicode_literals | ||
342 | 6 | |||
343 | 5 | __metaclass__ = type | 7 | __metaclass__ = type |
344 | 6 | __all__ = [ | 8 | __all__ = [ |
345 | 7 | 'Language', | 9 | 'Language', |
346 | @@ -67,12 +69,12 @@ class Language(SQLBase): | |||
347 | 67 | default=TextDirection.LTR) | 69 | default=TextDirection.LTR) |
348 | 68 | 70 | ||
349 | 69 | translation_teams = SQLRelatedJoin( | 71 | translation_teams = SQLRelatedJoin( |
351 | 70 | 'Person', joinColumn="language", | 72 | six.ensure_str('Person'), joinColumn="language", |
352 | 71 | intermediateTable='Translator', otherColumn='translator') | 73 | intermediateTable='Translator', otherColumn='translator') |
353 | 72 | 74 | ||
354 | 73 | _countries = SQLRelatedJoin( | 75 | _countries = SQLRelatedJoin( |
357 | 74 | 'Country', joinColumn='language', otherColumn='country', | 76 | six.ensure_str('Country'), joinColumn='language', |
358 | 75 | intermediateTable='SpokenIn') | 77 | otherColumn='country', intermediateTable='SpokenIn') |
359 | 76 | 78 | ||
360 | 77 | # Define a read/write property `countries` so it can be passed | 79 | # Define a read/write property `countries` so it can be passed |
361 | 78 | # to language administration `LaunchpadFormView`. | 80 | # to language administration `LaunchpadFormView`. |
362 | diff --git a/lib/lp/services/worlddata/model/spokenin.py b/lib/lp/services/worlddata/model/spokenin.py | |||
363 | index ab51568..6d2f06c 100644 | |||
364 | --- a/lib/lp/services/worlddata/model/spokenin.py | |||
365 | +++ b/lib/lp/services/worlddata/model/spokenin.py | |||
366 | @@ -1,6 +1,8 @@ | |||
367 | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009 Canonical Ltd. This software is licensed under the |
368 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
369 | 3 | 3 | ||
370 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
371 | 5 | |||
372 | 4 | __metaclass__ = type | 6 | __metaclass__ = type |
373 | 5 | __all__ = ['SpokenIn'] | 7 | __all__ = ['SpokenIn'] |
374 | 6 | 8 | ||
375 | diff --git a/lib/lp/services/worlddata/stories/webservice/xx-country.txt b/lib/lp/services/worlddata/stories/webservice/xx-country.txt | |||
376 | index 05d8db0..d2aba2d 100644 | |||
377 | --- a/lib/lp/services/worlddata/stories/webservice/xx-country.txt | |||
378 | +++ b/lib/lp/services/worlddata/stories/webservice/xx-country.txt | |||
379 | @@ -4,7 +4,7 @@ At the top level we provide the collection of all countries. | |||
380 | 4 | 4 | ||
381 | 5 | >>> countries = webservice.get("/+countries").jsonBody() | 5 | >>> countries = webservice.get("/+countries").jsonBody() |
382 | 6 | >>> for entry in countries['entries']: | 6 | >>> for entry in countries['entries']: |
384 | 7 | ... print entry['self_link'] | 7 | ... print(entry['self_link']) |
385 | 8 | http://.../+countries/AD | 8 | http://.../+countries/AD |
386 | 9 | http://.../+countries/AE | 9 | http://.../+countries/AE |
387 | 10 | http://.../+countries/AF | 10 | http://.../+countries/AF |
388 | @@ -28,7 +28,7 @@ And for every country we publish most of its attributes. | |||
389 | 28 | Make sure that invalid countries return 404s and not OOPSes. | 28 | Make sure that invalid countries return 404s and not OOPSes. |
390 | 29 | 29 | ||
391 | 30 | >>> bogus_country = "http://api.launchpad.test/beta/+countries/bogus" | 30 | >>> bogus_country = "http://api.launchpad.test/beta/+countries/bogus" |
393 | 31 | >>> print webservice.get(bogus_country) | 31 | >>> print(webservice.get(bogus_country)) |
394 | 32 | HTTP/1.1 404 Not Found | 32 | HTTP/1.1 404 Not Found |
395 | 33 | ... | 33 | ... |
396 | 34 | Object: ..., name: u'bogus' | 34 | Object: ..., name: u'bogus' |
397 | @@ -40,7 +40,7 @@ Make sure that invalid countries return 404s and not OOPSes. | |||
398 | 40 | >>> uk = webservice.named_get( | 40 | >>> uk = webservice.named_get( |
399 | 41 | ... '/+countries', 'getByName', | 41 | ... '/+countries', 'getByName', |
400 | 42 | ... name='United Kingdom').jsonBody() | 42 | ... name='United Kingdom').jsonBody() |
402 | 43 | >>> print uk['self_link'] | 43 | >>> print(uk['self_link']) |
403 | 44 | http://.../+countries/GB | 44 | http://.../+countries/GB |
404 | 45 | 45 | ||
405 | 46 | Ensure that unknown/non-existent countries return a None and not an OOPS: | 46 | Ensure that unknown/non-existent countries return a None and not an OOPS: |
406 | @@ -48,7 +48,7 @@ Ensure that unknown/non-existent countries return a None and not an OOPS: | |||
407 | 48 | >>> bogus_country_by_name = webservice.named_get( | 48 | >>> bogus_country_by_name = webservice.named_get( |
408 | 49 | ... '/+countries', 'getByName', | 49 | ... '/+countries', 'getByName', |
409 | 50 | ... name='Klingon Land').jsonBody() | 50 | ... name='Klingon Land').jsonBody() |
411 | 51 | >>> print bogus_country_by_name | 51 | >>> print(bogus_country_by_name) |
412 | 52 | None | 52 | None |
413 | 53 | 53 | ||
414 | 54 | 54 | ||
415 | @@ -57,7 +57,7 @@ Ensure that unknown/non-existent countries return a None and not an OOPS: | |||
416 | 57 | >>> au = webservice.named_get( | 57 | >>> au = webservice.named_get( |
417 | 58 | ... '/+countries', 'getByCode', | 58 | ... '/+countries', 'getByCode', |
418 | 59 | ... code='AU').jsonBody() | 59 | ... code='AU').jsonBody() |
420 | 60 | >>> print au['self_link'] | 60 | >>> print(au['self_link']) |
421 | 61 | http://.../+countries/AU | 61 | http://.../+countries/AU |
422 | 62 | 62 | ||
423 | 63 | Ensure that unknown/non-existent country codes return a None and not an OOPS: | 63 | Ensure that unknown/non-existent country codes return a None and not an OOPS: |
424 | @@ -65,5 +65,5 @@ Ensure that unknown/non-existent country codes return a None and not an OOPS: | |||
425 | 65 | >>> bogus_country_by_code = webservice.named_get( | 65 | >>> bogus_country_by_code = webservice.named_get( |
426 | 66 | ... '/+countries', 'getByCode', | 66 | ... '/+countries', 'getByCode', |
427 | 67 | ... code='TEST').jsonBody() | 67 | ... code='TEST').jsonBody() |
429 | 68 | >>> print bogus_country_by_code | 68 | >>> print(bogus_country_by_code) |
430 | 69 | None | 69 | None |
431 | diff --git a/lib/lp/services/worlddata/stories/webservice/xx-language.txt b/lib/lp/services/worlddata/stories/webservice/xx-language.txt | |||
432 | index 05401ce..56484ae 100644 | |||
433 | --- a/lib/lp/services/worlddata/stories/webservice/xx-language.txt | |||
434 | +++ b/lib/lp/services/worlddata/stories/webservice/xx-language.txt | |||
435 | @@ -10,19 +10,19 @@ The language information from Launchpad can be queried using | |||
436 | 10 | >>> es = anon_webservice.get('/+languages/es').jsonBody() | 10 | >>> es = anon_webservice.get('/+languages/es').jsonBody() |
437 | 11 | >>> es['resource_type_link'] | 11 | >>> es['resource_type_link'] |
438 | 12 | u'http.../#language' | 12 | u'http.../#language' |
440 | 13 | >>> print es['text_direction'] | 13 | >>> print(es['text_direction']) |
441 | 14 | Left to Right | 14 | Left to Right |
443 | 15 | >>> print es['code'] | 15 | >>> print(es['code']) |
444 | 16 | es | 16 | es |
446 | 17 | >>> print es['english_name'] | 17 | >>> print(es['english_name']) |
447 | 18 | Spanish | 18 | Spanish |
449 | 19 | >>> print es['plural_expression'] | 19 | >>> print(es['plural_expression']) |
450 | 20 | n != 1 | 20 | n != 1 |
452 | 21 | >>> print es['plural_forms'] | 21 | >>> print(es['plural_forms']) |
453 | 22 | 2 | 22 | 2 |
455 | 23 | >>> print es['translators_count'] | 23 | >>> print(es['translators_count']) |
456 | 24 | 1 | 24 | 1 |
458 | 25 | >>> print es['visible'] | 25 | >>> print(es['visible']) |
459 | 26 | True | 26 | True |
460 | 27 | 27 | ||
461 | 28 | 28 | ||
462 | @@ -45,7 +45,7 @@ at '/+languages'. | |||
463 | 45 | >>> default_languages['resource_type_link'] | 45 | >>> default_languages['resource_type_link'] |
464 | 46 | u'http.../#languages' | 46 | u'http.../#languages' |
465 | 47 | >>> languages = get_languages_entries(default_languages) | 47 | >>> languages = get_languages_entries(default_languages) |
467 | 48 | >>> print languages | 48 | >>> print(languages) |
468 | 49 | Abkhazian | 49 | Abkhazian |
469 | 50 | ... | 50 | ... |
470 | 51 | >>> '(hidden)' in languages | 51 | >>> '(hidden)' in languages |
471 | @@ -60,7 +60,7 @@ default. | |||
472 | 60 | ... '/+languages?' | 60 | ... '/+languages?' |
473 | 61 | ... 'ws.op=getAllLanguages&ws.start=0&ws.size=10' | 61 | ... 'ws.op=getAllLanguages&ws.start=0&ws.size=10' |
474 | 62 | ... ).jsonBody() | 62 | ... ).jsonBody() |
476 | 63 | >>> print get_languages_entries(all_languages) | 63 | >>> print(get_languages_entries(all_languages)) |
477 | 64 | Abkhazian | 64 | Abkhazian |
478 | 65 | ... | 65 | ... |
479 | 66 | Afar (Djibouti)(hidden) | 66 | Afar (Djibouti)(hidden) |
480 | diff --git a/lib/lp/services/worlddata/tests/test_doc.py b/lib/lp/services/worlddata/tests/test_doc.py | |||
481 | index 3754618..39f6412 100644 | |||
482 | --- a/lib/lp/services/worlddata/tests/test_doc.py | |||
483 | +++ b/lib/lp/services/worlddata/tests/test_doc.py | |||
484 | @@ -5,10 +5,13 @@ | |||
485 | 5 | Run the doctests and pagetests. | 5 | Run the doctests and pagetests. |
486 | 6 | """ | 6 | """ |
487 | 7 | 7 | ||
488 | 8 | from __future__ import absolute_import, print_function, unicode_literals | ||
489 | 9 | |||
490 | 8 | import os | 10 | import os |
491 | 9 | 11 | ||
492 | 10 | from lp.services.testing import build_test_suite | 12 | from lp.services.testing import build_test_suite |
493 | 11 | from lp.testing.layers import LaunchpadZopelessLayer | 13 | from lp.testing.layers import LaunchpadZopelessLayer |
494 | 14 | from lp.testing.pages import setUpGlobs | ||
495 | 12 | from lp.testing.systemdocs import ( | 15 | from lp.testing.systemdocs import ( |
496 | 13 | LayeredDocFileSuite, | 16 | LayeredDocFileSuite, |
497 | 14 | setUp, | 17 | setUp, |
498 | @@ -21,9 +24,11 @@ special = { | |||
499 | 21 | 'language.txt': LayeredDocFileSuite( | 24 | 'language.txt': LayeredDocFileSuite( |
500 | 22 | '../doc/language.txt', | 25 | '../doc/language.txt', |
501 | 23 | layer=LaunchpadZopelessLayer, | 26 | layer=LaunchpadZopelessLayer, |
503 | 24 | setUp=setUp, tearDown=tearDown), | 27 | setUp=lambda test: setUp(test, future=True), tearDown=tearDown), |
504 | 25 | } | 28 | } |
505 | 26 | 29 | ||
506 | 27 | 30 | ||
507 | 28 | def test_suite(): | 31 | def test_suite(): |
509 | 29 | return build_test_suite(here, special) | 32 | return build_test_suite( |
510 | 33 | here, special, setUp=lambda test: setUp(test, future=True), | ||
511 | 34 | pageTestsSetUp=lambda test: setUpGlobs(test, future=True)) | ||
512 | diff --git a/lib/lp/services/worlddata/tests/test_helpers.py b/lib/lp/services/worlddata/tests/test_helpers.py | |||
513 | index a129604..a3b8429 100644 | |||
514 | --- a/lib/lp/services/worlddata/tests/test_helpers.py | |||
515 | +++ b/lib/lp/services/worlddata/tests/test_helpers.py | |||
516 | @@ -1,6 +1,8 @@ | |||
517 | 1 | # Copyright 2011 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2011 Canonical Ltd. This software is licensed under the |
518 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
519 | 3 | 3 | ||
520 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
521 | 5 | |||
522 | 4 | from doctest import DocTestSuite | 6 | from doctest import DocTestSuite |
523 | 5 | import unittest | 7 | import unittest |
524 | 6 | 8 | ||
525 | @@ -119,8 +121,8 @@ def test_preferred_or_request_languages(): | |||
526 | 119 | >>> languages = preferred_or_request_languages(DummyRequest()) | 121 | >>> languages = preferred_or_request_languages(DummyRequest()) |
527 | 120 | >>> len(languages) | 122 | >>> len(languages) |
528 | 121 | 1 | 123 | 1 |
531 | 122 | >>> languages[0].code | 124 | >>> print(languages[0].code) |
532 | 123 | 'es' | 125 | es |
533 | 124 | 126 | ||
534 | 125 | >>> tearDown() | 127 | >>> tearDown() |
535 | 126 | 128 | ||
536 | @@ -141,8 +143,8 @@ def test_preferred_or_request_languages(): | |||
537 | 141 | >>> languages = preferred_or_request_languages(DummyRequest()) | 143 | >>> languages = preferred_or_request_languages(DummyRequest()) |
538 | 142 | >>> len(languages) | 144 | >>> len(languages) |
539 | 143 | 6 | 145 | 6 |
542 | 144 | >>> languages[0].code | 146 | >>> print(languages[0].code) |
543 | 145 | 'ja' | 147 | ja |
544 | 146 | 148 | ||
545 | 147 | >>> tearDown() | 149 | >>> tearDown() |
546 | 148 | ''' | 150 | ''' |
547 | diff --git a/lib/lp/services/worlddata/tests/test_language.py b/lib/lp/services/worlddata/tests/test_language.py | |||
548 | index b5eafea..797d3d2 100644 | |||
549 | --- a/lib/lp/services/worlddata/tests/test_language.py | |||
550 | +++ b/lib/lp/services/worlddata/tests/test_language.py | |||
551 | @@ -1,6 +1,8 @@ | |||
552 | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2010 Canonical Ltd. This software is licensed under the |
553 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
554 | 3 | 3 | ||
555 | 4 | from __future__ import absolute_import, print_function, unicode_literals | ||
556 | 5 | |||
557 | 4 | __metaclass__ = type | 6 | __metaclass__ = type |
558 | 5 | 7 | ||
559 | 6 | from lazr.lifecycle.interfaces import IDoNotSnapshot | 8 | from lazr.lifecycle.interfaces import IDoNotSnapshot |
LGTM