<commit_before>import os, re, sys, subprocess

from argparse import ArgumentParser
from glob import glob

class DockerImage:
    def __init__(self, dockerfile, versioned=False):
        self.dockerfile = dockerfile
        self.dockerfile_folder = os.path.dirname(self.dockerfile)
        self.versioned = versioned
        self._set_name()
        self._set_parent_name()
        self._extra_build()

    def _set_parent_name(self):
        df = open(self.dockerfile).read()
        m = re.search('FROM\s+([a-z0-9\/\-\:\.]+)', df)
        self.parent_name = (m.group(1)).strip()

    def _set_name(self):
        df_location = os.path.dirname(self.dockerfile)
        self.name = os.path.split(df_location)[1]
        self.full_name = "apiaryio/" + self.name

        if self.versioned:
            self.tag = self.name
        else
            self.tag = 'latest'
        self.full_name = "apiaryio/{0}:{1}".format(self.name, self.tag)
        self.print_name = "apiaryio/{0}_{1}".format(self.name, self.tag)

    def _extra_build(self):
        df_location = os.path.dirname(self.dockerfile)
        if os.path.isfile(os.path.join(df_location, 'build.sh')):
            self.extra = True
        else:
            self.extra = False

def update_images_to_rebuild(rebuild_all, changed_files=None):
    if rebuild_all or not changed_files:
        print('Rebuilding all images')
        images_to_rebuild.update([image.full_name for image in all_images.values()])
    else:
        print('Selecting images for rebuild')
        for cf in changed_files:
            for image in all_images.values():
                if image.name in cf:
                    if image.versioned and image.tag not in cf:
                        print("Won't add {0} as nothing changed for this tag".format(image.full_name))
                        continue
                    print('Adding {0} because {1} has changed'.format(image.full_name, cf))
                    images_to_rebuild.add(image.full_name)
            if len(images_to_rebuild) != len(all_images):<commit_msg>fix: syntax error<commit_after>import os, re, sys, subprocess

from argparse import ArgumentParser
from glob import glob

class DockerImage:
    def __init__(self, dockerfile, versioned=False):
        self.dockerfile = dockerfile
        self.dockerfile_folder = os.path.dirname(self.dockerfile)
        self.versioned = versioned
        self._set_name()
        self._set_parent_name()
        self._extra_build()

    def _set_parent_name(self):
        df = open(self.dockerfile).read()
        m = re.search('FROM\s+([a-z0-9\/\-\:\.]+)', df)
        self.parent_name = (m.group(1)).strip()

    def _set_name(self):
        df_location = os.path.dirname(self.dockerfile)
        self.name = os.path.split(df_location)[1]
        if self.versioned:
            self.tag = self.name
            self.name = os.path.split(os.path.dirname(df_location))[1]
        else:
            self.tag = 'latest'
        self.full_name = "apiaryio/{0}:{1}".format(self.name, self.tag)
        self.print_name = "{0}_{1}".format(self.name, self.tag)

    def _extra_build(self):
        df_location = os.path.dirname(self.dockerfile)
        if os.path.isfile(os.path.join(df_location, 'build.sh')):
            self.extra = True
        else:
            self.extra = False

def update_images_to_rebuild(rebuild_all, changed_files=None):
    if rebuild_all or not changed_files:
        print('Rebuilding all images')
        images_to_rebuild.update([image.full_name for image in all_images.values()])
    else:
        print('Selecting images for rebuild')
        for cf in changed_files:
            for image in all_images.values():
                if image.name in cf:
                    if image.versioned and image.tag not in cf:
                        print("Won't add {0} as nothing changed for this tag".format(image.full_name))
                        continue
                    print('Adding {0} because {1} has changed'.format(image.full_name, cf))
                    images_to_rebuild.add(image.full_name)
            if len(images_to_rebuild) != len(all_images):
{'fraction_non_alphanumeric': 0.11619462599854757, 'fraction_numerical': 0.005567659162430404, 'mean_word_length': 2.2612470402525653, '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': '2724000', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1254, 'n_words': 264}