[MediaWiki-commits] [Gerrit] Rework importInterlang/Properties maintainance scripts - change (mediawiki...Wikibase)

2015-01-31 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Rework importInterlang/Properties maintainance scripts
..


Rework importInterlang/Properties maintainance scripts

Relevant changes:
* Replace deprecated code, use SiteLinkList and Fingerprint instead.
* Fix wrong doc in importProperties::createProperty.

Style changes:
* Replace odd strtr.
* Apply naming conventions for variable names.
* Favor single quotes over double quotes.
* Add lots of missing spaces.

Change-Id: I0b2be11d2bbb2cc5b91c7a56b89e0a20df8149c7
---
M repo/maintenance/importInterlang.php
M repo/maintenance/importProperties.php
2 files changed, 66 insertions(+), 73 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/maintenance/importInterlang.php 
b/repo/maintenance/importInterlang.php
index b9ee573..df1fe66 100644
--- a/repo/maintenance/importInterlang.php
+++ b/repo/maintenance/importInterlang.php
@@ -32,7 +32,7 @@
/**
 * @var bool
 */
-   private $ignore_errors = false;
+   private $ignoreErrors = false;
 
/**
 * @var int
@@ -59,7 +59,7 @@
 
$this->addOption( 'skip', "Skip number of entries in the import 
file" );
$this->addOption( 'only', "Only import the specific entry from 
the import file" );
-   $this->addOption( 'verbose', "Print activity " );
+   $this->addOption( 'verbose', "Print activity" );
$this->addOption( 'ignore-errors', "Continue after errors" );
$this->addArg( 'lang', "The source wiki's language code (e.g. 
`en`)", true );
$this->addArg( 'filename', "File with interlanguage links", 
true );
@@ -79,13 +79,13 @@
$this->store = 
WikibaseRepo::getDefaultInstance()->getEntityStore();
 
$this->verbose = (bool)$this->getOption( 'verbose' );
-   $this->ignore_errors = (bool)$this->getOption( 'ignore-errors' 
);
+   $this->ignoreErrors = (bool)$this->getOption( 'ignore-errors' );
$this->skip = (int)$this->getOption( 'skip' );
$this->only = (int)$this->getOption( 'only' );
-   $lang = $this->getArg( 0 );
+   $languageCode = $this->getArg( 0 );
$filename = $this->getArg( 1 );
 
-   $file = fopen( $filename, "r" );
+   $file = fopen( $filename, 'r' );
 
if ( !$file ) {
$this->doPrint( "ERROR: failed to open `$filename`" );
@@ -95,15 +95,15 @@
fgets( $file ); // We don't need the first line with column 
names.
 
$current = null;
-   $current_links = array();
+   $currentLinks = array();
$count = 0;
$ok = true;
-   while( $link = fgetcsv( $file, 0, "\t" ) ) {
-   if( $link[0] !== $current ) {
-   if ( !empty( $current_links ) ) {
-   $ok = $this->createItem( $current_links 
);
+   while ( $link = fgetcsv( $file, 0, "\t" ) ) {
+   if ( $link[0] !== $current ) {
+   if ( !empty( $currentLinks ) ) {
+   $ok = $this->createItem( $currentLinks 
);
 
-   if ( !$ok && !$this->ignore_errors ) {
+   if ( !$ok && !$this->ignoreErrors ) {
break;
}
}
@@ -113,7 +113,7 @@
continue;
}
if ( ( $this->only !== 0 ) && ( $this->only !== 
$count ) ) {
-   if ($this->only < $count) {
+   if ( $this->only < $count ) {
break;
}
continue;
@@ -121,52 +121,50 @@
 
$current = $link[0];
$this->maybePrint( "Processing `$current`" );
-
-   $current_links = array(
-   $lang => $current
-   );
+   $currentLinks = array( $languageCode => 
$current );
}
 
-   $current_links[ $link[1] ] = $link[2];
+   $currentLinks[$link[1]] = $link[2];
}
 
-   if ( !$ok && !$this->ignore_errors ) {
-   $this->doPrint( "Aborted!" );
+   if ( !$ok && !$this->ignoreErrors ) {
+   $this->doPrint( 'Aborted!' );
  

[MediaWiki-commits] [Gerrit] Rework importInterlang/Properties maintainance scripts - change (mediawiki...Wikibase)

2014-12-15 Thread WMDE
Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/179915

Change subject: Rework importInterlang/Properties maintainance scripts
..

Rework importInterlang/Properties maintainance scripts

Change-Id: I0b2be11d2bbb2cc5b91c7a56b89e0a20df8149c7
---
M repo/maintenance/importInterlang.php
M repo/maintenance/importProperties.php
2 files changed, 134 insertions(+), 109 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/15/179915/1

diff --git a/repo/maintenance/importInterlang.php 
b/repo/maintenance/importInterlang.php
index 9237758..bb09af6 100644
--- a/repo/maintenance/importInterlang.php
+++ b/repo/maintenance/importInterlang.php
@@ -24,30 +24,45 @@
 
 class importInterlang extends Maintenance {
 
-   protected $verbose = false;
-   protected $ignore_errors = false;
-   protected $skip = 0;
-   protected $only = 0;
+   /**
+* @var bool
+*/
+   private $verbose = false;
+
+   /**
+* @var bool
+*/
+   private $ignoreErrors = false;
+
+   /**
+* @var int
+*/
+   private $skip = 0;
+
+   /**
+* @var int
+*/
+   private $only = 0;
 
