Permalink
Browse files

insert template immediately after level 2 heading of section, and ski…

…p pages that start with A and B as well
  • Loading branch information...
HazardSJ committed Mar 3, 2016
1 parent f16e137 commit d36d35be2b0bc123144e24032be3eaf98d32d0c1
Showing with 9 additions and 15 deletions.
  1. +9 −15 enwiki/research_help.py
View
@@ -62,19 +62,6 @@ def get_best_section(self, code):
return section
return None
def insert_rh_template(self, rh_template, section):
rh_template += "\n"
# Insert before <references />
if "<references" in section:
section.replace("<references", "%s<references" % rh_template)
return
# Insert before {{reflist}}
for template in section.ifilter_templates():
if template.name.lower().strip() in self._reflist_template_titles:
if not template.has_param("group"):
section.insert_before(template, rh_template)
return
def run(self):
for group in self.groups.values():
edits = 0
@@ -86,7 +73,10 @@ def run(self):
page = talk.toggleTalkPage()
# Skip pages that start with a digit
if re.match(r"\d.*", page.title()):
if re.match(r"\d", page.title()):
continue
# Skip pages that start with the letter "A" or "B" (so we don't do any more of those)
if re.match(r"[A-B]", page.title()):
continue
try:
@@ -103,7 +93,11 @@ def run(self):
section = self.get_best_section(code)
if section is not None:
self.insert_rh_template(group["template"], section)
try:
section_heading = section.filter_headings()[0]
except IndexError:
continue
section.insert_after(section_heading, "\n" + group["template"])
else:
continue

0 comments on commit d36d35b

Please sign in to comment.