diff --git a/src/cluecode/copyrights.py b/src/cluecode/copyrights.py index 6d17467acf..3dbf6c15d2 100644 --- a/src/cluecode/copyrights.py +++ b/src/cluecode/copyrights.py @@ -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'), ] @@ -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 @@ -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 diff --git a/tests/cluecode/data/authors/author_no_space_after_colon.cpp b/tests/cluecode/data/authors/author_no_space_after_colon.cpp new file mode 100644 index 0000000000..0a8816c79c --- /dev/null +++ b/tests/cluecode/data/authors/author_no_space_after_colon.cpp @@ -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 diff --git a/tests/cluecode/data/authors/author_no_space_after_colon.cpp.yml b/tests/cluecode/data/authors/author_no_space_after_colon.cpp.yml new file mode 100644 index 0000000000..49175a5606 --- /dev/null +++ b/tests/cluecode/data/authors/author_no_space_after_colon.cpp.yml @@ -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 diff --git a/tests/cluecode/test_copyrights_basic.py b/tests/cluecode/test_copyrights_basic.py index 1fbafcf548..587b90273c 100644 --- a/tests/cluecode/test_copyrights_basic.py +++ b/tests/cluecode/test_copyrights_basic.py @@ -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