MediaWiki r10962 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r10961‎ | r10962 (on ViewVC)‎ | r10963 >
Date:07:06, 10 September 2005
Author:vibber
Status:old
Tags:
Comment:
Change list filter to take talk and subject pages together, and add
an exactlist filter to provide the old exact match behavior.
Modified paths:

Diff [purge]

Index: trunk/mwdumper/mwdumper/Dumper.cs
@@ -183,6 +183,8 @@
184184 return new TitleMatchFilter(sink, param);
185185 else if (filter == "list")
186186 return new ListFilter(sink, param);
 187+ else if (filter == "exactlist")
 188+ return new ExactListFilter(sink, param);
187189 else
188190 throw new ArgumentException("Filter unknown: " + filter);
189191 }
Index: trunk/mwdumper/Makefile
@@ -18,6 +18,7 @@
1919 SOURCES_IMPORT=\
2020 mwimport/AssemblyInfo.cs \
2121 mwimport/Contributor.cs \
 22+ mwimport/ExactListFilter.cs \
2223 mwimport/IDumpWriter.cs \
2324 mwimport/LatestFilter.cs \
2425 mwimport/ListFilter.cs \
Index: trunk/mwdumper/README
@@ -61,7 +61,9 @@
6262 --filter=list:<list-filename>
6363 Excludes all pages whose titles do not appear in the given file.
6464 Use one title per line; blanks and lines starting with # are
65 - ignored.
 65+ ignored. Talk and subject pages of given titles are both matched.
 66+ --filter=exactlist:<list-filename>
 67+ As above, but does not try to match associated talk/subject pages.
6668 --filter=namespace:[!]<NS_KEY,NS_OTHERKEY,100,...>
6769 Excludes all pages in (or not in, with "!") the given namespaces.
6870 You can use the NS_* constant names or the raw numeric keys.
Index: trunk/mwdumper/mwimport/Title.cs
@@ -32,8 +32,19 @@
3333 public string Text;
3434
3535 private string _prefix;
 36+ private IDictionary _namespaces;
3637
 38+ public Title(int namespaceKey, string text, IDictionary namespaces) {
 39+ _namespaces = namespaces;
 40+ Namespace = namespaceKey;
 41+ _prefix = (string)namespaces[namespaceKey];
 42+ if (_prefix != "")
 43+ _prefix = _prefix + ":";
 44+ Text = text;
 45+ }
 46+
3747 public Title(string prefixedTitle, IDictionary namespaces) {
 48+ _namespaces = namespaces;
3849 foreach (int key in namespaces.Keys) {
3950 string prefix = (string)namespaces[key];
4051 int len = prefix.Length;
@@ -63,8 +74,26 @@
6475
6576 public bool IsTalk {
6677 get {
67 - return (Namespace & 0x0001) == 1;
 78+ return (Namespace > 0) && (Namespace % 2 == 1);
6879 }
6980 }
 81+
 82+ public Title TalkPage {
 83+ get {
 84+ if (IsTalk)
 85+ return this;
 86+ else
 87+ return new Title(Namespace + 1, Text, _namespaces);
 88+ }
 89+ }
 90+
 91+ public Title SubjectPage {
 92+ get {
 93+ if (IsTalk)
 94+ return new Title(Namespace - 1, Text, _namespaces);
 95+ else
 96+ return this;
 97+ }
 98+ }
7099 }
71100 }
Index: trunk/mwdumper/mwimport/ListFilter.cs
@@ -29,7 +29,7 @@
3030 using System.IO;
3131
3232 public class ListFilter : PageFilter {
33 - IDictionary _list;
 33+ protected IDictionary _list;
3434
3535 public ListFilter(IDumpWriter sink, string sourceFileName) : base(sink) {
3636 _list = new Hashtable();
@@ -49,7 +49,8 @@
5050 }
5151
5252 protected override bool Pass(Page page) {
53 - return _list.Contains(page.Title.ToString());
 53+ return _list.Contains(page.Title.SubjectPage.ToString())
 54+ || _list.Contains(page.Title.TalkPage.ToString());
5455 }
5556 }
5657 }
Index: trunk/mwdumper/mwimport/mwimport.mdp
@@ -36,6 +36,7 @@
3737 <File name="./NamespaceFilter.cs" subtype="Code" buildaction="Compile" />
3838 <File name="./NotalkFilter.cs" subtype="Code" buildaction="Compile" />
3939 <File name="./MultiWriter.cs" subtype="Code" buildaction="Compile" />
 40+ <File name="./ExactListFilter.cs" subtype="Code" buildaction="Compile" />
4041 </Contents>
4142 <References>
4243 <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Index: trunk/mwdumper/mwimport/ExactListFilter.cs
@@ -0,0 +1,40 @@
 2+/*
 3+ * MediaWiki import/export processing tools
 4+ * Copyright 2005 by Brion Vibber
 5+ *
 6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
 7+ * of this software and associated documentation files (the "Software"), to deal
 8+ * in the Software without restriction, including without limitation the rights
 9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 10+ * copies of the Software, and to permit persons to whom the Software is
 11+ * furnished to do so, subject to the following conditions:
 12+ *
 13+ * The above copyright notice and this permission notice shall be included in
 14+ * all copies or substantial portions of the Software.
 15+ *
 16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 22+ * SOFTWARE.
 23+ *
 24+ * $Id$
 25+ */
 26+
 27+namespace MediaWiki.Import {
 28+ using System;
 29+ using System.Collections;
 30+ using System.IO;
 31+
 32+ public class ExactListFilter : ListFilter {
 33+ public ExactListFilter(IDumpWriter sink, string sourceFileName)
 34+ : base(sink, sourceFileName) {
 35+ }
 36+
 37+ protected override bool Pass(Page page) {
 38+ return _list.Contains(page.Title.ToString());
 39+ }
 40+ }
 41+}
Property changes on: trunk/mwdumper/mwimport/ExactListFilter.cs
___________________________________________________________________
Added: svn:eol-style
142 + native
Added: svn:keywords
243 + Author Date Id Revision

Status & tagging log

  • 01:58, 13 October 2010 ^demon (Talk | contribs) changed the status of r10962 [removed: new added: old]
Personal tools
Namespaces

Variants
Views
Actions
Navigation
Support
Download
Development
Communication
Toolbox