<commit_before># -*- coding: utf-8 -*-

import logging
import os

from jinja2 import Environment, FileSystemLoader

from cekit import tools
from cekit.descriptor import Image, Overrides
from cekit.errors import CekitError
from cekit.module import copy_module_to_target
from cekit.template_helper import TemplateHelper
from cekit.descriptor.resource import Resource

logger = logging.getLogger('cekit')


class Generator(object):
    """This class process Image descriptor(self.image) and uses it to generate
    target directory by fetching all dependencies and artifacts

    Args:
      descriptor_path - path to an image descriptor
      target - path to target directory
      builder - builder type
      overrides - path to overrides file (can be None)
    """

    def __new__(cls, descriptor_path, target, builder, overrides):
        if cls is Generator:
            if 'docker' == builder:
                from cekit.generator.docker import DockerGenerator as GeneratorImpl
                logger.info('Generating files for Docker engine.')
            elif 'osbs' == builder:
                from cekit.generator.osbs import OSBSGenerator as GeneratorImpl
                logger.info('Generating files for OSBS engine.')
            else:
                raise CekitError("Unsupported generator type: '%s'" % builder)
        return super(Generator, cls).__new__(GeneratorImpl)

    def __init__(self, descriptor_path, target, builder, overrides):
        self._type = builder
        descriptor = tools.load_descriptor(descriptor_path)

        # if there is a local modules directory and no modules are defined
        # we will inject it for a backward compatibility
        local_mod_path = os.path.join(os.path.abspath(os.path.dirname(descriptor_path)), 'modules')
        if os.path.exists(local_mod_path) and 'modules' in descriptor:
            modules = descriptor.get('modules')
            if not modules.get('repositories'):
                modules['repositories'] = [{'path': local_mod_path, 'name': 'modules'}]

        self.image = Image(descriptor, os.path.dirname(os.path.abspath(descriptor_path)))
        self.target = target<commit_msg>Fixed Buildah enigne to use Docker Generator as bud is used.<commit_after># -*- coding: utf-8 -*-

import logging
import os

from jinja2 import Environment, FileSystemLoader

from cekit import tools
from cekit.descriptor import Image, Overrides
from cekit.errors import CekitError
from cekit.module import copy_module_to_target
from cekit.template_helper import TemplateHelper
from cekit.descriptor.resource import Resource

logger = logging.getLogger('cekit')


class Generator(object):
    """This class process Image descriptor(self.image) and uses it to generate
    target directory by fetching all dependencies and artifacts

    Args:
      descriptor_path - path to an image descriptor
      target - path to target directory
      builder - builder type
      overrides - path to overrides file (can be None)
    """

    def __new__(cls, descriptor_path, target, builder, overrides):
        if cls is Generator:
            if 'docker' == builder or 'buildah' == builder:
                from cekit.generator.docker import DockerGenerator as GeneratorImpl
                logger.info('Generating files for Docker engine.')
            elif 'osbs' == builder:
                from cekit.generator.osbs import OSBSGenerator as GeneratorImpl
                logger.info('Generating files for OSBS engine.')
            else:
                raise CekitError("Unsupported generator type: '%s'" % builder)
        return super(Generator, cls).__new__(GeneratorImpl)

    def __init__(self, descriptor_path, target, builder, overrides):
        self._type = builder
        descriptor = tools.load_descriptor(descriptor_path)

        # if there is a local modules directory and no modules are defined
        # we will inject it for a backward compatibility
        local_mod_path = os.path.join(os.path.abspath(os.path.dirname(descriptor_path)), 'modules')
        if os.path.exists(local_mod_path) and 'modules' in descriptor:
            modules = descriptor.get('modules')
            if not modules.get('repositories'):
                modules['repositories'] = [{'path': local_mod_path, 'name': 'modules'}]

        self.image = Image(descriptor, os.path.dirname(os.path.abspath(descriptor_path)))
        self.target = target
{'fraction_non_alphanumeric': 0.08195232690124858, 'fraction_numerical': 0.0009080590238365494, 'mean_word_length': 3.0054545454545454, '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': '7022187', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1138, 'n_words': 380}