code: def _update_pot_file(target, source, env):
      import re
      import os
      import SCons.Action
      nop = lambda target, source, env: 0
      save_cwd = env.fs.getcwd()
      save_os_cwd = os.getcwd()
      chdir = target[0].dir
      chdir_str = repr(chdir.get_abspath())
      env.Execute(SCons.Action.Action(nop, "Entering " + chdir_str))
      env.fs.chdir(chdir, 1)
      try:
          cmd = _CmdRunner('$XGETTEXTCOM', '$XGETTEXTCOMSTR')
          action = SCons.Action.Action(cmd, strfunction=cmd.strfunction)
          status = action([target[0]], source, env)
      except:
          env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str))
          env.fs.chdir(save_cwd, 0)
          os.chdir(save_os_cwd)
          raise
      env.Execute(SCons.Action.Action(nop, "Leaving " + chdir_str))
      env.fs.chdir(save_cwd, 0)
      os.chdir(save_os_cwd)
      if status: return status
      new_content = cmd.out
      if not new_content:
          needs_update = False
          explain = "no internationalized messages encountered"
      else:
          if target[0].exists():
              old_content = target[0].get_text_contents()
              re_cdate = re.compile(r'^"POT-Creation-Date: .*"$[\r\n]?', re.M)
              old_content_nocdate = re.sub(re_cdate, "", old_content)
              new_content_nocdate = re.sub(re_cdate, "", new_content)
              if (old_content_nocdate == new_content_nocdate):
                  needs_update = False
                  explain = "messages in file found to be up-to-date"
              else:
                  needs_update = True
                  explain = "messages in file were outdated"
          else:
              needs_update = True
              explain = "new file"
      if needs_update:
          msg = "Writing " + repr(str(target[0])) + " (" + explain + ")"
          env.Execute(SCons.Action.Action(nop, msg))
          f = open(str(target[0]), "w")
          f.write(new_content)
          f.close()
          return 0
      else:
          msg = "Not writing " + repr(str(target[0])) + " (" + explain + ")"
          env.Execute(SCons.Action.Action(nop, msg))
          return 0