def gen_all_lang(): result = set() for lang in pywikibot_utils.get_all_lang('wikisource'): result.add(lang) return result
'%(code)s': ( %(page_ns)d, "%(Proofread)s", "%(Validated)s", "%(Without_text)s", "%(Problematic)s", ), """ % format_dict text += u"}\n" return text if __name__ == "__main__": langs = pywikibot_utils.get_all_lang('wikisource') text = gen_ws_category(langs) #print text.encode('utf-8') target = os.path.expanduser('~/wikisource/ws_category.py') old_text = '' if os.path.exists(target): fd = open(target, 'r') old_text = fd.read() fd.close() if unicode(old_text, 'utf-8') != text: print "writing file, no server needs a restart" fd = open(target, 'w') fd.write(text.encode('utf-8')) fd.close()
%(page_ns)d, "%(Proofread)s", "%(Validated)s", "%(Without_text)s", "%(Problematic)s", ), """ % format_dict text += u"}\n" return text if __name__ == "__main__": langs = pywikibot_utils.get_all_lang('wikisource') text = gen_ws_category(langs) #print text.encode('utf-8') target = os.path.expanduser('~/wikisource/ws_category.py') old_text = '' if os.path.exists(target): fd = open(target, 'r') old_text = fd.read() fd.close() if unicode(old_text, 'utf-8') != text: print "writing file, no server needs a restart" fd = open(target, 'w') fd.write(text.encode('utf-8')) fd.close()