def begin_end_from_header(header): """ Return begin and endyear from header. Begin is extracted from begin of copyright End is current year """ thisyear = _this_year() endyear = thisyear reg_begin_endyear = re.search(r'^#\s*Copyright\s+(?P<beginyear>\d+)(?:-(?P<endyear>\d+))?($|\s+)', header, re.M) if reg_begin_endyear: beginyear = int(reg_begin_endyear.groupdict()['beginyear']) else: log.error('No begin/endyear found, using this year as begin (and end)') beginyear = thisyear return beginyear, endyear