Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ImportStackExchangeDump | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @ingroup Maintenance |
19 | */ |
20 | |
21 | use MathSearch\StackExchange\DumpReader; |
22 | |
23 | require_once __DIR__ . '/../../../maintenance/Maintenance.php'; |
24 | |
25 | class ImportStackExchangeDump extends Maintenance { |
26 | |
27 | /** @var string */ |
28 | private $dir; |
29 | |
30 | public function __construct() { |
31 | parent::__construct(); |
32 | $this->addDescription( "Imports StackExchangeDump. \n" . |
33 | "Processes XML files in the StackExchangeDump dump format." ); |
34 | $this->addArg( 'dir', 'The directory to be read', true ); |
35 | $this->addArg( 'errPath', 'The directory to write error files', false ); |
36 | $this->requireExtension( 'MathSearch' ); |
37 | // $this->requireExtension('Wikibase'); |
38 | } |
39 | |
40 | public function execute() { |
41 | $this->dir = $this->getArg( 0 ); |
42 | $errPath = $this->getArg( 1, realpath( $this->dir ) ); |
43 | if ( !is_dir( $this->dir ) ) { |
44 | $this->output( "{$this->dir} is not a directory.\n" ); |
45 | exit( 1 ); |
46 | } |
47 | $files = new GlobIterator( $this->dir . '*.xml' ); |
48 | foreach ( $files as $file ) { |
49 | print "Processing {$file->getFilename()}\n"; |
50 | $dr = new DumpReader( $file, $errPath ); |
51 | $dr->run(); |
52 | } |
53 | } |
54 | } |
55 | |
56 | $maintClass = ImportStackExchangeDump::class; |
57 | /** @noinspection PhpIncludeInspection */ |
58 | require_once RUN_MAINTENANCE_IF_MAIN; |