Jump to content

User:Monkbot/Task 1: CS1 deprecated date parameters

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Trappist the monk (talk | contribs) at 16:41, 22 December 2013 (Version with settings load problems for debug;). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

This is a simple, brute-force, AWB script that finds adjacent |day= or |date=, and |month= and |year= parameters in CS1 citations and concatenates them into a single |date= parameter. The default category is Category:Pages containing cite templates with deprecated parameters.

The script does not do error checking, it simply captures the content of the various parameters and lumps them together.

Feel free to use and improve this script.

<?xml version="1.0"?>
<AutoWikiBrowserPreferences xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:space="preserve" Version="5.5.2.2">
  <Project>wikipedia</Project>
  <LanguageCode>en</LanguageCode>
  <CustomProject />
  <Protocol>http://</Protocol>
  <LoginDomain />
  <List>
    <ListSource>Category:Pages containing cite templates with deprecated parameters</ListSource>
    <SelectedProvider>CategoryListProvider</SelectedProvider>
    <ArticleList />
  </List>
  <FindAndReplace>
    <Enabled>true</Enabled>
    <IgnoreSomeText>false</IgnoreSomeText>
    <IgnoreMoreText>false</IgnoreMoreText>
    <AppendSummary>false</AppendSummary>
    <Replacements>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\w*)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $3 $4$5</Replace>
        <Comment>dmy cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*year\s*=\s*(\w*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2 $4$5</Replace>
        <Comment>mdy cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\w*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})(\|?[^}]*)</Find>
        <Replace>$1|date=$4 $2 $3$5</Replace>
        <Comment>myd cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*year\s*=\s*(\w*)\s*\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})(?!\d)(\|?[^}]*)</Find>
        <Replace>$1|date=$4 $3 $2$5</Replace>
        <Comment>ymd cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*year\s*=\s*(\w*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $4 $2$5</Replace>
        <Comment>ydm cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*year\s*=\s*(\w*)\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $4 $3$5</Replace>
        <Comment>dym cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\w*)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $3 $4$5</Replace>
        <Comment>dmy citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*year\s*=\s*(\w*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2 $4$5</Replace>
        <Comment>mdy cite</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\w*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})(\|?[^}]*)</Find>
        <Replace>$1|date=$4 $2 $3$5</Replace>
        <Comment>myd citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*year\s*=\s*(\w*)\s*\|\s*month\s*=\s*([A-Za-z]+\.*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2}(?!\d))(\|?[^}]*)</Find>
        <Replace>$1|date=$4 $3 $2$5</Replace>
        <Comment>ymd citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*year\s*=\s*(\w*)\s*\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $4 $2$5</Replace>
        <Comment>ydm citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*da(?:te|y)\s*=\s*(\d{1,2})\s*\|\s*year\s*=\s*(\w*)\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $4 $2$5</Replace>
        <Comment>dym citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*month\s*=([A-Za-z]+\.*\s*(?:[-/–]|&ndash;)\s*[A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\d{3,4})(?!\d)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $3$4</Replace>
        <Comment>m-my cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*year\s*=(\d{3,4})\s*\|\s*month\s*=\s*([A-Za-z]+\.*\s*(?:[-/–]|&ndash;)\s*[A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2$4</Replace>
        <Comment>ym-m cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*month\s*=([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\d{3,4})(?!\d)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $3$4</Replace>
        <Comment>my cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]ite.*?)\|\s*year\s*=(\d{3,4})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2$4</Replace>
        <Comment>ym cite xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*month\s*=([A-Za-z]+\.*\s*(?:[-/–]|&ndash;)?\s*[A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\d{3,4})(?!\d)(\|?[^}]+)</Find>
        <Replace>$1|date=$2 $3$4</Replace>
        <Comment>m-my citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*year\s*=(\d{3,4})\s*\|\s*month\s*=\s*([A-Za-z]+\.*\s*(?:[-/–]|&ndash;)\s*[A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2$4</Replace>
        <Comment>ym-m citation</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*month\s*=([A-Za-z]+\.*)\s*\|\s*year\s*=\s*(\d{3,4})(?!\d)(\|?[^}]*)</Find>
        <Replace>$1|date=$2 $3$4</Replace>
        <Comment>my citation xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
      <Replacement>
        <Find>({{[Cc]itation[^}]+)\|\s*year\s*=(\d{3,4})\s*\|\s*month\s*=\s*([A-Za-z]+\.*)(\|?[^}]*)</Find>
        <Replace>$1|date=$3 $2$4</Replace>
        <Comment>ym citation xxx</Comment>
        <IsRegex>true</IsRegex>
        <Enabled>true</Enabled>
        <Minor>false</Minor>
        <BeforeOrAfter>false</BeforeOrAfter>
        <RegularExpressionOptions>IgnoreCase</RegularExpressionOptions>
      </Replacement>
    </Replacements>
    <AdvancedReps />
    <SubstTemplates />
    <IncludeComments>false</IncludeComments>
    <ExpandRecursively>true</ExpandRecursively>
    <IgnoreUnformatted>false</IgnoreUnformatted>
  </FindAndReplace>
  <Editprefs>
    <GeneralFixes>false</GeneralFixes>
    <Tagger>false</Tagger>
    <Unicodify>false</Unicodify>
    <Recategorisation>0</Recategorisation>
    <NewCategory />
    <NewCategory2 />
    <ReImage>0</ReImage>
    <ImageFind />
    <Replace />
    <SkipIfNoCatChange>false</SkipIfNoCatChange>
    <RemoveSortKey>false</RemoveSortKey>
    <SkipIfNoImgChange>false</SkipIfNoImgChange>
    <AppendText>false</AppendText>
    <AppendTextMetaDataSort>false</AppendTextMetaDataSort>
    <Append>true</Append>
    <Text />
    <Newlines>2</Newlines>
    <AutoDelay>10</AutoDelay>
    <BotMaxEdits>0</BotMaxEdits>
    <SupressTag>false</SupressTag>
    <RegexTypoFix>false</RegexTypoFix>
  </Editprefs>
  <General>
    <AutoSaveEdit>
      <Enabled>false</Enabled>
      <SavePeriod>30</SavePeriod>
      <SaveFile />
    </AutoSaveEdit>
    <SelectedSummary>fix CS1 deprecated date parameter errors (test)</SelectedSummary>
    <Summaries>
      <string>clean up</string>
      <string>re-categorisation per [[WP:CFD|CFD]]</string>
      <string>clean up and re-categorisation per [[WP:CFD|CFD]]</string>
      <string>removing category per [[WP:CFD|CFD]]</string>
      <string>[[Wikipedia:Template substitution|subst:'ing]]</string>
      <string>[[Wikipedia:WikiProject Stub sorting|stub sorting]]</string>
      <string>[[WP:AWB/T|Typo fixing]]</string>
      <string>bad link repair</string>
      <string>Fixing [[Wikipedia:Disambiguation pages with links|links to disambiguation pages]]</string>
      <string>Unicodifying</string>
      <string>fix deprecated parameters</string>
      <string>fix CS1 deprecated parameters</string>
      <string>fix CS1 deprecated date parameter errors (test)</string>
    </Summaries>
    <PasteMore>
      <string />
      <string />
      <string />
      <string />
      <string />
      <string />
      <string />
      <string />
      <string />
      <string />
    </PasteMore>
    <FindText />
    <FindRegex>false</FindRegex>
    <FindCaseSensitive>false</FindCaseSensitive>
    <WordWrap>true</WordWrap>
    <ToolBarEnabled>false</ToolBarEnabled>
    <BypassRedirect>true</BypassRedirect>
    <AutoSaveSettings>false</AutoSaveSettings>
    <noSectionEditSummary>false</noSectionEditSummary>
    <restrictDefaultsortAddition>true</restrictDefaultsortAddition>
    <restrictOrphanTagging>true</restrictOrphanTagging>
    <noMOSComplianceFixes>false</noMOSComplianceFixes>
    <syntaxHighlightEditBox>false</syntaxHighlightEditBox>
    <highlightAllFind>false</highlightAllFind>
    <PreParseMode>false</PreParseMode>
    <NoAutoChanges>false</NoAutoChanges>
    <OnLoadAction>0</OnLoadAction>
    <DiffInBotMode>false</DiffInBotMode>
    <Minor>true</Minor>
    <AddToWatchlist>2</AddToWatchlist>
    <TimerEnabled>false</TimerEnabled>
    <SortListAlphabetically>false</SortListAlphabetically>
    <AddIgnoredToLog>false</AddIgnoredToLog>
    <EditToolbarEnabled>true</EditToolbarEnabled>
    <filterNonMainSpace>false</filterNonMainSpace>
    <AutoFilterDuplicates>false</AutoFilterDuplicates>
    <FocusAtEndOfEditBox>false</FocusAtEndOfEditBox>
    <scrollToUnbalancedBrackets>false</scrollToUnbalancedBrackets>
    <TextBoxSize>10</TextBoxSize>
    <TextBoxFont>Courier New</TextBoxFont>
    <LowThreadPriority>false</LowThreadPriority>
    <Beep>false</Beep>
    <Flash>false</Flash>
    <Minimize>false</Minimize>
    <LockSummary>false</LockSummary>
    <SaveArticleList>true</SaveArticleList>
    <SuppressUsingAWB>false</SuppressUsingAWB>
    <AddUsingAWBToActionSummaries>false</AddUsingAWBToActionSummaries>
    <IgnoreNoBots>false</IgnoreNoBots>
    <ClearPageListOnProjectChange>false</ClearPageListOnProjectChange>
    <SortInterWikiOrder>true</SortInterWikiOrder>
    <ReplaceReferenceTags>true</ReplaceReferenceTags>
    <LoggingEnabled>true</LoggingEnabled>
    <AlertPreferences />
  </General>
  <SkipOptions>
    <SkipNonexistent>true</SkipNonexistent>
    <Skipexistent>false</Skipexistent>
    <SkipWhenNoChanges>false</SkipWhenNoChanges>
    <SkipSpamFilterBlocked>false</SkipSpamFilterBlocked>
    <SkipInuse>false</SkipInuse>
    <SkipWhenOnlyWhitespaceChanged>false</SkipWhenOnlyWhitespaceChanged>
    <SkipOnlyGeneralFixChanges>true</SkipOnlyGeneralFixChanges>
    <SkipOnlyMinorGeneralFixChanges>false</SkipOnlyMinorGeneralFixChanges>
    <SkipOnlyCasingChanged>false</SkipOnlyCasingChanged>
    <SkipIfRedirect>false</SkipIfRedirect>
    <SkipIfNoAlerts>false</SkipIfNoAlerts>
    <SkipDoes>false</SkipDoes>
    <SkipDoesNot>false</SkipDoesNot>
    <SkipDoesText />
    <SkipDoesNotText />
    <Regex>false</Regex>
    <CaseSensitive>false</CaseSensitive>
    <AfterProcessing>false</AfterProcessing>
    <SkipNoFindAndReplace>true</SkipNoFindAndReplace>
    <SkipMinorFindAndReplace>false</SkipMinorFindAndReplace>
    <SkipNoRegexTypoFix>false</SkipNoRegexTypoFix>
    <SkipNoDisambiguation>false</SkipNoDisambiguation>
    <SkipNoLinksOnPage>false</SkipNoLinksOnPage>
    <GeneralSkipList />
  </SkipOptions>
  <Module>
    <Enabled>false</Enabled>
    <Language>C# 2.0</Language>
    <Code>        public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "test";
 
            ArticleText = "test \r\n\r\n" + ArticleText;
 
            return ArticleText;
        }</Code>
  </Module>
  <ExternalProgram>
    <Enabled>false</Enabled>
    <Skip>false</Skip>
    <Program />
    <Parameters />
    <PassAsFile>true</PassAsFile>
    <OutputFile />
  </ExternalProgram>
  <Disambiguation>
    <Enabled>false</Enabled>
    <Link />
    <Variants />
    <ContextChars>20</ContextChars>
  </Disambiguation>
  <Special>
    <namespaceValues>
      <int>0</int>
      <int>1</int>
      <int>2</int>
      <int>3</int>
      <int>4</int>
      <int>5</int>
      <int>6</int>
      <int>7</int>
      <int>10</int>
      <int>11</int>
      <int>14</int>
      <int>15</int>
    </namespaceValues>
    <remDupes>true</remDupes>
    <sortAZ>true</sortAZ>
    <filterTitlesThatContain>false</filterTitlesThatContain>
    <filterTitlesThatContainText />
    <filterTitlesThatDontContain>false</filterTitlesThatDontContain>
    <filterTitlesThatDontContainText />
    <areRegex>false</areRegex>
    <opType>-1</opType>
    <remove />
  </Special>
  <Tool>
    <ListComparerUseCurrentArticleList>0</ListComparerUseCurrentArticleList>
    <ListSplitterUseCurrentArticleList>0</ListSplitterUseCurrentArticleList>
    <DatabaseScannerUseCurrentArticleList>0</DatabaseScannerUseCurrentArticleList>
  </Tool>
  <Plugin />
</AutoWikiBrowserPreferences>