class_docstr: Handles upgrading a set of Python files using a given API change spec.
class_docstr_tok: ["Handles","upgrading","a","set","of","Python","files","using","a","given","API","change","spec","."]
docstr: Updates a file using pasta.
docstr_tok: ["Updates","a","file","using","pasta","."]
code: def update_string_pasta(self, text, in_filename):
      """Updates a file using pasta."""
      try:
          t = pasta.parse(text)
      except (SyntaxError, ValueError, TypeError):
          log = ["ERROR: Failed to parse.\n" + traceback.format_exc()]
          return 0, "", log, []
  
      (
          t,
          preprocess_logs,
          preprocess_errors,
      ) = self._api_change_spec.preprocess(t)
  
      visitor = _PastaEditVisitor(self._api_change_spec)
      visitor.visit(t)
  
      self._api_change_spec.clear_preprocessing()
  
      logs = [
          self.format_log(log, None)
          for log in (preprocess_logs + visitor.log)
      ]
      errors = [
          self.format_log(error, in_filename)
          for error in (preprocess_errors + visitor.warnings_and_errors)
      ]
      return 1, pasta.dump(t), logs, errors
  
imports: import ast
  import collections
  import os
  import re
  import shutil
  import sys
  import tempfile
  import traceback
  import pasta
label_desc: Use image node_id 4 for calling the ASTCodeUpgrader obj's underlying member method code with example usage: obj.update_string_pasta(text, in_filename) and returns: int,  pasta,  logs,  errors, int,  str,  log,  list