def fix_header_comment(filename, timestamp):
    """Fixes the header-comment of the given file."""
    # Fix input file.
    name = os.path.basename( filename )
    for line in fileinput.input( filename, inplace=1, mode="rU" ):
        # If header-comment already contains anything for '$Id$', remove it.
        line = re.sub(r'\$Id:[^$]+\$', r'$Id$', line.rstrip())
        # Replace '$Id$' by a string containing the file's name (and a timestamp)!
        line = re.sub(re.escape(r'$Id$'), r'$Id: ' + name + r' ' + timestamp.isoformat() + r' $', line.rstrip())
        print(line)
def fix_header_comment ( filename , timestamp ) : name = os . path . basename ( filename ) for line in fileinput . input ( filename , inplace = 1 , mode = "rU" ) : line = re . sub ( r'\$Id:[^$]+\$' , r'$Id$' , line . rstrip ( ) ) line = re . sub ( re . escape ( r'$Id$' ) , r'$Id: ' + name + r' ' + timestamp . isoformat ( ) + r' $' , line . rstrip ( ) ) print ( line )
Fixes the header-comment of the given file.