aboutsummaryrefslogtreecommitdiffstats
path: root/websites
diff options
context:
space:
mode:
authorYuri Chornoivan <yurchor@mageia.org>2013-05-26 18:52:52 +0000
committerYuri Chornoivan <yurchor@mageia.org>2013-05-26 18:52:52 +0000
commit44d2801f17a42f4a3f447a3c90caf326c59ea821 (patch)
tree6fbdf72c614b6ce7ec4cbf3b6da012aff3fb66ae /websites
parentcfe198dc6bf9f417c6f69925c255a2d96d461cb4 (diff)
downloadtools-44d2801f17a42f4a3f447a3c90caf326c59ea821.tar
tools-44d2801f17a42f4a3f447a3c90caf326c59ea821.tar.gz
tools-44d2801f17a42f4a3f447a3c90caf326c59ea821.tar.bz2
tools-44d2801f17a42f4a3f447a3c90caf326c59ea821.tar.xz
tools-44d2801f17a42f4a3f447a3c90caf326c59ea821.zip
Implement -d <directory> parameter
Diffstat (limited to 'websites')
-rw-r--r--websites/langpo.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/websites/langpo.py b/websites/langpo.py
index 052c4d5a..9e036e44 100644
--- a/websites/langpo.py
+++ b/websites/langpo.py
@@ -1,13 +1,37 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import errno, glob, polib, re, os
+import errno, glob, polib, re, os, getopt, sys
from time import strftime
-for langfile in glob.glob('*.en.lang'):
- langfilename = langfile.replace('.en.lang', '')
+def usage():
+ print '\nUsage: python %s [OPTION]' %os.path.basename(sys.argv[0])
+ print ' generate pot catalogs and updates po files for lang resources in the specified directory'
+ print 'Options: -h, --help : usage'
+ print ' -d <directory>, --directory <directory> : directory with lang files'
+ sys.exit(2)
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hd:", ["help", "directory="])
+except getopt.GetoptError:
+ usage() # print help information and exit
+
+directory=''
+for o,a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ if o in ("-d", "--directory"):
+ directory=a
+
+directory = directory.rstrip('/')
+
+if (directory != '') and (os.path.isdir(directory) == False):
+ sys.exit('Specified directory does not exixst')
+
+for langfile in glob.glob(os.path.join(directory, '*.en.lang')):
+ langfiledir = langfile.replace('.en.lang', '')
+ langfilename = langfiledir.rpartition('/')[2]
# Create localization directories if needed
- podir = langfilename + '/po'
+ podir = langfiledir + '/po'
try:
os.makedirs(podir)
except OSError, e:
@@ -50,7 +74,7 @@ for langfile in glob.glob('*.en.lang'):
occurrences=[(langfile,'')]
)
pot.append(potentry)
- potfilename = langfilename + '/po/' + langfilename + '.pot'
+ potfilename = langfiledir + '/po/' + langfilename + '.pot'
pot.save(potfilename)
# Parse PO files