<commit_before># Copyright 2013-present Barefoot Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
sys.path.append('../p4_hlir')
from p4_hlir.main import HLIR
from p4_hlir import hlir
import shutil
import math


p4_source = sys.argv[1]
absolute_source = os.path.join(os.getcwd(), p4_source)
if not os.path.isfile(absolute_source):
    print "Source file '" + p4_source + \
          "' could not be opened or does not exist."

input_hlir = HLIR(absolute_source)
input_hlir.build()

# Get a parser_state
for parse_state in input_hlir.p4_parse_states.itervalues():
    if len(parse_state.branch_on) > 0:
        if isinstance(parse_state.branch_on[0], hlir.p4_headers.p4_field):
            if parse_state.branch_on[0].instance.name == "ipv4":
                break
print parse_state

# Fields of the parser state
header_fields = parse_state.branch_on[0].instance.fields
protocol_name = 'p4_' + parse_state.branch_on[0].instance.name
# Write to file
dissector_filename = os.path.dirname(absolute_source) + "/" + "p4_dissector.lua"
shutil.copyfile('p4_dissector_template.lua', dissector_filename)
f = open(dissector_filename, "a")
<commit_msg>Re-org imports<commit_after># Copyright 2013-present Barefoot Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
import shutil
import math
sys.path.append('../p4_hlir')
from p4_hlir.main import HLIR
from p4_hlir import hlir


p4_source = sys.argv[1]
absolute_source = os.path.join(os.getcwd(), p4_source)
if not os.path.isfile(absolute_source):
    print "Source file '" + p4_source + \
          "' could not be opened or does not exist."

input_hlir = HLIR(absolute_source)
input_hlir.build()

# Get a parser_state
for parse_state in input_hlir.p4_parse_states.itervalues():
    if len(parse_state.branch_on) > 0:
        if isinstance(parse_state.branch_on[0], hlir.p4_headers.p4_field):
            if parse_state.branch_on[0].instance.name == "ipv4":
                break
print parse_state

# Fields of the parser state
header_fields = parse_state.branch_on[0].instance.fields
protocol_name = 'p4_' + parse_state.branch_on[0].instance.name
# Write to file
dissector_filename = os.path.dirname(absolute_source) + "/" + "p4_dissector.lua"
shutil.copyfile('p4_dissector_template.lua', dissector_filename)
f = open(dissector_filename, "a")

{'fraction_non_alphanumeric': 0.09596412556053811, 'fraction_numerical': 0.016143497757847534, 'mean_word_length': 4.370786516853933, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1153735', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1053, 'n_words': 329}