diff options
author | Yuri Chornoivan <yurchor@ukr.net> | 2014-01-19 17:35:54 +0200 |
---|---|---|
committer | Yuri Chornoivan <yurchor@ukr.net> | 2014-01-19 17:35:54 +0200 |
commit | 65ab023991d86fd9e707ea3005a9a4c2013e5198 (patch) | |
tree | 86a8c36aeb5358e8c303fa23aacee29df7136e16 | |
parent | 9d3040fdb90ad4fad0f949e055978b0977193ec7 (diff) | |
download | tools-65ab023991d86fd9e707ea3005a9a4c2013e5198.tar tools-65ab023991d86fd9e707ea3005a9a4c2013e5198.tar.gz tools-65ab023991d86fd9e707ea3005a9a4c2013e5198.tar.bz2 tools-65ab023991d86fd9e707ea3005a9a4c2013e5198.tar.xz tools-65ab023991d86fd9e707ea3005a9a4c2013e5198.zip |
Add image control script
-rw-r--r-- | docs/images/images.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/docs/images/images.py b/docs/images/images.py new file mode 100644 index 00000000..85344c74 --- /dev/null +++ b/docs/images/images.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import re, sys, os, getopt, subprocess, urllib2 + +def usage(): + print '\nUsage: python %s [OPTION]' %os.path.basename(sys.argv[0]) + print ' Show the list of missing images for given locale and docs name' + print 'Options: -h, --help : usage' + print ' -l <locale>, --locale <locale> : locale to test (default is "uk")' + print ' -d <docs>, --docs <docs> : docs to test (installer (default) or mcc)' + sys.exit(2) +try: + opts, args = getopt.getopt(sys.argv[1:], "hld:", ["help", "locale=", "docs="]) +except getopt.GetoptError: + usage() # print help information and exit + +docs = '' +locale = '' + +for o,a in opts: + if o in ("-h", "--help"): + usage() + if o in ("-d", "--docs"): + docs=a + if o in ("-l", "--locale"): + locale=a + +if docs == '': + docs = 'installer' + +if locale == '': + locale = 'uk' + +command_template = "svn list svn://svn.mageia.org/svn/soft/mageia-doc/trunk/%s/%s/images/ -R" + +existing_images = [] + +download_command = command_template %(docs, locale) +proc = subprocess.Popen(download_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) +while True: + line = proc.stdout.readline() + if line != '': + existing_images.append(line.rstrip()) + else: + break + +if docs == 'installer': + po_url = "http://gitweb.mageia.org/software/i18n/tools/plain/docs/installer/%s.po" %locale +if docs == 'mcc': + po_url = "http://gitweb.mageia.org/software/i18n/tools/plain/docs/mcc-help/%s.po" %locale + +response = urllib2.urlopen(po_url) +po_text = response.read().replace('\"\n\"','') + +dirty_list = [] + +regexpression='[a-zA-Z0-9_-]{1,}\.png' +such=re.compile(regexpression,re.DOTALL) +for image in such.findall(po_text): + image_name = image.strip('') + #add image_name + if not(image_name in existing_images): + dirty_list.append(image) + +list = sorted(set(dirty_list)) +print "\n".join(list) |