Index: trunk/pywikipedia/category.py |
— | — | @@ -408,7 +408,7 @@ |
409 | 409 | if current_cat == original_cat: |
410 | 410 | print 'No changes necessary.' |
411 | 411 | else: |
412 | | - catlib.change_category(article, original_cat.catname(), current_cat.catname()) |
| 412 | + catlib.change_category(article, original_cat.titleWithoutNamespace(), current_cat.titleWithoutNamespace()) |
413 | 413 | flag = True |
414 | 414 | elif choice == 'j': |
415 | 415 | newCatTitle = wikipedia.input(u'Please enter the category the article should be moved to:') |
— | — | @@ -418,7 +418,7 @@ |
419 | 419 | flag = True |
420 | 420 | elif choice == 'r': |
421 | 421 | # remove the category tag |
422 | | - catlib.change_category(article, original_cat.catname(), None) |
| 422 | + catlib.change_category(article, original_cat.titleWithoutNamespace(), None) |
423 | 423 | flag = True |
424 | 424 | elif choice == '?': |
425 | 425 | print '' |
Index: trunk/pywikipedia/catlib.py |
— | — | @@ -265,7 +265,7 @@ |
266 | 266 | cats.remove(cat) |
267 | 267 | removed = True |
268 | 268 | elif cattext.startswith(old_cat_title + '|'): |
269 | | - sort_key = cat.catname().split('|', 1)[1] |
| 269 | + sort_key = cat.titleWithoutNamespace().split('|', 1)[1] |
270 | 270 | cats.remove(cat) |
271 | 271 | removed = True |
272 | 272 | if not removed: |
Index: trunk/pywikipedia/wikipedia.py |
— | — | @@ -138,9 +138,6 @@ |
139 | 139 | class SectionError(ValueError): |
140 | 140 | """The section specified by # does not exist""" |
141 | 141 | |
142 | | -class NoNamespace(Error): |
143 | | - """Page is not in a special namespace""" |
144 | | - |
145 | 142 | class PageNotSaved(Error): |
146 | 143 | """ Saving the page has failed """ |
147 | 144 | |
— | — | @@ -240,16 +237,17 @@ |
241 | 238 | """The name of this Page, as a Unicode string""" |
242 | 239 | return self._title |
243 | 240 | |
244 | | - def catname(self): |
| 241 | + def titleWithoutNamespace(self): |
245 | 242 | """The name of the page without the namespace part. Gives an error |
246 | 243 | if the page is from the main namespace. Note that this is a raw way |
247 | 244 | of doing things - it simply looks for a : in the name.""" |
248 | 245 | t=self.sectionFreeTitle() |
249 | | - p=t.split(':') |
250 | | - p=p[1:] |
251 | | - if p==[]: |
252 | | - raise NoNamespace(self) |
253 | | - return ':'.join(p) |
| 246 | + p=t.split(':', 1) |
| 247 | + if len(p) == 1: |
| 248 | + # page is in the main namespace |
| 249 | + return p[0] |
| 250 | + else: |
| 251 | + return p[1] |
254 | 252 | |
255 | 253 | def section(self): |
256 | 254 | """The name of the section this Page refers to. Sections are |