nodes: 0, module; 1, function_definition; 2, function_name:AddShapePointObjectUnsorted; 3, parameters; 4, block; 5, identifier:self; 6, identifier:shapepoint; 7, identifier:problems; 8, expression_statement; 9, if_statement; 10, if_statement; 11, if_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, comment:"""Insert a point into a correct position by sequence. """; 17, parenthesized_expression; 18, block; 19, elif_clause; 20, else_clause; 21, comparison_operator:shapepoint.shape_pt_sequence in self.sequence; 22, block; 23, boolean_operator; 24, block; 25, comparison_operator:shapepoint.shape_dist_traveled > self.max_distance; 26, block; 27, call; 28, call; 29, call; 30, boolean_operator; 31, expression_statement; 32, comparison_operator:shapepoint.shape_pt_sequence <= self.sequence[0]; 33, block; 34, block; 35, attribute; 36, attribute; 37, expression_statement; 38, comparison_operator:shapepoint.shape_dist_traveled is not None; 39, comparison_operator:len(self.sequence) > 0; 40, if_statement; 41, if_statement; 42, attribute; 43, attribute; 44, expression_statement; 45, attribute; 46, argument_list; 47, attribute; 48, argument_list; 49, attribute; 50, argument_list; 51, comparison_operator:len(self.sequence) == 0; 52, comparison_operator:shapepoint.shape_pt_sequence >= self.sequence[-1]; 53, assignment; 54, attribute; 55, subscript; 56, expression_statement; 57, expression_statement; 58, identifier:shapepoint; 59, identifier:shape_pt_sequence; 60, identifier:self; 61, identifier:sequence; 62, call; 63, attribute; 64, None; 65, call; 66, integer:0; 67, parenthesized_expression; 68, block; 69, parenthesized_expression; 70, block; 71, identifier:shapepoint; 72, identifier:shape_dist_traveled; 73, identifier:self; 74, identifier:max_distance; 75, assignment; 76, attribute; 77, identifier:insert; 78, identifier:index; 79, attribute; 80, attribute; 81, identifier:insert; 82, identifier:index; 83, attribute; 84, attribute; 85, identifier:insert; 86, identifier:index; 87, tuple; 88, call; 89, integer:0; 90, attribute; 91, subscript; 92, identifier:index; 93, call; 94, identifier:shapepoint; 95, identifier:shape_pt_sequence; 96, attribute; 97, integer:0; 98, assignment; 99, assignment; 100, attribute; 101, argument_list; 102, identifier:shapepoint; 103, identifier:shape_dist_traveled; 104, identifier:len; 105, argument_list; 106, boolean_operator; 107, expression_statement; 108, boolean_operator; 109, expression_statement; 110, attribute; 111, attribute; 112, identifier:self; 113, identifier:sequence; 114, identifier:shapepoint; 115, identifier:shape_pt_sequence; 116, identifier:self; 117, identifier:distance; 118, identifier:shapepoint; 119, identifier:shape_dist_traveled; 120, identifier:self; 121, identifier:points; 122, attribute; 123, attribute; 124, attribute; 125, identifier:len; 126, argument_list; 127, identifier:shapepoint; 128, identifier:shape_pt_sequence; 129, attribute; 130, unary_operator; 131, identifier:len; 132, argument_list; 133, identifier:self; 134, identifier:sequence; 135, identifier:index; 136, integer:0; 137, identifier:index; 138, call; 139, identifier:problems; 140, identifier:InvalidValue; 141, string; 142, attribute; 143, binary_operator:'The sequence number %d occurs more than once in '
                              'shape %s.' %
                              (shapepoint.shape_pt_sequence, self.shape_id); 144, attribute; 145, comparison_operator:index != len(self.sequence); 146, comparison_operator:shapepoint.shape_dist_traveled > self.distance[index]; 147, call; 148, comparison_operator:index > 0; 149, comparison_operator:shapepoint.shape_dist_traveled < self.distance[index - 1]; 150, call; 151, identifier:self; 152, identifier:max_distance; 153, identifier:shapepoint; 154, identifier:shape_dist_traveled; 155, identifier:shapepoint; 156, identifier:shape_pt_lat; 157, identifier:shapepoint; 158, identifier:shape_pt_lon; 159, identifier:shapepoint; 160, identifier:shape_dist_traveled; 161, attribute; 162, identifier:self; 163, identifier:sequence; 164, integer:1; 165, attribute; 166, attribute; 167, argument_list; 168, string_content:shape_pt_sequence; 169, identifier:shapepoint; 170, identifier:shape_pt_sequence; 171, concatenated_string; 172, tuple; 173, identifier:self; 174, identifier:sequence; 175, identifier:index; 176, call; 177, attribute; 178, subscript; 179, attribute; 180, argument_list; 181, identifier:index; 182, integer:0; 183, attribute; 184, subscript; 185, attribute; 186, argument_list; 187, identifier:self; 188, identifier:sequence; 189, identifier:self; 190, identifier:sequence; 191, identifier:bisect; 192, identifier:bisect; 193, attribute; 194, attribute; 195, string; 196, string; 197, attribute; 198, attribute; 199, identifier:len; 200, argument_list; 201, identifier:shapepoint; 202, identifier:shape_dist_traveled; 203, attribute; 204, identifier:index; 205, identifier:problems; 206, identifier:InvalidValue; 207, string; 208, attribute; 209, binary_operator:'Each subsequent point in a shape should have '
                                'a distance value that shouldn\'t be larger '
                                'than the next ones. In this case, the next '
                                'distance was %f.' % self.distance[index]; 210, identifier:shapepoint; 211, identifier:shape_dist_traveled; 212, attribute; 213, binary_operator:index - 1; 214, identifier:problems; 215, identifier:InvalidValue; 216, string; 217, attribute; 218, binary_operator:'Each subsequent point in a shape should have '
                                'a distance value that\'s at least as large as '
                                'the previous ones. In this case, the previous '
                                'distance was %f.' % self.distance[index - 1]; 219, identifier:self; 220, identifier:sequence; 221, identifier:shapepoint; 222, identifier:shape_pt_sequence; 223, string_content:The sequence number %d occurs more than once in; 224, string_content:shape %s.; 225, identifier:shapepoint; 226, identifier:shape_pt_sequence; 227, identifier:self; 228, identifier:shape_id; 229, attribute; 230, identifier:self; 231, identifier:distance; 232, string_content:shape_dist_traveled; 233, identifier:shapepoint; 234, identifier:shape_dist_traveled; 235, concatenated_string; 236, subscript; 237, identifier:self; 238, identifier:distance; 239, identifier:index; 240, integer:1; 241, string_content:shape_dist_traveled; 242, identifier:shapepoint; 243, identifier:shape_dist_traveled; 244, concatenated_string; 245, subscript; 246, identifier:self; 247, identifier:sequence; 248, string; 249, string; 250, string; 251, string; 252, attribute; 253, identifier:index; 254, string; 255, string; 256, string; 257, string; 258, attribute; 259, binary_operator:index - 1; 260, string_content:Each subsequent point in a shape should have; 261, string_content; 262, string_content:than the next ones. In this case, the next; 263, string_content:distance was %f.; 264, identifier:self; 265, identifier:distance; 266, string_content:Each subsequent point in a shape should have; 267, string_content; 268, string_content:the previous ones. In this case, the previous; 269, string_content:distance was %f.; 270, identifier:self; 271, identifier:distance; 272, identifier:index; 273, integer:1; 274, escape_sequence:\'; 275, escape_sequence:\'
