<commit_before># Standard library modules.
import fnmatch
import logging
import os
import pipes
import sys
import time

# External dependencies.
import pip_accel
from deb_pkg_tools.control import merge_control_fields
from deb_pkg_tools.package import clean_package_tree
from debian.deb822 import Deb822
from stdeb import __version__ as stdeb_version

# Modules included in our package.
from py2deb.util import patch_control_file, run

# Initialize a logger for this module.
logger = logging.getLogger(__name__)

def build(context):
    debianize(context['package'], context['verbose'])
    patch_control(context['package'], context['config'])
    apply_script(context['package'], context['config'], context['verbose'])
    pip_accel.deps.sanity_check_dependencies(context['package'].name, context['auto_install'])
    clean_package_tree(context['package'].directory)
    return dpkg_buildpackage(context['package'], context['verbose'])

def debianize(package, verbose):
    """
    Debianize a Python package using stdeb.
    """
    logger.debug('Debianizing %s', package.name)
    python = os.path.join(sys.prefix, 'bin', 'python')
    command = [python, 'setup.py', '--command-packages=stdeb.command', 'debianize']
    if stdeb_version == '0.6.0': # The "old" version of stdeb.
        command.append('--ignore-install-requires')
    if run(' '.join(command), package.directory, verbose):
        raise Exception, "Failed to debianize package! (%s)" % package.name
    logger.debug('Debianized %s', package.name)

def patch_control(package, config):
    """
    Patch the control file of a 'Debianized' Python package (see
    :py:func:`debianize()`) to modify the package metadata and inject the
    Python package's dependencies as Debian package dependencies.
    """
    logger.debug('Patching control file of %s', package.name)<commit_msg>Minor change to stdeb backend<commit_after># Standard library modules.
import fnmatch
import logging
import os
import pipes
import sys
import time

# External dependencies.
from deb_pkg_tools.control import merge_control_fields
from deb_pkg_tools.package import clean_package_tree
from debian.deb822 import Deb822
from pip_accel.deps import sanity_check_dependencies
from stdeb import __version__ as stdeb_version

# Modules included in our package.
from py2deb.util import patch_control_file, run

# Initialize a logger for this module.
logger = logging.getLogger(__name__)

def build(context):
    debianize(context['package'], context['verbose'])
    patch_control(context['package'], context['config'])
    apply_script(context['package'], context['config'], context['verbose'])
    sanity_check_dependencies(context['package'].name, context['auto_install'])
    clean_package_tree(context['package'].directory)
    return dpkg_buildpackage(context['package'], context['verbose'])

def debianize(package, verbose):
    """
    Debianize a Python package using stdeb.
    """
    logger.debug('Debianizing %s', package.name)
    python = os.path.join(sys.prefix, 'bin', 'python')
    command = [python, 'setup.py', '--command-packages=stdeb.command', 'debianize']
    if stdeb_version == '0.6.0': # The "old" version of stdeb.
        command.append('--ignore-install-requires')
    if run(' '.join(command), package.directory, verbose):
        raise Exception, "Failed to debianize package! (%s)" % package.name
    logger.debug('Debianized %s', package.name)

def patch_control(package, config):
    """
    Patch the control file of a 'Debianized' Python package (see
    :py:func:`debianize()`) to modify the package metadata and inject the
    Python package's dependencies as Debian package dependencies.
    """
    logger.debug('Patching control file of %s', package.name)
{'fraction_non_alphanumeric': 0.11819887429643527, 'fraction_numerical': 0.005360493165371214, 'mean_word_length': 4.961661341853035, 'pattern_counts': {'":': 0, '<': 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': '7535783', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1040, 'n_words': 309}