reuse.header module

Functions for manipulating the comment headers of files.

reuse.header.add_arguments(parser)[source]

Add arguments to parser.

Return type:None
reuse.header.create_header(spdx_info, header=None, style=<class 'reuse._comment.PythonCommentStyle'>)[source]

Create a header containing spdx_info. header is an optional argument containing a header which should be modified to include spdx_info. If header is not given, a brand new header is created.

Raises:CommentCreateError – if a comment could not be created.
Return type:str
reuse.header.find_and_replace_header(text, spdx_info, style=<class 'reuse._comment.PythonCommentStyle'>)[source]

Find the comment block starting at the first character in text. That comment block is replaced by a new comment block containing spdx_info.

If the comment block already contained some SPDX information, that information is merged into spdx_info.

If no header exists, one is simply created.

text is returned with a new header.

Raises:CommentCreateError – if a comment could not be created.
Return type:str
reuse.header.run(args, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Add headers to files.

Return type:int