docs: def replace_in_file(self, file_path, old_exp, new_exp):
          """ In the given file, replace all 'old_exp' by 'new_exp'. """
          self.term.print_info(u"Making replacement into {}"
                                   .format(self.term.text_in_color(file_path,
                                                                   TERM_GREEN)))
          # write the new version into a temporary file
          tmp_file = tempfile.NamedTemporaryFile(mode='w+t', delete=False)
          for filelineno, line in enumerate(io.open(file_path, encoding="utf-8")):
              if old_exp in line:
                  line = line.replace(old_exp, new_exp)
              try:
                  tmp_file.write(line.encode('utf-8'))
              except TypeError:
                  tmp_file.write(line)
  
          name = tmp_file.name # keep the name
          tmp_file.close()
          shutil.copy(name, file_path) # replace the original one
          os.remove(name)