Skip to content

Fix author extraction for single-line declarations(#4229) #4234

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all 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
18 changes: 17 additions & 1 deletion src/cluecode/copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,23 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split):
.strip()
)

# remove leading plus sign
if tok.startswith('+') and len(tok) > 1:
tok = tok.lstrip('+')
# convert 'AUTHOR' to ('author' or 'Author')
if tok == 'AUTHOR':
tok = 'author'

# Split tokens like 'Author:Frankie.Chu' into 'Author' and 'Frankie.Chu'
if tok.startswith("Author:"):
parts = tok.split(":", 1)
for part in parts:
part = part.strip()
if part and part not in ':.':
yield Token(value=part, start_line=start_line, pos=pos)
pos += 1
continue

# the tokenizer allows a single colon or dot to be a token and we discard these
if tok and tok not in ':.':
yield Token(value=tok, start_line=start_line, pos=pos)
Expand Down Expand Up @@ -3478,7 +3495,6 @@ def build_detection_from_node(
# developed by Atkinson, et al.
AUTHOR: {<AUTH> <NNP>+ <CC> <AUTHDOT> } #Atkinson, et al.


#######################################
# Mixed AUTHOR and COPYRIGHT
#######################################
Expand Down
Loading