parameters: (event_data)
return_statement: return False
docstring: Returns whether obj is a TraceEvent array.
docstring_summary: Returns whether obj is a TraceEvent array.
docstring_tokens: Returns whether obj is a TraceEvent array .
function: def CanImport(event_data):
      ''' Returns whether obj is a TraceEvent array. '''
      # May be encoded JSON. But we dont want to parse it fully yet.
      # Use a simple heuristic:
      #   - event_data that starts with [ are probably trace_event
      #   - event_data that starts with { are probably trace_event
      # May be encoded JSON. Treat files that start with { as importable by us.
      if isinstance(event_data, str):
        return len(event_data) > 0 and (event_data[0] == '{'
            or event_data[0] == '[')
  
      # Might just be an array of events
      if (isinstance(event_data, list) and len(event_data)
          and 'ph' in event_data[0]):
        return True
  
      # Might be an object with a traceEvents field in it.
      if 'traceEvents' in event_data:
        trace_events = event_data.get('traceEvents', None)
        return (type(trace_events) is list and
            len(trace_events) > 0 and 'ph' in trace_events[0])
  
      return False
function_tokens: def CanImport ( event_data ) : # May be encoded JSON. But we dont want to parse it fully yet. # Use a simple heuristic: #   - event_data that starts with [ are probably trace_event #   - event_data that starts with { are probably trace_event # May be encoded JSON. Treat files that start with { as importable by us. if isinstance ( event_data , str ) : return len ( event_data ) > 0 and ( event_data [ 0 ] == '{' or event_data [ 0 ] == '[' ) # Might just be an array of events if ( isinstance ( event_data , list ) and len ( event_data ) and 'ph' in event_data [ 0 ] ) : return True # Might be an object with a traceEvents field in it. if 'traceEvents' in event_data : trace_events = event_data . get ( 'traceEvents' , None ) return ( type ( trace_events ) is list and len ( trace_events ) > 0 and 'ph' in trace_events [ 0 ] ) return False