<commit_before>

from h2.events import (
    ResponseReceived, DataReceived, RemoteSettingsChanged, StreamEnded,
    StreamReset, SettingsAcknowledged,RequestReceived   
)
from h2.events import _bytes_representation
import json

# sort the object by type
# give it to the method with the right encoding method

class FrameEventToJSON(json.JSONEncoder):

    def default(self, event):

        if isinstance(event, RequestReceived):
            return {"stream_id": event.stream_id,
                    "headers": event.headers}
        elif isinstance(event, DataReceived):
            return {"stream_id": event.stream_id,
            "flow_controlled_length": event.flow_controlled_length,
            "data": event.data}
        elif isinstance(event, RemoteSettingsChanged):
            return {"changed_settings": event.changed_settings}
        # elif isinstance(event, StreamEnded):
        # elif isinstance(event, StreamReset):
        elif isinstance(event, SettingsAcknowledged):
            return {"changed_settings": event.changed_settings}
        # elif isinstance(event, ResponseReceived()):
    

    # return the header object as a series of JSON-encodable arrays
    def parse_headers_to_JSON(self, event):
        pass<commit_msg>add passing method and test for parsing headers<commit_after>

from h2.events import (
    ResponseReceived, DataReceived, RemoteSettingsChanged, StreamEnded,
    StreamReset, SettingsAcknowledged,RequestReceived   
)
from h2.events import _bytes_representation
import json

# sort the object by type
# give it to the method with the right encoding method

class FrameEventToJSON(json.JSONEncoder):

    def default(self, event):

        if isinstance(event, RequestReceived):
            return {"stream_id": event.stream_id,
                    "headers": event.headers}
        elif isinstance(event, DataReceived):
            return {"stream_id": event.stream_id,
            "flow_controlled_length": event.flow_controlled_length,
            "data": event.data}
        elif isinstance(event, RemoteSettingsChanged):
            return {"changed_settings": event.changed_settings}
        # elif isinstance(event, StreamEnded):
        # elif isinstance(event, StreamReset):
        elif isinstance(event, SettingsAcknowledged):
            return {"changed_settings": event.changed_settings}
        elif isinstance(event, ResponseReceived):
            return {"stream_id": event.stream_id,
            "headers": self.parse_response_headers_to_JSON(event)} 

    # return the header object as a series of pairs in dictionary 
    def parse_response_headers_to_JSON(self, event):
        headers = event.headers
        return_dict = {}
        for header_pair in headers:
            return_dict[header_pair[0]] = header_pair[1]
        return return_dict

            
    
{'fraction_non_alphanumeric': 0.07898448519040903, 'fraction_numerical': 0.0021156558533145277, 'mean_word_length': 3.0586552217453504, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1402583', 'n_tokens_mistral': 727, 'n_tokens_neox': 700, 'n_words': 200}