124124 --width=columns
125125 Set width of output to columns.
126126
127+ --omit-header
128+ Do not write header to file.
129+
130+ This is useful for testing purposes because it eliminates a source of
131+ variance for generated .mo files.
132+
133+ Note: Using this option may lead to an error during compilation or other
134+ manipulation if the resulting file is not entirely in ASCII.
135+
127136 -x filename
128137 --exclude-file=filename
129138 Specify a file that contains a list of strings that are not be
@@ -629,9 +638,11 @@ def _is_string_const(self, node):
629638def write_pot_file (messages , options , fp ):
630639 timestamp = time .strftime ('%Y-%m-%d %H:%M%z' )
631640 encoding = fp .encoding if fp .encoding else 'UTF-8'
632- print (pot_header % {'time' : timestamp , 'version' : __version__ ,
633- 'charset' : encoding ,
634- 'encoding' : '8bit' }, file = fp )
641+
642+ if not options .omit_header :
643+ print (pot_header % {'time' : timestamp , 'version' : __version__ ,
644+ 'charset' : encoding ,
645+ 'encoding' : '8bit' }, file = fp )
635646
636647 # Sort locations within each message by filename and lineno
637648 sorted_keys = [
@@ -691,7 +702,7 @@ def main():
691702 ['extract-all' , 'add-comments=?' , 'default-domain=' , 'escape' ,
692703 'help' , 'keyword=' , 'no-default-keywords' ,
693704 'add-location' , 'no-location' , 'output=' , 'output-dir=' ,
694- 'style=' , 'verbose' , 'version' , 'width=' , 'exclude-file=' ,
705+ 'style=' , 'verbose' , 'version' , 'width=' , 'omit-header' , ' exclude-file=' ,
695706 'docstrings' , 'no-docstrings' ,
696707 ])
697708 except getopt .error as msg :
@@ -712,6 +723,7 @@ class Options:
712723 locationstyle = GNU
713724 verbose = 0
714725 width = 78
726+ omit_header = False
715727 excludefilename = ''
716728 docstrings = 0
717729 nodocstrings = {}
@@ -764,6 +776,8 @@ class Options:
764776 options .width = int (arg )
765777 except ValueError :
766778 usage (1 , f'--width argument must be an integer: { arg } ' )
779+ elif opt in ('--omit-header' ,):
780+ options .omit_header = True
767781 elif opt in ('-x' , '--exclude-file' ):
768782 options .excludefilename = arg
769783 elif opt in ('-X' , '--no-docstrings' ):
0 commit comments