licenseheaders
licenseheaders copied to clipboard
Code with inline comment disappear after apply licenseheaders
I installed licenseheaders
via pip and get licenseheaders_0.8.5.
I applied licenseheaders
on my code and the line with a comment symbol (#), which is continue from header block, is disappeared.
Here is my command and log.
$ licenseheaders -v -v -d target -t header.tmpl -b
licenseheaders_0.8.5 INFO: Using file //header.tmpl
licenseheaders_0.8.5 INFO: Processing file target/foo.py as python
licenseheaders_0.8.5 INFO: Backing up file target/foo.py to target/foo.py.bak
foo.py.bak (original)
#
# Copyright (c) 2020 Foo Inc. All rights reserved.
#
from XXX import YYY # Import package
foo.py (after)
#
# Copyright (c) 2020 Foo Inc. All rights reserved.
#
That looks like a terrible terrbile bug, thanks for reporting.
I noticed this bug too. Is it easy to fix?
@jdumas , Hello.
I found solution that looks like working.
Line 85 in licenseheaders.py.
Replace:
"lineCommentStartPattern": re.compile(r'\s*#'),
To:
"lineCommentStartPattern": re.compile(r'^\s*#'),
Description:
looks like pattern '\s*#' grab every line from beging that contain #
. But with new one ^\s*#
everything looks okay.
Probably wouldn't work if the line just below the header is a comment, but not part of the header itself.
@jdumas, its working for this case:
#
# Copyright (c) 2020 Foo Inc. All rights reserved.
#
from XXX import YYY # Import package
Import will not be rewritten.
How about this one:
#
# Copyright (c) 2020 Foo Inc. All rights reserved.
#
# Import package
from XXX import YYY
@Igor1306 Thank you. Your solution solved my issue.
Anyway, I try with this case but the #import package
line is missing.
#
# Copyright (c) 2020 Foo Inc. All rights reserved.
#
# Import package
from XXX import YYY
I have this modification.
85c85
< "lineCommentStartPattern": re.compile(r'\s*#'),
---
> "lineCommentStartPattern": re.compile(r'^\s*#'),
Could you tell me any other modification?
@oatawa1, you are welcome. I will try to investigate this issue a little bit later, will inform about results.
@oatawa1 hello, sorry for long delay in response, I didn't come up with solution for now. Logic of licenseheader should be rewrite a little, for covering your case.