Skip to content

Commit 0f7827d

Browse files
Feature/dump namespaces (SemanticMediaWiki#5032)
* add option for namespace * change namespaces to constants * assign restrictNamespaceTo directly, remove namespaces variable * fix arg name and add quotes for example namespaces in top comment section Co-authored-by: Øyvind gjesdal <[email protected]>
1 parent fd96934 commit 0f7827d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: maintenance/dumpRDF.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
* --classes Export only concepts and categories
2929
* --properties Export only properties
3030
* --individuals Export only pages that are no categories, properties, or types
31+
* --namespace <namespacelist>
32+
* Export only namespaces included in <namespacelist>
33+
* Example: --namespace "NS_Example1|NS_Example3|SMW_CONCEPT" with | being used as separator.
34+
* Uses constant namespace names.
3135
* --page <pagelist> Export only pages included in the <pagelist> with | being used as a separator.
3236
* Example: --page "Page 1|Page 2", -e, -file, -d are ignored if --page is given.
3337
* -d <delay> Slows down the export in order to stress the server less,
@@ -68,7 +72,11 @@ public function __construct() {
6872
$this->addOption( 'properties', 'Export only properties', false );
6973
$this->addOption( 'individuals', 'Export only individuals', false );
7074

71-
$this->addOption( 'page', 'Export only pages included in the <pagelist> with | being used as a separator. ' .
75+
$this->addOption('namespace','Export only namespaced included in the <namespacelist> with | being used as a separator. ' .
76+
'Example: --namespace "NS_NS1|NS_NS2|NS_NS3"',false,true);
77+
78+
79+
$this->addOption( 'page', 'Export only pages included in the <pagelist> with | being used as a separator. ' .
7280
'Example: --page "Page 1|Page 2", -e, -file, -d are ignored if --page is given.', false, true );
7381

7482
$this->addOption( 'server', '<server> The protocol and server name to as base URLs, e.g. http://en.wikipedia.org. ' .
@@ -176,10 +184,15 @@ private function runExport() {
176184
$pages = explode( '|', $this->getOption( 'page' ) );
177185
}
178186

179-
if ( $this->hasOption( 'server' ) ) {
187+
if ( $this->hasOption( 'namespace' ) ) {
188+
$restrictNamespaceTo = array_map('constant', explode( '|', $this->getOption( 'namespace' ) ) );
189+
}
190+
191+
if ( $this->hasOption( 'server' ) ) {
180192
$GLOBALS['wgServer'] = $this->getOption( 'server' );
181193
}
182194

195+
183196
$exporterFactory = new ExporterFactory();
184197

185198
$exportController = $exporterFactory->newExportController(

0 commit comments

Comments
 (0)