/**
 * @var User
 */
-   protected $user = null;
+   private $user;
 
/**
 * @var EntityStore
 */
-   protected $store = null;
+   private $store;
 
public function __construct() {
-   $this->mDescription = "Import interlanguage links in 
Wikidata.\n\nThe links may be created by extractInterlang.sql";
+   $this->mDescription = 'Import interlanguage links in 
Wikidata.\n\nThe links may be created by extractInterlang.sql';
 
-   $this->addOption( 'skip', "Skip number of entries in the import 
file" );
-   $this->addOption( 'only', "Only import the specific entry from 
the import file" );
-   $this->addOption( 'verbose', "Print activity " );
-   $this->addOption( 'ignore-errors', "Continue after errors" );
-   $this->addArg( 'lang', "The source wiki's language code (e.g. 
`en`)", true );
-   $this->addArg( 'filename', "File with interlanguage links", 
true );
+   $this->addOption( 'skip', 'Skip number of entries in the import 
file' );
+   $this->addOption( 'only', 'Only import the specific entry from 
the import file' );
+   $this->addOption( 'verbose', 'Print activity' );
+   $this->addOption( 'ignore-errors', 'Continue after errors' );
+   $this->addArg( 'lang', 'The source wiki\'s language code (e.g. 
"en")', true );
+   $this->addArg( 'filename', 'File with interlanguage links', 
true );
 
parent::__construct();
}
@@ -64,31 +79,31 @@
$this->store = 
WikibaseRepo::getDefaultInstance()->getEntityStore();
 
$this->verbose = (bool)$this->getOption( 'verbose' );
-   $this->ignore_errors = (bool)$this->getOption( 'ignore-errors' 
);
+   $this->ignoreErrors = (bool)$this->getOption( 'ignore-errors' );
$this->skip = (int)$this->getOption( 'skip' );
$this->only = (int)$this->getOption( 'only' );
-   $lang = $this->getArg( 0 );
+   $languageCode = $this->getArg( 0 );
$filename = $this->getArg( 1 );
 
-   $file = fopen( $filename, "r" );
+   $file = fopen( $filename, 'r' );
 
if ( !$file ) {
-   $this->doPrint( "ERROR: failed to open `$filename`" );
+   $this->doPrint( 'ERROR: failed to open ' . $filename );
return;
}
 
fgets( $file ); // We don't need the first line with column 
names.
 
$current = null;
-   $current_links = array();
+   $currentLinks = array();
$count = 0;
$ok = true;
-   while( $link = fgetcsv( $file, 0, "\t" ) ) {
-   if( $link[0] !== $current ) {
-   if ( !empty( $current_links ) ) {
-   $ok = $this->createItem( $current_links 
);
+   while ( $link = fgetcsv( $file, 0, "\t" ) ) {
+   if ( $link[0] !== $current ) {
+   if ( !empty( $currentLinks ) ) {
+   $ok = $this->createItem( $currentLinks 
);
 
-   if ( !$ok && !$this->ignore_errors ) {
+   if ( !$ok && !$this->ignoreErrors ) {
break;
}
}
@@ -98,59 +113,57 @@