nodes: 0, module; 1, function_definition; 2, function_name:_get_archive_filelist; 3, parameters; 4, comment:# type: (str) -> List[str]; 5, block; 6, identifier:filename; 7, expression_statement; 8, expression_statement; 9, comment:# type: List[str]; 10, if_statement; 11, if_statement; 12, return_statement; 13, comment:"""Extract the list of files from a tar or zip archive.
  
      Args:
          filename: name of the archive
  
      Returns:
          Sorted list of files in the archive, excluding './'
  
      Raises:
          ValueError: when the file is neither a zip nor a tar archive
          FileNotFoundError: when the provided file does not exist (for Python 3)
          IOError: when the provided file does not exist (for Python 2)
      """; 14, assignment; 15, call; 16, block; 17, elif_clause; 18, else_clause; 19, comparison_operator:"./" in names; 20, block; 21, identifier:names; 22, identifier:names; 23, list; 24, attribute; 25, argument_list; 26, with_statement; 27, call; 28, block; 29, block; 30, string:"./"; 31, identifier:names; 32, expression_statement; 33, identifier:tarfile; 34, identifier:is_tarfile; 35, identifier:filename; 36, with_clause; 37, block; 38, attribute; 39, argument_list; 40, with_statement; 41, raise_statement; 42, call; 43, with_item; 44, expression_statement; 45, identifier:zipfile; 46, identifier:is_zipfile; 47, identifier:filename; 48, with_clause; 49, block; 50, call; 51, attribute; 52, argument_list; 53, as_pattern; 54, assignment; 55, with_item; 56, expression_statement; 57, identifier:ValueError; 58, argument_list; 59, identifier:names; 60, identifier:remove; 61, string:"./"; 62, call; 63, as_pattern_target; 64, identifier:names; 65, call; 66, as_pattern; 67, assignment; 68, call; 69, attribute; 70, argument_list; 71, identifier:tar_file; 72, identifier:sorted; 73, argument_list; 74, call; 75, as_pattern_target; 76, identifier:names; 77, call; 78, attribute; 79, argument_list; 80, identifier:tarfile; 81, identifier:open; 82, identifier:filename; 83, call; 84, attribute; 85, argument_list; 86, identifier:zip_file; 87, identifier:sorted; 88, argument_list; 89, concatenated_string; 90, identifier:format; 91, identifier:filename; 92, attribute; 93, argument_list; 94, identifier:zipfile; 95, identifier:ZipFile; 96, identifier:filename; 97, call; 98, string:"Can not get filenames from '{!s}'. "; 99, string:"Not a tar or zip file"; 100, identifier:tar_file; 101, identifier:getnames; 102, attribute; 103, argument_list; 104, identifier:zip_file; 105, identifier:namelist
code: def _get_archive_filelist(filename):
      # type: (str) -> List[str]
      """Extract the list of files from a tar or zip archive.
  
      Args:
          filename: name of the archive
  
      Returns:
          Sorted list of files in the archive, excluding './'
  
      Raises:
          ValueError: when the file is neither a zip nor a tar archive
          FileNotFoundError: when the provided file does not exist (for Python 3)
          IOError: when the provided file does not exist (for Python 2)
      """
      names = []  # type: List[str]
      if tarfile.is_tarfile(filename):
          with tarfile.open(filename) as tar_file:
              names = sorted(tar_file.getnames())
      elif zipfile.is_zipfile(filename):
          with zipfile.ZipFile(filename) as zip_file:
              names = sorted(zip_file.namelist())
      else:
          raise ValueError("Can not get filenames from '{!s}'. "
                           "Not a tar or zip file".format(filename))
      if "./" in names:
          names.remove("./")
      return names