code: def add_header(fname, header):
      """Add header to file"""
      if not os.path.exists(fname):
          print("Cannot find %s ..." % fname)
          return
  
      lines = open(fname).readlines()
  
      has_asf_header = False
      has_copyright = False
  
      for i, l in enumerate(lines):
          if l.find("Licensed to the Apache Software Foundation") != -1:
              has_asf_header = True
          elif copyright_line(l):
              has_copyright = True
              lines[i] = ""
  
      if has_asf_header and not has_copyright:
          print("Skip file %s ..." % fname)
          return
  
      with open(fname, "w") as outfile:
          skipline = False
          ext = os.path.splitext(fname)[1][1:]
  
          if not lines:
              skipline = False  # File is enpty
          elif lines[0][:2] == "#!":
              skipline = True
          elif lines[0][:2] == "<?":
              skipline = True
          elif lines[0].startswith("<html>"):
              skipline = True
          elif lines[0].startswith("// !$"):
              skipline = True
  
          if skipline:
              outfile.write(lines[0])
              if not has_asf_header:
                  outfile.write(header + "\n\n")
              outfile.write("".join(lines[1:]))
          else:
              if not has_asf_header:
                  outfile.write(header + "\n\n")
              outfile.write("".join(lines))
      if not has_asf_header:
          print("Add header to %s" % fname)
      if has_copyright:
          print("Removed copyright line from %s" % fname)
  
imports: import os
  import sys
label_desc: Use image node_id 2 for calling a global function with example usage: add_header(fname, header) without return types