Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-130647: Add--omit-header option to pygettext#130650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
StanFromIreland wants to merge8 commits intopython:main
base:main
Choose a base branch
Loading
fromStanFromIreland:omit-header
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionsLib/test/test_tools/i18n_data/noheader.pot
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
#: noheader.py:3
msgid "Foo"
msgstr ""

#: noheader.py:5
msgid "Bar"
msgstr ""

5 changes: 5 additions & 0 deletionsLib/test/test_tools/i18n_data/noheader.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
from gettext import gettext as _

_('Foo')

_('Bar')
1 change: 1 addition & 0 deletionsLib/test/test_tools/test_i18n.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -593,6 +593,7 @@ def extract_from_snapshots():
'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2',
'--keyword=pfoo:1c,2',
'--keyword=npfoo:1c,2,3', '--keyword=_:1,2'),
'noheader.py': ('--omit-header',),
'multiple_keywords.py': ('--keyword=foo:1c,2,3', '--keyword=foo:1c,2',
'--keyword=foo:1,2',
# repeat a keyword to make sure it is extracted only once
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Add ``--omit-header`` option to :program:`pygettext`.
22 changes: 18 additions & 4 deletionsTools/i18n/pygettext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,6 +124,15 @@
--width=columns
Set width of output to columns.

--omit-header
Do not write header to file.

This is useful for testing purposes because it eliminates a source of
variance for generated .mo files.

Note: Using this option may lead to an error during compilation or other
manipulation if the resulting file is not entirely in ASCII.

-x filename
--exclude-file=filename
Specify a file that contains a list of strings that are not be
Expand DownExpand Up@@ -629,9 +638,11 @@ def _is_string_const(self, node):
def write_pot_file(messages, options, fp):
timestamp = time.strftime('%Y-%m-%d %H:%M%z')
encoding = fp.encoding if fp.encoding else 'UTF-8'
print(pot_header % {'time': timestamp, 'version': __version__,
'charset': encoding,
'encoding': '8bit'}, file=fp)

if not options.omit_header:
print(pot_header % {'time': timestamp, 'version': __version__,
'charset': encoding,
'encoding': '8bit'}, file=fp)

# Sort locations within each message by filename and lineno
sorted_keys = [
Expand DownExpand Up@@ -691,7 +702,7 @@ def main():
['extract-all', 'add-comments=?', 'default-domain=', 'escape',
'help', 'keyword=', 'no-default-keywords',
'add-location', 'no-location', 'output=', 'output-dir=',
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
'style=', 'verbose', 'version', 'width=', 'omit-header', 'exclude-file=',
'docstrings', 'no-docstrings',
])
except getopt.error as msg:
Expand All@@ -712,6 +723,7 @@ class Options:
locationstyle = GNU
verbose = 0
width = 78
omit_header = False
excludefilename = ''
docstrings = 0
nodocstrings = {}
Expand DownExpand Up@@ -764,6 +776,8 @@ class Options:
options.width = int(arg)
except ValueError:
usage(1, f'--width argument must be an integer: {arg}')
elif opt in ('--omit-header',):
options.omit_header = True
elif opt in ('-x', '--exclude-file'):
options.excludefilename = arg
elif opt in ('-X', '--no-docstrings'):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp