Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/221610
Change subject: Update pywikibot checker/insertables
......................................................................
Update pywikibot checker/insertables
Parameter checks were already correct (see T98004)
Added brace balance check as there are many links
Added insertables for the message parameters
Change-Id: I40f27473e076629c6ed54166d9ee85afad52c933
---
M groups/Pywikibot/Pywikibot.yaml
A groups/Pywikibot/Suggester.php
2 files changed, 26 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/translatewiki
refs/changes/10/221610/1
diff --git a/groups/Pywikibot/Pywikibot.yaml b/groups/Pywikibot/Pywikibot.yaml
index 4f5ee54..1554c42 100644
--- a/groups/Pywikibot/Pywikibot.yaml
+++ b/groups/Pywikibot/Pywikibot.yaml
@@ -35,8 +35,14 @@
CHECKER:
class: MessageChecker
checks:
- # This check should be renamed when we use JSON for everything
- pythonInterpolationCheck
+ - braceBalanceCheck
+
+ INSERTABLES:
+ class: PywikibotInsertablesSuggester
+
+ AUTOLOAD:
+ PywikibotInsertablesSuggester: Suggester.php
LANGUAGES:
blacklist:
diff --git a/groups/Pywikibot/Suggester.php b/groups/Pywikibot/Suggester.php
new file mode 100644
index 0000000..6840965
--- /dev/null
+++ b/groups/Pywikibot/Suggester.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @file
+ * @author Niklas Laxström
+ * @license GPL-2.0+
+ */
+
+class PywikibotInsertablesSuggester {
+ public function getInsertables( $text ) {
+ // %(title)s
+ $matches = array();
+ preg_match_all( '\%\([a-zA-Z0-9]*?\)[diouxXeEfFgGcrs]/U',
$text, $matches, PREG_SET_ORDER );
+ $insertables = array_map( function( $match ) {
+ return new Insertable( $match[0], $match[0] );
+ }, $matches );
+
+ return $insertables;
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/221610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I40f27473e076629c6ed54166d9ee85afad52c933
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits