<commit_before><?php

namespace Paquito\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\ArrayInput;

class Normalize extends Command
{
    public $newStruct = array();
    public $distribution = array('Debian','Archlinux','Centos');

    protected function configure()
    {
        $this
            ->setName('normalize')
            ->setDescription('Normalize a YaML file')
            ->addArgument(
                'input',
                InputArgument::REQUIRED,
                'Name of the directory which contains the sources and the paquito.yaml file'
            )
            ->addArgument(
                'output',
                InputArgument::OPTIONAL,
                'Name of a YaML file'
            )
            ;
		
		}

		protected function check_file($package,$test,$file,$tab) {

		 	/* parcours des fichiers*/
			foreach ($tab as $key => $val) {
			 	/* si les fichiers ne sont pas sous forme d'un tableau de champs Source et Permission*/
				if (!is_array($val)) {
				 	/* champ contenant le fichier de destination*/
					$dest = $key;
					/* champ contenant un fichier source*/
				 	$source = $val;
					$permission = '755';
					if($test=='Test'){
						$this->newStruct['Packages'][$package][$test][$file][$dest] = array('Source' => $source,'Permissions' => $permission);
					}
					else {
						$this->newStruct['Packages'][$package][$file][$dest] = array('Source' => $source,'Permissions' => $permission);
					}
				
				
			 	} else {
					/* la structure est un tableau donc sous forme "Source , Permission", Rien ne change*/
					if($test=='Test'){
						$this->newStruct['Packages'][$package][$test][$file][$dest] =$val;
					}
					else {
						$this->newStruct['Packages'][$package][$file][$key] = $val;
					}
			 	}
			
			}
		}

		protected function check_dependencies($struct,$package,$field,$depend,$tab) {


				 /*je parcours la liste des dependances*/
                        foreach ($tab as $key => $val) {
                            /*champ contenant le nom de la dépendance*/
                            $d = $key;
                            /* la dependance est la méme pour toutes les ditributions*/
                            if ($val == '*') {
                                /*il faut normaliser */
                                $this->newStruct['Packages'][$package][$field][$depend][$d] = array('Debian' => array('All' => $d),'Archlinux' => array('All' => $d),'Centos' => array('All' => $d));
                            } else {

                                /* tableau contenant les dépendances pour les différentes distributions*/<commit_msg>include case where source and destination of field File are same<commit_after><?php

namespace Paquito\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\ArrayInput;

class Normalize extends Command
{
    public $newStruct = array();
    public $distribution = array('Debian','Archlinux','Centos');

    protected function configure()
    {
        $this
            ->setName('normalize')
            ->setDescription('Normalize a YaML file')
            ->addArgument(
                'input',
                InputArgument::REQUIRED,
                'Name of the directory which contains the sources and the paquito.yaml file'
            )
            ->addArgument(
                'output',
                InputArgument::OPTIONAL,
                'Name of a YaML file'
            )
            ;
		
		}

		protected function check_file($package,$test,$file,$tab) {

		 	/* parcours des fichiers*/
			foreach ($tab as $key => $val) {
			 	/* si les fichiers ne sont pas sous forme d'un tableau de champs Source et Permission*/
				if (!is_array($val)) {
				 	/* champ contenant le fichier de destination*/
					$dest = $key;
					/* champ contenant un fichier source*/
				 	$source = $val;
					$permission = '755';
					if($test=='Test'){
							if(empty(!$val)) {
									$this->newStruct['Packages'][$package][$test][$file][$dest] = array('Source' => $source,'Permissions' => $permission);
							}
							else {
									$this->newStruct['Packages'][$package][$test][$file][$dest] = array('Source' => $dest,'Permissions' => $permission);
							}
					}
					else {
							if(empty(!$val)) {
									$this->newStruct['Packages'][$package][$file][$dest] = array('Source' => $source,'Permissions' => $permission);
							}
							else {
									$this->newStruct['Packages'][$package][$file][$dest] = array('Source' => $dest,'Permissions' => $permission);
							}
					}
				
				
			 	} else {
					/* la structure est un tableau donc sous forme "Source , Permission", Rien ne change*/
					if($test=='Test'){
						$this->newStruct['Packages'][$package][$test][$file][$dest] =$val;
					}
					else {
						$this->newStruct['Packages'][$package][$file][$key] = $val;
					}
			 	}
			
			}
		}

		protected function check_dependencies($struct,$package,$field,$depend,$tab) {


				 /*je parcours la liste des dependances*/
                        foreach ($tab as $key => $val) {
                            /*champ contenant le nom de la dépendance*/
                            $d = $key;
                            /* la dependance est la méme pour toutes les ditributions*/
                            if ($val == '*') {
                                /*il faut normaliser */
                                $this->newStruct['Packages'][$package][$field][$depend][$d] = array('Debian' => array('All' => $d),'Archlinux' => array('All' => $d),'Centos' => array('All' => $d));
                            } else {

                                /* tableau contenant les dépendances pour les différentes distributions*/
{'fraction_non_alphanumeric': 0.14707824364476724, 'fraction_numerical': 0.0009904258831297458, 'mean_word_length': 2.0897501274859764, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5738267', 'n_tokens_mistral': 2014, 'n_tokens_neox': 1671, 'n_words': 389}