Exemplo n.º 1
0
 def check(self, d):
     if d.is_template or d.is_category:
         return
     if d.is_redirect:
         self.redirects[d.title] = True
         return
     self.articles[d.title] = W.cf_values(d.content)
     self.pages[d.title] = d.page.id
Exemplo n.º 2
0
 def check(self, d):
     if d.is_template or d.is_category:
         return
     if d.is_redirect:
         return
     curr_title = d.title
     self.articles[curr_title] = W.cf_values(d.content)
     self.pages[curr_title] = d.page.id
     base_title = self.convert(curr_title)
     if base_title != curr_title:
         self.dl(base_title, curr_title)
         self.base_titles[curr_title] = base_title
Exemplo n.º 3
0
 def change_content_action(self, page, content, **kwargs):
     all_values = W.cf_values(content)
     patterns = P.template_cf.findall(content)
     if len(patterns) < 2:
         print 'Wrong report?', '?' * 80
         return content
     new_tpl = u'{{Cf|%s}}' % ', '.join(all_values)
     # todo: check if several templates are IDENTICAL!!!
     # https://ru.wiktionary.org/w/index.php?title=Buddhismus&type=revision&diff=6833634&oldid=5640598
     new_content = content.replace(patterns[0], new_tpl)
     for pattern in patterns:
         new_content = new_content.replace(pattern, '')
     return new_content
Exemplo n.º 4
0
 def change_content_action(self, page, content, **kwargs):
     if page.title in [u'Заглавная страница']:
         return content
     all_values = W.cf_values(content)
     patterns = P.template_cf.findall(content)
     for value in page.new_values:
         if value in all_values:
             print u'In "%s" value "%s" already exist!' % \
                   (transliterate(page.title), transliterate(value)), \
                 '!' * 20
             continue
         all_values.append(value)
     new_tpl = u'{{Cf|%s}}' % ', '.join(all_values)
     if patterns:
         new_content = content.replace(patterns[0], new_tpl)
         for pattern in patterns[1:]:
             new_content = new_content.replace(pattern, '')
     else:
         new_content = new_tpl + '\n\n' + content
     return new_content