original_docstring: Reads JSON output of the specified shard.
  
    Args:
      output_dir: The directory in which to look for the JSON output to load.
      index: The index of the shard to load data for, this is for old api.
      task_id: The directory of the shard to load data for, this is for new api.
  
    Returns: A tuple containing:
      * The contents of path, deserialized into a python object.
      * An error string.
      (exactly one of the tuple elements will be non-None).
    
docstring: Reads JSON output of the specified shard.
docstring_tokens: Reads JSON output of the specified shard .
code: def load_shard_json(index, task_id, jsons_to_merge):
    """Reads JSON output of the specified shard.
  
    Args:
      output_dir: The directory in which to look for the JSON output to load.
      index: The index of the shard to load data for, this is for old api.
      task_id: The directory of the shard to load data for, this is for new api.
  
    Returns: A tuple containing:
      * The contents of path, deserialized into a python object.
      * An error string.
      (exactly one of the tuple elements will be non-None).
    """
    matching_json_files = [
        j for j in jsons_to_merge
        if (os.path.basename(j) == 'output.json' and
            (os.path.basename(os.path.dirname(j)) == str(index) or
             os.path.basename(os.path.dirname(j)) == task_id))]
  
    if not matching_json_files:
      print('shard %s test output missing' % index, file=sys.stderr)
      return (None, 'shard %s test output was missing' % index)
    if len(matching_json_files) > 1:
      print('duplicate test output for shard %s' % index, file=sys.stderr)
      return (None, 'shard %s test output was duplicated' % index)
  
    path = matching_json_files[0]
  
    try:
      filesize = os.stat(path).st_size
      if filesize > OUTPUT_JSON_SIZE_LIMIT:
        print(
            'output.json is %d bytes. Max size is %d' % (filesize,
                                                         OUTPUT_JSON_SIZE_LIMIT),
            file=sys.stderr)
        return (None, 'shard %s test output exceeded the size limit' % index)
  
      with open(path) as f:
        return (json.load(f), None)
    except (IOError, ValueError, OSError) as e:
      print('Missing or invalid gtest JSON file: %s' % path, file=sys.stderr)
      print('%s: %s' % (type(e).__name__, e), file=sys.stderr)
  
      return (None, 'shard %s test output was missing or invalid' % index)
code_tokens: def load_shard_json ( index , task_id , jsons_to_merge ) : matching_json_files = [ j for j in jsons_to_merge if ( os . path . basename ( j ) == 'output.json' and ( os . path . basename ( os . path . dirname ( j ) ) == str ( index ) or os . path . basename ( os . path . dirname ( j ) ) == task_id ) ) ] if not matching_json_files : print ( 'shard %s test output missing' % index , file = sys . stderr ) return ( None , 'shard %s test output was missing' % index ) if len ( matching_json_files ) > 1 : print ( 'duplicate test output for shard %s' % index , file = sys . stderr ) return ( None , 'shard %s test output was duplicated' % index ) path = matching_json_files [ 0 ] try : filesize = os . stat ( path ) . st_size if filesize > OUTPUT_JSON_SIZE_LIMIT : print ( 'output.json is %d bytes. Max size is %d' % ( filesize , OUTPUT_JSON_SIZE_LIMIT ) , file = sys . stderr ) return ( None , 'shard %s test output exceeded the size limit' % index ) with open ( path ) as f : return ( json . load ( f ) , None ) except ( IOError , ValueError , OSError ) as e : print ( 'Missing or invalid gtest JSON file: %s' % path , file = sys . stderr ) print ( '%s: %s' % ( type ( e ) . __name__ , e ) , file = sys . stderr ) return ( None , 'shard %s test output was missing or invalid' % index )
short_docstring: Reads JSON output of the specified shard.
short_docstring_tokens: Reads JSON output of the specified shard .
comment: """Reads JSON output of the specified shard.
  
    Args:
      output_dir: The directory in which to look for the JSON output to load.
      index: The index of the shard to load data for, this is for old api.
      task_id: The directory of the shard to load data for, this is for new api.
  
    Returns: A tuple containing:
      * The contents of path, deserialized into a python object.
      * An error string.
      (exactly one of the tuple elements will be non-None).
    """