Skip to content

Commit

Permalink
added support for removal of 'accessdate' param if no url
Browse files Browse the repository at this point in the history
  • Loading branch information
HazardSJ committed Aug 28, 2013
1 parent 241c412 commit 3755e84
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions citationstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CitationStyleRobot(object):
def __init__(self):
self.site = pywikibot.Site("en", "wikipedia")
self.categories = [
Category(self.site, "Category:Pages using citations with accessdate and no URL"),
Category(self.site, "Category:Pages with archiveurl citation errors"),
Category(self.site, "Category:Pages with citations having wikilinks embedded in URL titles"),
Category(self.site, "Category:Pages with empty citations")
Expand Down Expand Up @@ -170,6 +171,14 @@ def getArchiveDate(self):
date = datetime.strptime(timestamp,'%Y%m%d%H%M%S')
self.template.add("archivedate", (date.strftime("%d %B %Y")).lstrip("0"))

def removeAccessdate(self):
if not (self.template.has_param("accessdate") and not
self.template.has_param("url") and not
self.template.has_param("archiveurl") and not
self.template.has_param("deadurl")):
return
self.template.remove("accessdate")

def run(self):
for category in self.categories:
self.checkDoTaskPage()
Expand All @@ -186,10 +195,11 @@ def run(self):
if not self.template.name.lower().strip() in self.citationTemplates:
continue
try:
self.removeWikilinks()
self.fixEmptyCitations()
self.getURLFromArchive()
self.getArchiveDate()
self.getURLFromArchive()
self.removeAccessdate()
self.removeWikilinks()
except:
print "Skipping: Error encountered while processing"
if text == self.code:
Expand Down

0 comments on commit 3755e84

Please sign in to comment.