jenkins-bot has submitted this change and it was merged.

Change subject: upload: use siteinfo fileextensions for allowed formats
......................................................................


upload: use siteinfo fileextensions for allowed formats

Change-Id: I9cc6d692818700ab807c12efdd862101260e8d30
---
M CREDITS
M scripts/upload.py
2 files changed, 10 insertions(+), 5 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CREDITS b/CREDITS
index 86ca30b..93af68e 100644
--- a/CREDITS
+++ b/CREDITS
@@ -46,6 +46,7 @@
 Linedwell
 Maarten Dammers
 Marcin Cieslak
+Matanya
 Maxim Razin
 Meno25
 Merlijn van Deen
diff --git a/scripts/upload.py b/scripts/upload.py
index f70e228..29eaf4a 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -290,10 +290,14 @@
         # FIXME: these 2 belong somewhere else, presumably in family
         # forbidden characters are handled by pywikibot/page.py
         forbidden = ':*?/\\'  # to be extended
-        allowed_formats = (u'gif', u'jpg', u'jpeg', u'mid', u'midi',
-                           u'ogg', u'png', u'svg', u'xcf', u'djvu',
-                           u'ogv', u'oga', u'tif', u'tiff', u'webm',
-                           u'flac', u'wav')
+        try:
+            allowed_formats = self.targetSite.siteinfo.get(
+                'fileextensions', get_default=False)
+        except KeyError:
+            allowed_formats = []
+        else:
+            allowed_formats = [item['ext'] for item in allowed_formats]
+
         # ask until it's valid
         first_check = True
         while True:
@@ -314,7 +318,7 @@
                 pywikibot.output(
                     'Invalid character(s): %s. Please try again' % c)
                 continue
-            if ext not in allowed_formats:
+            if allowed_formats and ext not in allowed_formats:
                 if always:
                     pywikibot.output('File format is not one of '
                                      '[{0}]'.format(' '.join(allowed_formats)))

-- 
To view, visit https://gerrit.wikimedia.org/r/223021
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9cc6d692818700ab807c12efdd862101260e8d30
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matanya <mata...@foss.co.il>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisa...@openmailbox.org>
Gerrit-Reviewer: XZise <commodorefabia...@gmx.de>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to