Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions src/cluecode/copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,10 @@ def build_detection_from_node(
# catch all other as Nouns
############################################################################

# Dot-separated proper names like Frankie.Chu (used as author handles)
# Changes made by Aditya issue no. #4229 regarding to Author detection
(r'^[A-Z][a-z]+\.[A-Z][a-z]+$', 'NAME'),

# nouns (default)
(r'.+', 'NN'),
]
Expand Down Expand Up @@ -4447,6 +4451,11 @@ def collect_candidate_lines(numbered_lines):

fold_consecutive_quotes = re.compile(r"'\"{2,}").sub

# normalize "Author:" (and variants) not followed by a space so that
# "Author:Name" becomes "Author: Name" and can be properly tokenized.
# Changes made by Aditya issue no. #4229 regarding to Author detection
normalize_author_colon = re.compile(r'(?i)\b(authors?)\s*:\s*(?=\S)').sub

# less common rem comment line prefix in dos
# less common dnl comment line prefix in autotools am/in
remove_weird_comment_markers = re.compile(r'^(rem|\@rem|dnl)\s+').sub
Expand Down Expand Up @@ -4503,6 +4512,12 @@ def prepare_text_line(line):
if TRACE_TOK:
logger_debug(' prepare_text_line: after remove_code_comment_markers: ' + repr(line))

# normalize "Author:Name" to "Author: Name"
# Changes made by Aditya issue no. #4229 regarding to Author detection
line = normalize_author_colon(r'\1: ', line)
if TRACE_TOK:
logger_debug(' prepare_text_line: after normalize_author_colon: ' + repr(line))

line = (line
# C and C++ style comment markers
# in rst
Expand Down
4 changes: 4 additions & 0 deletions tests/cluecode/data/authors/author_no_space_after_colon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Changes made by Aditya issue no. #4229 regarding to Author detection
// Date:9 April,2012
// Author:Frankie.Chu
// IDE Arduino-1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Changes made by Aditya issue no. #4229 regarding to Author detection
what:
- authors
- authors_summary
authors:
- Frankie.Chu
authors_summary:
- value: Frankie.Chu
count: 1
12 changes: 12 additions & 0 deletions tests/cluecode/test_copyrights_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ def test_prepare_text_line_does_not_munge_markup_like_emails(self):
result = prepare_text_line(cp)
assert result == 'Jason Hunter <jhunter AT jdom DOT org'

def test_prepare_text_line_normalizes_author_colon_no_space(self):
# Changes made by Aditya issue no. #4229 regarding to Author detection
cp = '// Author:Frankie.Chu'
result = prepare_text_line(cp)
assert 'Author: Frankie.Chu' in result

def test_prepare_text_line_normalizes_author_colon_with_space(self):
# Ensure we don't break the case where there is already a space
cp = '// Author: Frankie.Chu'
result = prepare_text_line(cp)
assert 'Author: Frankie.Chu' in result

def test_is_end_of_statement(self):
line = ''' "All rights reserved\\n"'''
prepped_line = prepare_text_line(line)
Expand Down
Loading