<commit_before># Copyright (c) <NAME>, TU Delft.
# All rights reserved.
# See COPYRIGHT for details.

import config
from install_package import InstallPackage
import os
import shutil
import utils
import sys

BASENAME = "Insight"
# password part of REPO spec
CVS_REPO = ":pserver:anonymous:insight@www.itk.org:/cvsroot/" + BASENAME
CVS_VERSION = "-r ITK-3-10-2" # 

CS_BASENAME = "CableSwig"
# password part of REPO spec
CS_CVS_REPO = ":pserver:anonymous@www.itk.org:/cvsroot/" + CS_BASENAME
# CableSwig doesn't have the full ITK-3-10-2 tag
CABLESWIG_CVS_VERSION = "-r ITK-3-10"

# this patch is located in johannes/patches/ teehee
SOGC_PATCH = "itk310-itkSpatialObjectTreeNode-GetChildren.diff"

dependencies = []


class ITK(InstallPackage):
    
    def __init__(self):
        self.source_dir = os.path.join(config.archive_dir, BASENAME)
        self.build_dir = os.path.join(config.build_dir, '%s-build' %
                                      (BASENAME,))
        self.inst_dir = os.path.join(config.inst_dir, BASENAME)

        self.sogc_patch_src_filename = os.path.join(
                config.patches_dir, SOGC_PATCH)
        self.sogc_patch_dst_filename = os.path.join(
                config.archive_dir, SOGC_PATCH)


    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("ITK already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CVS_REPO, CVS_VERSION, BASENAME))
            
            if ret != 0:
                utils.error("Could not CVS checkout ITK.  Fix and try again.")

            os.chdir(os.path.join(self.source_dir, 'Utilities'))
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CS_CVS_REPO, 
                                CABLESWIG_CVS_VERSION, CS_BASENAME))
            
            if ret != 0:
                utils.error("Could not CVS checkout CableSwig.  Fix and try again.")


        if not os.path.exists(self.sogc_patch_dst_filename):
            shutil.copy(self.sogc_patch_src_filename,
                        self.sogc_patch_dst_filename)

            utils.output("Applying SOGC patch")
            os.chdir(self.source_dir)
            ret = os.system(
                "%s -p0 < %s" % (config.PATCH, self.sogc_patch_dst_filename))

            if ret != 0:
                utils.error(
                    "Could not apply EXC patch.  Fix and try again.")


        # also the source dir for other installpackages that wish to build
        # WrapITK external projects<commit_msg>Changed logic of when to apply patches to ITK.<commit_after># Copyright (c) <NAME>, TU Delft.
# All rights reserved.
# See COPYRIGHT for details.

import config
from install_package import InstallPackage
import os
import shutil
import utils
import sys

BASENAME = "Insight"
# password part of REPO spec
CVS_REPO = ":pserver:anonymous:insight@www.<EMAIL>.<EMAIL>:/cvsroot/" + BASENAME
CVS_VERSION = "-r ITK-3-10-2" # 

CS_BASENAME = "CableSwig"
# password part of REPO spec
CS_CVS_REPO = ":pserver:anonymous@www.itk.org:/cvsroot/" + CS_BASENAME
# CableSwig doesn't have the full ITK-3-10-2 tag
CABLESWIG_CVS_VERSION = "-r ITK-3-10"

# this patch is located in johannes/patches/ teehee
SOGC_PATCH = "itk310-itkSpatialObjectTreeNode-GetChildren.diff"

dependencies = []


class ITK(InstallPackage):
    
    def __init__(self):
        self.source_dir = os.path.join(config.archive_dir, BASENAME)
        self.build_dir = os.path.join(config.build_dir, '%s-build' %
                                      (BASENAME,))
        self.inst_dir = os.path.join(config.inst_dir, BASENAME)

        self.sogc_patch_src_filename = os.path.join(
                config.patches_dir, SOGC_PATCH)
        self.sogc_patch_dst_filename = os.path.join(
                config.archive_dir, SOGC_PATCH)


    def get(self):
        if os.path.exists(self.source_dir):
            utils.output("ITK already checked out, skipping step.")

        else:
            os.chdir(config.archive_dir)
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CVS_REPO, CVS_VERSION, BASENAME))
            
            if ret != 0:
                utils.error("Could not CVS checkout ITK.  Fix and try again.")

            os.chdir(os.path.join(self.source_dir, 'Utilities'))
            ret = os.system("%s -d %s co %s %s" %
                            (config.CVS, CS_CVS_REPO, 
                                CABLESWIG_CVS_VERSION, CS_BASENAME))
            
            if ret != 0:
                utils.error("Could not CVS checkout CableSwig.  Fix and try again.")

            # only download patch if we don't have it
            # only do this check if we're already downloading source
            if not os.path.exists(self.sogc_patch_dst_filename):
                shutil.copy(self.sogc_patch_src_filename,
                            self.sogc_patch_dst_filename)

            # always try to apply patch if we've just checked out
            utils.output("Applying SOGC patch")
            os.chdir(self.source_dir)
            ret = os.system(
                "%s -p0 < %s" % (config.PATCH, self.sogc_patch_dst_filename))

            if ret != 0:
                utils.error(
                    "Could not apply EXC patch.  Fix and try again.")


        # also the source dir for other installpackages that wish to build
        # WrapITK external projects
{'fraction_non_alphanumeric': 0.09958280428079086, 'fraction_numerical': 0.006530019952838745, 'mean_word_length': 2.024684585847504, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5800763', 'n_tokens_mistral': 1847, 'n_tokens_neox': 1746, 'n_words': 424}