Changeset - 27d6f56ade84
[Not reviewed]
stable
0 1 0
Mads Kiilerich - 6 years ago 2020-01-18 22:42:50
mads@kiilerich.com
Grafted from: b5b0e612e663
scripts: lower case contributor emails to normalize them
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
scripts/update-copyrights.py
Show inline comments
 
@@ -79,48 +79,51 @@ def nice_years(l, dash='-', join=' '):
 
    return join.join(ranges)
 

	
 

	
 
def insert_entries(
 
        filename,
 
        all_entries,
 
        no_entries,
 
        domain_extra,
 
        split_re,
 
        normalize_name,
 
        format_f):
 
    """Update file with contributor information.
 
    all_entries: list of tuples with year and name
 
    no_entries: set of names or name and year tuples to ignore
 
    domain_extra: map domain name to extra credit name
 
    split_re: regexp matching the part of file to rewrite
 
    normalize_name: function to normalize names for grouping and display
 
    format_f: function formatting year list and name to a string
 
    """
 
    name_years = defaultdict(set)
 

	
 
    for year, name in all_entries:
 
        if name in no_entries or (name, year) in no_entries:
 
            continue
 
        parts = name.split(' <', 1)
 
        if len(parts) == 2:
 
            name = parts[0] + ' <' + parts[1].lower()
 
        domain = name.split('@', 1)[-1].rstrip('>')
 
        if domain in domain_extra:
 
            name_years[domain_extra[domain]].add(year)
 
        name_years[normalize_name(name)].add(year)
 

	
 
    l = [(list(sorted(year for year in years if year)), name)
 
         for name, years in name_years.items()]
 
    l.sort(key=sortkey)
 

	
 
    with open(filename) as f:
 
        pre, post = re.split(split_re, f.read())
 

	
 
    with open(filename, 'w') as f:
 
        f.write(pre +
 
                ''.join(format_f(years, name) for years, name in l) +
 
                post)
 

	
 

	
 
def main():
 
    repo_entries = [
 
        (year, contributor_data.name_fixes.get(name) or contributor_data.name_fixes.get(name.rsplit('<', 1)[0].strip()) or name)
 
        for year, name in
 
        (line.strip().split(' ', 1)
 
         for line in os.popen("""hg log -r '::.' -T '{date(date,"%Y")} {author}\n'""").readlines())
0 comments (0 inline, 0 general)