<commit_before>import os
import sys

from bento.core.utils import \
        find_package
from bento.installed_package_description import \
        InstalledPkgDescription, InstalledSection, ipkg_meta_from_pkg

from bento.commands.core \
    import \
        Option
from bento.commands \
    import \
        build_distutils
from bento.commands \
    import \
        build_yaku
from bento.commands.core import \
        Command
from bento.commands.configure import \
        get_configured_state
from bento.commands.script_utils import \
        create_posix_script, create_win32_script

class BuildCommand(Command):
    long_descr = """\
Purpose: build the project
Usage:   bentomaker build [OPTIONS]."""
    short_descr = "build the project."
    opts = Command.opts

    def run(self, ctx):
        opts = ctx.cmd_opts
        self.set_option_parser()
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if ctx.get_user_data()["use_distutils"]:
            build_extensions = build_distutils.build_extensions
        else:
            build_extensions = build_yaku.build_extensions

        s = get_configured_state()
        pkg = s.pkg

        section_writer = SectionWriter()
        section_writer.update_sections(pkg)
        section_writer.sections_callbacks["extension"] = \
                build_extensions
        section_writer.store()

class SectionWriter(object):
    def __init__(self):
        self.sections_callbacks = {
            "pythonfiles": build_python_files,
            "datafiles": build_data_files,
            "extension": build_distutils.build_extensions,
            "executable": build_executables
        }
        self.sections = {}
        for k in self.sections_callbacks:
            self.sections[k] = {}

    def update_sections(self, pkg):
        for name, updater in self.sections_callbacks.iteritems():
            self.sections[name].update(updater(pkg))

    def store(self, filename="installed-pkg-info"):
        s = get_configured_state()<commit_msg>BUG: update section *after* setting callbacks.<commit_after>import os
import sys

from bento.core.utils import \
        find_package
from bento.installed_package_description import \
        InstalledPkgDescription, InstalledSection, ipkg_meta_from_pkg

from bento.commands.core \
    import \
        Option
from bento.commands \
    import \
        build_distutils
from bento.commands \
    import \
        build_yaku
from bento.commands.core import \
        Command
from bento.commands.configure import \
        get_configured_state
from bento.commands.script_utils import \
        create_posix_script, create_win32_script

class BuildCommand(Command):
    long_descr = """\
Purpose: build the project
Usage:   bentomaker build [OPTIONS]."""
    short_descr = "build the project."
    opts = Command.opts

    def run(self, ctx):
        opts = ctx.cmd_opts
        self.set_option_parser()
        o, a = self.parser.parse_args(opts)
        if o.help:
            self.parser.print_help()
            return

        if ctx.get_user_data()["use_distutils"]:
            build_extensions = build_distutils.build_extensions
        else:
            build_extensions = build_yaku.build_extensions

        s = get_configured_state()
        pkg = s.pkg

        section_writer = SectionWriter()
        section_writer.sections_callbacks["extension"] = \
                build_extensions
        section_writer.update_sections(pkg)
        section_writer.store()

class SectionWriter(object):
    def __init__(self):
        self.sections_callbacks = {
            "pythonfiles": build_python_files,
            "datafiles": build_data_files,
            "extension": build_distutils.build_extensions,
            "executable": build_executables
        }
        self.sections = {}
        for k in self.sections_callbacks:
            self.sections[k] = {}

    def update_sections(self, pkg):
        for name, updater in self.sections_callbacks.iteritems():
            self.sections[name].update(updater(pkg))

    def store(self, filename="installed-pkg-info"):
        s = get_configured_state()
{'fraction_non_alphanumeric': 0.08454740864580845, 'fraction_numerical': 0.0009553379508000956, 'mean_word_length': 2.4697597348798674, 'pattern_counts': {'":': 8, '<': 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': '6576448', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1181, 'n_words': 242}