Skip to content

Commit 1ad4ae9

Browse files
Support fnmatch
1 parent c52e785 commit 1ad4ae9

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

Lib/test/test_tools/i18n_data/skipdocstrings.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ fileloc.py
22

33
skipdocstrings.py
44
messages.py
5-
messages.py
5+
messages.py
6+
test*.py
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def func():
2+
"""Get the Holy Hand Grenade!"""

Lib/test/test_tools/test_i18n.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def extract_from_snapshots():
589589
'messages.py': (),
590590
'fileloc.py': ('--docstrings',),
591591
'docstrings.py': ('--docstrings',),
592-
('docstrings.py', 'skipdocstrings.py', 'docstrings.pot'): ('--docstrings',
592+
('docstrings.py', 'skipdocstrings.py', 'testfile.py', 'docstrings.pot'): ('--docstrings',
593593
f'--exclude-docstrings={DATA_DIR}{os.path.sep}skipdocstrings.txt'),
594594
'comments.py': ('--add-comments=i18n:',),
595595
'custom_keywords.py': ('--keyword=foo', '--keyword=nfoo:1,2',

Tools/i18n/pygettext.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@
131131
appear on a line by itself in the file.
132132
133133
-X filename
134-
--exclude-docstrings=filename
134+
--exclude-docstrings=
135+
This is only useful in conjunction with the -D option above.
135136
Specify a file that contains a list of files (one per line) that
136-
should not have their docstrings extracted. This is only useful in
137-
conjunction with the -D option above.
137+
should not have their docstrings extracted. fnmatch-style patterns are
138+
supported.
139+
138140
139141
If 'inputfile' is -, standard input is read.
140142
"""
@@ -716,7 +718,7 @@ class Options:
716718
width = 78
717719
excludefilename = ''
718720
docstrings = 0
719-
nodocstrings = []
721+
nodocstrings = set()
720722
comment_tags = set()
721723

722724
options = Options()
@@ -769,11 +771,10 @@ class Options:
769771
elif opt in ('-x', '--exclude-file'):
770772
options.excludefilename = arg
771773
elif opt in ('-X', '--exclude-docstrings'):
772-
with open(arg, 'r') as nodocstrings_file:
774+
with open(arg) as nodocstrings_file:
773775
for line in nodocstrings_file:
774776
line = line.strip()
775-
if line and line not in options.nodocstrings:
776-
options.nodocstrings.append(line)
777+
options.nodocstrings.add(line)
777778

778779
options.comment_tags = tuple(options.comment_tags)
779780

0 commit comments

Comments
 (0)