nodes: 0, module; 1, function_definition; 2, function_name:topports; 3, parameters; 4, block; 5, default_parameter; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, expression_statement; 10, expression_statement; 11, if_statement; 12, return_statement; 13, identifier:sort_by; 14, string; 15, identifier:limit; 16, integer:10; 17, identifier:date; 18, None; 19, identifier:return_format; 20, None; 21, comment:"""Information about top ports for a particular date with return limit.
  
      :param sort_by: one of 'records', 'targets', 'sources'
      :param limit: number of records to be returned
      :param date: an optional string in 'Y-M-D' format or datetime.date() object
      """; 22, assignment; 23, identifier:date; 24, block; 25, call; 26, string_content:records; 27, identifier:uri; 28, call; 29, try_statement; 30, identifier:_get; 31, argument_list; 32, attribute; 33, argument_list; 34, block; 35, except_clause; 36, identifier:uri; 37, identifier:return_format; 38, string; 39, identifier:join; 40, list; 41, expression_statement; 42, identifier:AttributeError; 43, block; 44, string_content:/; 45, string; 46, identifier:sort_by; 47, call; 48, assignment; 49, expression_statement; 50, string_content:topports; 51, identifier:str; 52, argument_list; 53, identifier:uri; 54, call; 55, assignment; 56, identifier:limit; 57, attribute; 58, argument_list; 59, identifier:uri; 60, call; 61, string; 62, identifier:join; 63, list; 64, attribute; 65, argument_list; 66, string_content:/; 67, identifier:uri; 68, call; 69, string; 70, identifier:join; 71, list; 72, attribute; 73, argument_list; 74, string_content:/; 75, identifier:uri; 76, identifier:date; 77, identifier:date; 78, identifier:strftime; 79, string:"%Y-%m-%d"
code: def topports(sort_by='records', limit=10, date=None, return_format=None):
      """Information about top ports for a particular date with return limit.
  
      :param sort_by: one of 'records', 'targets', 'sources'
      :param limit: number of records to be returned
      :param date: an optional string in 'Y-M-D' format or datetime.date() object
      """
      uri = '/'.join(['topports', sort_by, str(limit)])
      if date:
          try:
              uri = '/'.join([uri, date.strftime("%Y-%m-%d")])
          except AttributeError:
              uri = '/'.join([uri, date])
      return _get(uri, return_format)