<commit_before><?php

namespace Cravler\MaxMindGeoIpBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class UpdateDatabaseCommand extends Command
{
    /**
     * @var array
     */
    private $config = array();

    /**
     * @param array $config
     */
    public function __construct(array $config)
    {
        parent::__construct();

        $this->config = $config;
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName('cravler:maxmind:geoip-update')
            ->setDescription('Downloads and updates the MaxMind GeoIp2 database')
            ->addOption('no-md5-check', null, InputOption::VALUE_NONE, 'Disable MD5 check')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = $this->config;

        foreach ($config['source'] as $key => $source) {
            if (!$source) {
                continue;
            }

            $output->writeln('');
            $output->write(sprintf('Downloading %s... ', $source));

            $tmpFile = $this->downloadFile($source);
            if (false === $tmpFile) {
                $output->writeln('FAILED');
                $output->writeln(sprintf('<error>Error during file download occurred on %s</error>', $source));
                continue;
            }

            $output->writeln('<info>Done</info>');<commit_msg>Make UpdateDatabaseCommand lazy (#25)<commit_after><?php

namespace Cravler\MaxMindGeoIpBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

/**
 * @author <NAME> <<EMAIL>>
 */
class UpdateDatabaseCommand extends Command
{
    protected static $defaultName = 'cravler:maxmind:geoip-update';
    protected static $defaultDescription = 'Downloads and updates the MaxMind GeoIp2 database';
    
    /**
     * @var array
     */
    private $config = array();

    /**
     * @param array $config
     */
    public function __construct(array $config)
    {
        parent::__construct();

        $this->config = $config;
    }

    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        $this
            ->setName(static::$defaultName)
            ->setDescription(static::$defaultDescription)
            ->addOption('no-md5-check', null, InputOption::VALUE_NONE, 'Disable MD5 check')
        ;
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $config = $this->config;

        foreach ($config['source'] as $key => $source) {
            if (!$source) {
                continue;
            }

            $output->writeln('');
            $output->write(sprintf('Downloading %s... ', $source));

            $tmpFile = $this->downloadFile($source);
            if (false === $tmpFile) {
                $output->writeln('FAILED');
                $output->writeln(sprintf('<error>Error during file download occurred on %s</error>', $source));
                continue;
            }

            $output->writeln('<info>Done</info>');
{'fraction_non_alphanumeric': 0.14449870726802644, 'fraction_numerical': 0.002298190175237001, 'mean_word_length': 2.2756349952963313, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5695279', 'n_tokens_mistral': 974, 'n_tokens_neox': 954, 'n_words': 188}