Index: trunk/pywikipedia/fixing_redirects.py |
— | — | @@ -122,10 +122,18 @@ |
123 | 123 | continue |
124 | 124 | replaceit = choice in "rR" |
125 | 125 | |
| 126 | + # remove preleading ":" |
| 127 | + if link_text[0]==':': |
| 128 | + link_text = link_text[1:] |
126 | 129 | if link_text[0].isupper(): |
127 | 130 | new_page_title = targetPage.title() |
128 | 131 | else: |
129 | 132 | new_page_title = targetPage.title()[0].lower() + targetPage.title()[1:] |
| 133 | + |
| 134 | + # remove preleading ":" |
| 135 | + if new_page_title[0]==':': |
| 136 | + new_page_title = new_page_title[1:] |
| 137 | + |
130 | 138 | if replaceit and trailing_chars: |
131 | 139 | newlink = "[[%s%s]]%s" % (new_page_title, section, trailing_chars) |
132 | 140 | elif replaceit or (new_page_title == link_text and not section): |
— | — | @@ -146,13 +154,17 @@ |
147 | 155 | try: |
148 | 156 | text = page.get() |
149 | 157 | except wikipedia.IsRedirectPage: |
| 158 | + wikipedia.output(u'%s is a redirect page. Skipping' % page.aslink()) |
150 | 159 | return |
| 160 | + except wikipedia.NoPage: |
| 161 | + wikipedia.output(u'%s does not exist. Skipping' % page.aslink()) |
| 162 | + return |
151 | 163 | wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) |
152 | 164 | links = page.linkedPages() |
153 | 165 | if len(links) > 0: |
154 | 166 | wikipedia.getall(mysite,links) |
155 | 167 | else: |
156 | | - wikipedia.output('No any links.') |
| 168 | + wikipedia.output('Nothing left to do.') |
157 | 169 | return |
158 | 170 | |
159 | 171 | for page2 in links: |