/usr/bin/POFileStatus is in gettext-lint 0.4-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #!/usr/bin/python
# -*- mode: Python; coding: utf-8; -*-
# PO file status
#
# Pedro Morais <morais@kde.org>
# José Nuno Pires <jncp@netcabo.pt>
# (c) Copyright 2003, 2004
# Distributable under the terms of the GPL - see COPYING
import sys
import getopt
if not "/usr/share/gettext-lint" in sys.path:
sys.path.append("/usr/share/gettext-lint")
from POFile import POFile
from util import Output
def usage(code = -1):
w = sys.stderr.write
w('Usage: POFileStatus [OPTION] <FILE>...\n')
w('\n')
w('Mandatory arguments to long options are mandatory '
'for short options too.\n')
w('\n')
w('Options:\n')
w(' -h, --help show this help\n')
w(' -a, --show-all show all files, even if 100% translated\n')
w(' -b, --break-path add file path components to XML output\n')
w(' -p, --pot-dir=<dir> pot file dir, checks obsolete/untranslated files\n')
w(' -x, --pot-exclude=<pat> exclude pot files that match this pattern\n')
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], "habd:x:",
["help", "show-all", "break-path",
"pot-dir=", "pot-exclude="])
except getopt.GetoptError:
usage()
showall = 0
breakpath = 0
potexclude = []
potdir = None
for o, a in opts:
if o in ("-h", "--help"):
usage(0)
if o in ("-a", "--show-all"):
showall = 1
if o in ("-b", "--break-path"):
breakpath = 1
if o in ("-d", "--pot-dir"):
import os
potdir = os.path.expandvars(os.path.expanduser(a))
if o in ("-x", "--pot-exclude"):
potexclude.append(a)
if len(args) < 1: usage()
def findfiles(dir, ext, exclude):
def walkfunc(arg, dirname, fnames):
dirname = dirname[len(os.path.commonprefix((dirname, arg[2]))):]
for i in fnames:
if i.endswith(arg[1]):
name = dirname + '/' + i
for j in exclude:
if name.find(j) >= 0:
name = None
continue
if name != None: arg[0][name] = name
import os
map = {}
if os.path.isdir(dir): os.path.walk(dir, walkfunc, (map, ext, dir))
return map
def attrname(filename, breakpath, attr):
attr['name'] = filename
if breakpath:
cindex = 1
for component in filename.split('/'):
attr['name-%d' % cindex] = component
cindex = cindex + 1
potfiles = None
if potdir != None: potfiles = findfiles(potdir, '.pot', potexclude)
out = Output("po-file-status")
for filename in args:
po = POFile(filename)
if po.validate():
po.obsolete = 0
if potfiles:
if not potfiles.has_key(filename + 't'):
po.obsolete = 1
else:
del potfiles[filename + 't']
if showall or po.fuzzy or po.untranslated or po.obsolete:
attr = {}
attrname(filename, breakpath, attr)
if po.translated: attr['translated'] = str(po.translated)
if po.fuzzy: attr['fuzzy'] = str(po.fuzzy)
if po.untranslated: attr['untranslated'] = str(po.untranslated)
if po.obsolete: attr['obsolete'] = 'true'
out.opentag('file', attr, close = 1)
else:
out.opentag('file', { 'name': filename })
out.opentag('error', body = po.validateError, close = 1)
out.closetag()
if potfiles:
for filename in potfiles.keys():
attr = {}
attrname(filename, breakpath, attr)
attr['not-found'] = 'true'
out.opentag('file', attr, close = 1)
out.finish()
|