Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
82336717
Commit
82336717
authored
Mar 02, 2001
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added -o/--output-file option as per GNU msgfmt to specify the output
file instead of using inputfilename.mo
parent
e5b75769
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
Tools/i18n/msgfmt.py
Tools/i18n/msgfmt.py
+18
-9
No files found.
Tools/i18n/msgfmt.py
View file @
82336717
...
...
@@ -11,6 +11,11 @@ GNU msgfmt program, however, it is a simpler implementation.
Usage: msgfmt.py [OPTIONS] filename.po
Options:
-o file
--output-file=file
Specify the output file to write to. If omitted, output will go to a
file named filename.mo (based off the input file name).
-h
--help
Print this message and exit.
...
...
@@ -18,15 +23,15 @@ Options:
-V
--version
Display version information and exit.
"""
import
sys
import
os
import
getopt
import
struct
import
array
__version__
=
"1.
0
"
__version__
=
"1.
1
"
MESSAGES
=
{}
...
...
@@ -91,17 +96,18 @@ def generate():
def
make
(
filename
):
def
make
(
filename
,
outfile
):
ID
=
1
STR
=
2
# Compute .mo name from .po name
# Compute .mo name from .po name
and arguments
if
filename
.
endswith
(
'.po'
):
infile
=
filename
outfile
=
filename
[:
-
2
]
+
'mo'
else
:
infile
=
filename
+
'.po'
outfile
=
filename
+
'.mo'
if
outfile
is
None
:
outfile
=
os
.
path
.
splitext
(
infile
)[
0
]
+
'.mo'
try
:
lines
=
open
(
infile
).
readlines
()
except
IOError
,
msg
:
...
...
@@ -159,7 +165,6 @@ def make(filename):
# Compute output
output
=
generate
()
# Save output
try
:
open
(
outfile
,
"wb"
).
write
(
output
)
except
IOError
,
msg
:
...
...
@@ -169,10 +174,12 @@ def make(filename):
def
main
():
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'hV'
,
[
'help'
,
'version'
])
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'hVo:'
,
[
'help'
,
'version'
,
'output-file='
])
except
getopt
.
error
,
msg
:
usage
(
1
,
msg
)
outfile
=
None
# parse options
for
opt
,
arg
in
opts
:
if
opt
in
(
'-h'
,
'--help'
):
...
...
@@ -180,6 +187,8 @@ def main():
elif
opt
in
(
'-V'
,
'--version'
):
print
>>
sys
.
stderr
,
"msgfmt.py"
,
__version__
sys
.
exit
(
0
)
elif
opt
in
(
'-o'
,
'--output-file'
):
outfile
=
arg
# do it
if
not
args
:
print
>>
sys
.
stderr
,
'No input file given'
...
...
@@ -187,7 +196,7 @@ def main():
return
for
filename
in
args
:
make
(
filename
)
make
(
filename
,
outfile
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment