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
16 changes: 16 additions & 0 deletions src/cluecode/copyrights.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,22 @@ def get_tokens(numbered_lines, splitter=re.compile(r'[\t =;]+').split):
# space before in some cases: exclude (digit , (s , (c , (-
# this allows to recover from words like KISA(Korean
line = re.sub(pattern=r'(\([^rsc\-\d])', repl=r' \g<1>', string=line)

# Split compact author prefixes such as Author:Frankie.Chu while
# preserving colons elsewhere, for example in URLs.
line = re.sub(
pattern=r'(^|\s)([Aa]uthor):(?=\S)',
repl=r'\1\2 ',
string=line,
)

# Normalize dotted names only when they follow an Author tag.
line = re.sub(
pattern=r'(^|\s)([Aa]uthor)\s+([A-Z][a-z]+)\.([A-Z][a-z]+)(?=\b|[,;])',
repl=r'\1\2 \3 \4',
string=line,
)

for tok in splitter(line):
# strip trailing quotes+comma
if tok.endswith("',"):
Expand Down
16 changes: 16 additions & 0 deletions tests/cluecode/test_copyrights_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,22 @@ def test_detect_with_lines_only_holders(self):
))
assert results == expected

def test_detect_author_without_space_and_with_dotted_name(self):
numbered_lines = [
(1, '// Date:9 April,2012'),
(2, '// Author:Frankie.Chu'),
]
expected = [
copyrights.AuthorDetection('Frankie Chu', 2, 2),
]
results = list(copyrights.detect_copyrights_from_lines(
numbered_lines,
include_copyrights=False,
include_holders=False,
include_authors=True,
))
assert results == expected


def check_full_detections(expected, test_file):
"""
Expand Down