code: def AddShapePointObjectUnsorted(self, shapepoint, problems):
      """Insert a point into a correct position by sequence. """
      if (len(self.sequence) == 0 or
          shapepoint.shape_pt_sequence >= self.sequence[-1]):
        index = len(self.sequence)
      elif shapepoint.shape_pt_sequence <= self.sequence[0]:
        index = 0
      else:
        index = bisect.bisect(self.sequence, shapepoint.shape_pt_sequence)
  
      if shapepoint.shape_pt_sequence in self.sequence:
        problems.InvalidValue('shape_pt_sequence', shapepoint.shape_pt_sequence,
                              'The sequence number %d occurs more than once in '
                              'shape %s.' %
                              (shapepoint.shape_pt_sequence, self.shape_id))
  
      if shapepoint.shape_dist_traveled is not None and len(self.sequence) > 0:
        if (index != len(self.sequence) and
            shapepoint.shape_dist_traveled > self.distance[index]):
          problems.InvalidValue('shape_dist_traveled',
                                shapepoint.shape_dist_traveled,
                                'Each subsequent point in a shape should have '
                                'a distance value that shouldn\'t be larger '
                                'than the next ones. In this case, the next '
                                'distance was %f.' % self.distance[index])
  
        if (index > 0 and
            shapepoint.shape_dist_traveled < self.distance[index - 1]):
          problems.InvalidValue('shape_dist_traveled',
                                shapepoint.shape_dist_traveled,
                                'Each subsequent point in a shape should have '
                                'a distance value that\'s at least as large as '
                                'the previous ones. In this case, the previous '
                                'distance was %f.' % self.distance[index - 1])
  
      if shapepoint.shape_dist_traveled > self.max_distance:
        self.max_distance = shapepoint.shape_dist_traveled
  
      self.sequence.insert(index, shapepoint.shape_pt_sequence)
      self.distance.insert(index, shapepoint.shape_dist_traveled)
      self.points.insert(index, (shapepoint.shape_pt_lat,
                                 shapepoint.shape_pt_lon,
                                 shapepoint.shape_dist_traveled))