Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 912367 Details for
Bug 1113425
[patch] make msghack python3 compatible
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to make msghack Python 3 compatible
gettext-msghack-python3.patch (text/plain), 5.87 KB, created by
Bohuslav "Slavek" Kabrda
on 2014-06-26 07:43:24 UTC
(
hide
)
Description:
Patch to make msghack Python 3 compatible
Filename:
MIME Type:
Creator:
Bohuslav "Slavek" Kabrda
Created:
2014-06-26 07:43:24 UTC
Size:
5.87 KB
patch
obsolete
>diff --git a/msghack.py b/msghack.py >index 0e16104..29bc1a8 100755 >--- a/msghack.py >+++ b/msghack.py >@@ -1,4 +1,4 @@ >-#!/usr/bin/python >+#!/usr/bin/python2 > ## -*- coding: utf-8 -*- > ## Copyright (C) 2001, 2004, 2008, 2012 Red Hat, Inc. > ## Copyright (C) 2001 Trond Eivind Glomsrød <teg@redhat.com> >@@ -20,7 +20,6 @@ > A msghack replacement > """ > >-import string > import sys > > class GTMessage: >@@ -35,8 +34,8 @@ class GTMessage: > @message The message > @id The messageid associated with the object > """ >- self._message=string.strip(message) >- self._id=string.strip(id) >+ self._message=message.strip() >+ self._id=id.strip() > self._refs=[] > for ref in refs: > self._refs.append(ref) >@@ -178,7 +177,7 @@ class GTFile: > msgar.append(GTMessage(message._id,message._message,message._refs)) > continue > msg=GTMessage(message._message,message._id,message._refs) >- if not msght.has_key(msg._id): >+ if msg._id not in msght: > msght[msg._id]=msg > msgar.append(msg) > else: >@@ -199,7 +198,7 @@ class GTFile: > res="" > for message in self._messages: > msgid=message._id >- if msgids.has_key(msgid): >+ if msgid in msgids: > res=res+"Duplicate: %s\n" % (msgid) > else: > msgids[msgid]=1 >@@ -259,12 +258,12 @@ class GTFile: > inmsgstr=0 > templines=file.readlines() > for line in templines: >- lines.append(string.strip(line)) >+ lines.append(line.strip()) > for line in lines: >- pos=string.find(line,'"') >- pos2=string.rfind(line,'"') >+ pos=line.find('"') >+ pos2=line.rfind('"') > if line and line[0]=="#": >- refs.append(string.strip(line)) >+ refs.append(line.strip()) > if inmsgstr==0 and line[:6]=="msgstr": > msgstr="" > inmsgstr=1 >@@ -342,7 +341,7 @@ class GTMaster: > > def printUsage(): > "Print the usage messages" >- print "Usage: ", str(sys.argv[0])," [OPTION] file.po [ref.po]\n\ >+ print("Usage: ", str(sys.argv[0])," [OPTION] file.po [ref.po]\n\ > This program can be used to alter .po files in ways no sane mind would think about.\n\ > -o result will be written to FILE\n\ > --invert invert a po file by switching msgid and msgstr\n\ >@@ -350,26 +349,26 @@ This program can be used to alter .po files in ways no sane mind would think abo > --empty empty the contents of the .po file, creating a .pot\n\ > --append append entries from ref.po that don't exist in file.po\n\ > \n\ >-Note: It is just a replacement of msghack for backward support.\n" >+Note: It is just a replacement of msghack for backward support.\n") > > > if __name__=="__main__": > output=None > res=None > if("-o") in sys.argv: >- if (len(sys.argv)<=sys.argv.index("-o")+1): >- print "file.po and ref.po are not specified!\n" >- printUsage() >- exit(1) >- output=sys.argv[sys.argv.index("-o")+1] >+ if (len(sys.argv)<=sys.argv.index("-o")+1): >+ print("file.po and ref.po are not specified!\n") >+ printUsage() >+ exit(1) >+ output=sys.argv[sys.argv.index("-o")+1] > sys.argv.remove("-o") >- sys.argv.remove(output) >+ sys.argv.remove(output) > if("--invert") in sys.argv: >- if (len(sys.argv)<=sys.argv.index("--invert")+1): >- print "file.po is not specified!\n" >- printUsage() >- exit(1) >- file=sys.argv[sys.argv.index("--invert")+1] >+ if (len(sys.argv)<=sys.argv.index("--invert")+1): >+ print("file.po is not specified!\n") >+ printUsage() >+ exit(1) >+ file=sys.argv[sys.argv.index("--invert")+1] > gtf=GTFile(file) > res1=gtf.msgidDupes() > if res1: >@@ -377,41 +376,41 @@ if __name__=="__main__": > sys.exit(1) > res=str(gtf.invertedStrings()) > elif("--empty") in sys.argv: >- if (len(sys.argv)<=sys.argv.index("--empty")+1): >- print "file.po is not specified!\n" >- printUsage() >- exit(1) >- file=sys.argv[sys.argv.index("--empty")+1] >+ if (len(sys.argv)<=sys.argv.index("--empty")+1): >+ print("file.po is not specified!\n") >+ printUsage() >+ exit(1) >+ file=sys.argv[sys.argv.index("--empty")+1] > gtf=GTFile(file) > res=str(gtf.emptyMsgStrings()) > elif("--master") in sys.argv: >- if (len(sys.argv)<=sys.argv.index("--master")+1): >- print "file.po is not specified!\n" >- printUsage() >- exit(1) >- loc=sys.argv.index("--master")+1 >+ if (len(sys.argv)<=sys.argv.index("--master")+1): >+ print("file.po is not specified!\n") >+ printUsage() >+ exit(1) >+ loc=sys.argv.index("--master")+1 > gtfs=[] > for file in sys.argv[loc:]: > gtfs.append(GTFile(file)) > master=GTMaster(gtfs) > res=str(master) > elif("--append") in sys.argv: >- if (len(sys.argv)<=sys.argv.index("--append")+2): >- print "file.po and/or ref.po are not specified!\n" >- printUsage() >- exit(1) >- file=sys.argv[sys.argv.index("--append")+1] >+ if (len(sys.argv)<=sys.argv.index("--append")+2): >+ print("file.po and/or ref.po are not specified!\n") >+ printUsage() >+ exit(1) >+ file=sys.argv[sys.argv.index("--append")+1] > file2=sys.argv[sys.argv.index("--append")+2] > gtf=GTFile(file) > gtf2=GTFile(file2) > gtf.append(gtf2) > res=str(gtf) > else: >- #print "Not implemented: "+str(sys.argv) >- printUsage() >+ #print("Not implemented: "+str(sys.argv)) >+ printUsage() > sys.exit(1) > if not output: >- print res >+ print(res) > else: > file=open(output,"w") > file.write(res)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1113425
: 912367