Wiktionary:Entries needing topical attention/bot code

''' Copyright (c) 2009 Betacommand.

Modified.

Copyright (c) 2009 NicDumZ.

Modified.

Copyright (c) 2014 msh210.

The copyright holders have licensed the code under the following license:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

parameter to any of these templates:' msg += u'\n,, , , ,' msg += u'\n,, , , ,' msg += u'\n,, , ,' msg += u'\n,, , .' msg += u'\n\n{|class=\'wikitable sortable\'\n' msg += u'!page!!topic!!language code' cat = catlib.Category(site,'Category:Entries needing topical attention') gen = pagegenerators.CategorizedPageGenerator(cat) reTemplate = re.compile('\{\{((rf|question|tearoom|look)[^}]*?lang=(?P [^}]*?)\|[^}]*?topic=(?P .*?)[|}]|(rf|question|tearoom|look)[^}]*?topic=(?P .*?)(\|[^}]*?lang=(?P .*?))?[|}]|attention\|(?P [^}]*?)\|.*?topic=(?P .*?)[|}]|attention\|topic=(?P [^}]*?)\|(?P [^=]*?)[|}])', re.I) for page in pagegenerators.PreloadingGenerator(gen): try: text = page.get for match in reTemplate.finditer(text): if match.group('topic'): topic = match.group('topic') elif match.group('topic2'): topic = match.group('topic2') elif match.group('topic3'): topic = match.group('topic3') elif match.group('topic4'): topic = match.group('topic4') else: topic = ' ' if match.group('langcode'): langcode = match.group('langcode') elif match.group('langcode2'): langcode = match.group('langcode2') elif match.group('langcode3'): langcode = match.group('langcode3') elif match.group('langcode4'): langcode = match.group('langcode4') else: langcode = '' msg += u'\n|-\n|'+page.title+'||'+topic+'||'+langcode flib += 1 except: pass logpage = wikipedia.Page(site,'Wiktionary:Entries needing topical attention') msg += u'\n|}' try: oldtext = logpage.get except: oldtext = u'' logpage.put(msg,comment='Update, '+str(flib)+' lines (bot)') if __name__ == "__main__": try: main finally: wikipedia.stopme
 * 1) Many thanks to Betacommand and NicDumZ.
 * 1) Many thanks to Betacommand and NicDumZ.