Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/bin
File: pygettext2.py
opts, args = getopt.getopt(
[500] Fix | Delete
sys.argv[1:],
[501] Fix | Delete
'ad:DEhk:Kno:p:S:Vvw:x:X:',
[502] Fix | Delete
['extract-all', 'default-domain=', 'escape', 'help',
[503] Fix | Delete
'keyword=', 'no-default-keywords',
[504] Fix | Delete
'add-location', 'no-location', 'output=', 'output-dir=',
[505] Fix | Delete
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
[506] Fix | Delete
'docstrings', 'no-docstrings',
[507] Fix | Delete
])
[508] Fix | Delete
except getopt.error, msg:
[509] Fix | Delete
usage(1, msg)
[510] Fix | Delete
[511] Fix | Delete
# for holding option values
[512] Fix | Delete
class Options:
[513] Fix | Delete
# constants
[514] Fix | Delete
GNU = 1
[515] Fix | Delete
SOLARIS = 2
[516] Fix | Delete
# defaults
[517] Fix | Delete
extractall = 0 # FIXME: currently this option has no effect at all.
[518] Fix | Delete
escape = 0
[519] Fix | Delete
keywords = []
[520] Fix | Delete
outpath = ''
[521] Fix | Delete
outfile = 'messages.pot'
[522] Fix | Delete
writelocations = 1
[523] Fix | Delete
locationstyle = GNU
[524] Fix | Delete
verbose = 0
[525] Fix | Delete
width = 78
[526] Fix | Delete
excludefilename = ''
[527] Fix | Delete
docstrings = 0
[528] Fix | Delete
nodocstrings = {}
[529] Fix | Delete
[530] Fix | Delete
options = Options()
[531] Fix | Delete
locations = {'gnu' : options.GNU,
[532] Fix | Delete
'solaris' : options.SOLARIS,
[533] Fix | Delete
}
[534] Fix | Delete
[535] Fix | Delete
# parse options
[536] Fix | Delete
for opt, arg in opts:
[537] Fix | Delete
if opt in ('-h', '--help'):
[538] Fix | Delete
usage(0)
[539] Fix | Delete
elif opt in ('-a', '--extract-all'):
[540] Fix | Delete
options.extractall = 1
[541] Fix | Delete
elif opt in ('-d', '--default-domain'):
[542] Fix | Delete
options.outfile = arg + '.pot'
[543] Fix | Delete
elif opt in ('-E', '--escape'):
[544] Fix | Delete
options.escape = 1
[545] Fix | Delete
elif opt in ('-D', '--docstrings'):
[546] Fix | Delete
options.docstrings = 1
[547] Fix | Delete
elif opt in ('-k', '--keyword'):
[548] Fix | Delete
options.keywords.append(arg)
[549] Fix | Delete
elif opt in ('-K', '--no-default-keywords'):
[550] Fix | Delete
default_keywords = []
[551] Fix | Delete
elif opt in ('-n', '--add-location'):
[552] Fix | Delete
options.writelocations = 1
[553] Fix | Delete
elif opt in ('--no-location',):
[554] Fix | Delete
options.writelocations = 0
[555] Fix | Delete
elif opt in ('-S', '--style'):
[556] Fix | Delete
options.locationstyle = locations.get(arg.lower())
[557] Fix | Delete
if options.locationstyle is None:
[558] Fix | Delete
usage(1, _('Invalid value for --style: %s') % arg)
[559] Fix | Delete
elif opt in ('-o', '--output'):
[560] Fix | Delete
options.outfile = arg
[561] Fix | Delete
elif opt in ('-p', '--output-dir'):
[562] Fix | Delete
options.outpath = arg
[563] Fix | Delete
elif opt in ('-v', '--verbose'):
[564] Fix | Delete
options.verbose = 1
[565] Fix | Delete
elif opt in ('-V', '--version'):
[566] Fix | Delete
print _('pygettext.py (xgettext for Python) %s') % __version__
[567] Fix | Delete
sys.exit(0)
[568] Fix | Delete
elif opt in ('-w', '--width'):
[569] Fix | Delete
try:
[570] Fix | Delete
options.width = int(arg)
[571] Fix | Delete
except ValueError:
[572] Fix | Delete
usage(1, _('--width argument must be an integer: %s') % arg)
[573] Fix | Delete
elif opt in ('-x', '--exclude-file'):
[574] Fix | Delete
options.excludefilename = arg
[575] Fix | Delete
elif opt in ('-X', '--no-docstrings'):
[576] Fix | Delete
fp = open(arg)
[577] Fix | Delete
try:
[578] Fix | Delete
while 1:
[579] Fix | Delete
line = fp.readline()
[580] Fix | Delete
if not line:
[581] Fix | Delete
break
[582] Fix | Delete
options.nodocstrings[line[:-1]] = 1
[583] Fix | Delete
finally:
[584] Fix | Delete
fp.close()
[585] Fix | Delete
[586] Fix | Delete
# calculate escapes
[587] Fix | Delete
make_escapes(not options.escape)
[588] Fix | Delete
[589] Fix | Delete
# calculate all keywords
[590] Fix | Delete
options.keywords.extend(default_keywords)
[591] Fix | Delete
[592] Fix | Delete
# initialize list of strings to exclude
[593] Fix | Delete
if options.excludefilename:
[594] Fix | Delete
try:
[595] Fix | Delete
fp = open(options.excludefilename)
[596] Fix | Delete
options.toexclude = fp.readlines()
[597] Fix | Delete
fp.close()
[598] Fix | Delete
except IOError:
[599] Fix | Delete
print >> sys.stderr, _(
[600] Fix | Delete
"Can't read --exclude-file: %s") % options.excludefilename
[601] Fix | Delete
sys.exit(1)
[602] Fix | Delete
else:
[603] Fix | Delete
options.toexclude = []
[604] Fix | Delete
[605] Fix | Delete
# resolve args to module lists
[606] Fix | Delete
expanded = []
[607] Fix | Delete
for arg in args:
[608] Fix | Delete
if arg == '-':
[609] Fix | Delete
expanded.append(arg)
[610] Fix | Delete
else:
[611] Fix | Delete
expanded.extend(getFilesForName(arg))
[612] Fix | Delete
args = expanded
[613] Fix | Delete
[614] Fix | Delete
# slurp through all the files
[615] Fix | Delete
eater = TokenEater(options)
[616] Fix | Delete
for filename in args:
[617] Fix | Delete
if filename == '-':
[618] Fix | Delete
if options.verbose:
[619] Fix | Delete
print _('Reading standard input')
[620] Fix | Delete
fp = sys.stdin
[621] Fix | Delete
closep = 0
[622] Fix | Delete
else:
[623] Fix | Delete
if options.verbose:
[624] Fix | Delete
print _('Working on %s') % filename
[625] Fix | Delete
fp = open(filename)
[626] Fix | Delete
closep = 1
[627] Fix | Delete
try:
[628] Fix | Delete
eater.set_filename(filename)
[629] Fix | Delete
try:
[630] Fix | Delete
tokenize.tokenize(fp.readline, eater)
[631] Fix | Delete
except tokenize.TokenError, e:
[632] Fix | Delete
print >> sys.stderr, '%s: %s, line %d, column %d' % (
[633] Fix | Delete
e[0], filename, e[1][0], e[1][1])
[634] Fix | Delete
finally:
[635] Fix | Delete
if closep:
[636] Fix | Delete
fp.close()
[637] Fix | Delete
[638] Fix | Delete
# write the output
[639] Fix | Delete
if options.outfile == '-':
[640] Fix | Delete
fp = sys.stdout
[641] Fix | Delete
closep = 0
[642] Fix | Delete
else:
[643] Fix | Delete
if options.outpath:
[644] Fix | Delete
options.outfile = os.path.join(options.outpath, options.outfile)
[645] Fix | Delete
fp = open(options.outfile, 'w')
[646] Fix | Delete
closep = 1
[647] Fix | Delete
try:
[648] Fix | Delete
eater.write(fp)
[649] Fix | Delete
finally:
[650] Fix | Delete
if closep:
[651] Fix | Delete
fp.close()
[652] Fix | Delete
[653] Fix | Delete
[654] Fix | Delete
if __name__ == '__main__':
[655] Fix | Delete
main()
[656] Fix | Delete
# some more test strings
[657] Fix | Delete
_(u'a unicode string')
[658] Fix | Delete
# this one creates a warning
[659] Fix | Delete
_('*** Seen unexpected token "%(token)s"') % {'token': 'test'}
[660] Fix | Delete
_('more' 'than' 'one' 'string')
[661] Fix | Delete
[662] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function