| Index: trunk/mwdumper/mwdumper/Dumper.cs |
| — | — | @@ -183,6 +183,8 @@ |
| 184 | 184 | return new TitleMatchFilter(sink, param); |
| 185 | 185 | else if (filter == "list") |
| 186 | 186 | return new ListFilter(sink, param); |
| | 187 | + else if (filter == "exactlist") |
| | 188 | + return new ExactListFilter(sink, param); |
| 187 | 189 | else |
| 188 | 190 | throw new ArgumentException("Filter unknown: " + filter); |
| 189 | 191 | } |
| Index: trunk/mwdumper/Makefile |
| — | — | @@ -18,6 +18,7 @@ |
| 19 | 19 | SOURCES_IMPORT=\ |
| 20 | 20 | mwimport/AssemblyInfo.cs \ |
| 21 | 21 | mwimport/Contributor.cs \ |
| | 22 | + mwimport/ExactListFilter.cs \ |
| 22 | 23 | mwimport/IDumpWriter.cs \ |
| 23 | 24 | mwimport/LatestFilter.cs \ |
| 24 | 25 | mwimport/ListFilter.cs \ |
| Index: trunk/mwdumper/README |
| — | — | @@ -61,7 +61,9 @@ |
| 62 | 62 | --filter=list:<list-filename> |
| 63 | 63 | Excludes all pages whose titles do not appear in the given file. |
| 64 | 64 | 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. |
| 66 | 68 | --filter=namespace:[!]<NS_KEY,NS_OTHERKEY,100,...> |
| 67 | 69 | Excludes all pages in (or not in, with "!") the given namespaces. |
| 68 | 70 | You can use the NS_* constant names or the raw numeric keys. |
| Index: trunk/mwdumper/mwimport/Title.cs |
| — | — | @@ -32,8 +32,19 @@ |
| 33 | 33 | public string Text; |
| 34 | 34 | |
| 35 | 35 | private string _prefix; |
| | 36 | + private IDictionary _namespaces; |
| 36 | 37 | |
| | 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 | + |
| 37 | 47 | public Title(string prefixedTitle, IDictionary namespaces) { |
| | 48 | + _namespaces = namespaces; |
| 38 | 49 | foreach (int key in namespaces.Keys) { |
| 39 | 50 | string prefix = (string)namespaces[key]; |
| 40 | 51 | int len = prefix.Length; |
| — | — | @@ -63,8 +74,26 @@ |
| 64 | 75 | |
| 65 | 76 | public bool IsTalk { |
| 66 | 77 | get { |
| 67 | | - return (Namespace & 0x0001) == 1; |
| | 78 | + return (Namespace > 0) && (Namespace % 2 == 1); |
| 68 | 79 | } |
| 69 | 80 | } |
| | 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 | + } |
| 70 | 99 | } |
| 71 | 100 | } |
| Index: trunk/mwdumper/mwimport/ListFilter.cs |
| — | — | @@ -29,7 +29,7 @@ |
| 30 | 30 | using System.IO; |
| 31 | 31 | |
| 32 | 32 | public class ListFilter : PageFilter { |
| 33 | | - IDictionary _list; |
| | 33 | + protected IDictionary _list; |
| 34 | 34 | |
| 35 | 35 | public ListFilter(IDumpWriter sink, string sourceFileName) : base(sink) { |
| 36 | 36 | _list = new Hashtable(); |
| — | — | @@ -49,7 +49,8 @@ |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | 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()); |
| 54 | 55 | } |
| 55 | 56 | } |
| 56 | 57 | } |
| Index: trunk/mwdumper/mwimport/mwimport.mdp |
| — | — | @@ -36,6 +36,7 @@ |
| 37 | 37 | <File name="./NamespaceFilter.cs" subtype="Code" buildaction="Compile" /> |
| 38 | 38 | <File name="./NotalkFilter.cs" subtype="Code" buildaction="Compile" /> |
| 39 | 39 | <File name="./MultiWriter.cs" subtype="Code" buildaction="Compile" /> |
| | 40 | + <File name="./ExactListFilter.cs" subtype="Code" buildaction="Compile" /> |
| 40 | 41 | </Contents> |
| 41 | 42 | <References> |
| 42 | 43 | <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 |
| 1 | 42 | + native |
| Added: svn:keywords |
| 2 | 43 | + Author Date Id Revision |