Return mail parser

@return Parser
542187
private function getParser()
    {
        if (null === $this->parser) {
            $this->parser = new Parser;
            $this->fixUniqueHeaders();
            $this->parser->setText($this->toString());
        }
        return $this->parser;
    }
593184
protected function buildEmail()
    {
        $email = $this->getEmailObject();

        $email->setSubject($this->getSubject());
        $email->setRecipient($this->getRecipient());
        $email->setFrom($this->getSender());
        $email->setBody($this->getBody());

        return $email;
    }
1325437
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->addSubcommand('initialize', [
            'help' => 'Execute The Initialize-method. This will add some important data to your database.',
            'parser' => $this->Initialize->getOptionParser(),
        ]);
        $parser->addSubcommand('user', [
            'help' => 'Execute The User-task. You will be able to create an user.',
            'parser' => $this->User->getOptionParser(),
        ]);

        return $parser;
    }
513224
public function getYamlParser()
    {
        if ($this->yamlParser === null) {
            $this->yamlParser = new \Symfony\Component\Yaml\Parser();
            $this->triggerEvent('onYamlParserRegistered', array(&$this->yamlParser));
        }

        return $this->yamlParser;
    }
879393
public function getEmail() : ?string 
    {
        if ( ! $this->hasEmail()) {
            $this->setEmail($this->getDefaultEmail());
        }
        return $this->email;
    }
358203
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->addOption('bootstrap', [
                    'short' => 'b',
                    'help' => 'Will load bootstrap.php from plugin.',
                    'boolean' => true,
                    'default' => false,
                ])
                ->addOption('routes', [
                    'short' => 'r',
                    'help' => 'Will load routes.php from plugin.',
                    'boolean' => true,
                    'default' => false,
                ])
                ->addOption('autoload', [
                    'help' => 'Will autoload the plugin using CakePHP.' .
                        'Set to true if you are not using composer to autoload your plugin.',
                    'boolean' => true,
                    'default' => false,
                ])
                ->addOption('cli', [
                    'help' => 'Use the bootstrap_cli file.',
                    'boolean' => true,
                    'default' => false,
                ])
                ->addOption('no_app', [
                    'help' => 'Do not update the Application if it exist. Forces config/bootstrap.php to be updated.',
                    'boolean' => true,
                    'default' => false,
                ])
                ->addArgument('plugin', [
                    'help' => 'Name of the plugin to load.',
                ]);

        return $parser;
    }
381928
public function getOptionParser() {
		$parser = parent::getOptionParser();

		$infoParser = $parser->toArray();
		$infoParser['arguments']['url'] = [
			'help' => 'Absolute URL',
			'required' => false
		];

		$parser->description('Cache Shell to cleanup caching of view files.')
				->addSubcommand('status', [
					'help' => 'Status information about the files',
					'parser' => $infoParser,
				])
				->addSubcommand('clear', [
					'help' => 'Clear all or part of the files',
					'parser' => $parser
				]);

		return $parser;
	}
332841
public function getOptionParser()
    {
        $parser = new ConsoleOptionParser('console');
        $parser
            ->description("This shell clean the cache of your application.")
            ->command("cache.clear")
            ->addOption('all', [
                'short' => 'a',
                'help' => 'Clear all caches',
                'boolean' => true,
            ])

            ->addSubcommand('all', [
                'help' => 'Clear all caches',
            ])
            ;

        foreach ( $this->tasks as $task => $option ) {
            $classname = $this->taskClassname($task);

            $parser->addSubcommand($this->taskName($task), [
                'help' => $this->$classname->help(),
                'parser' => $this->$classname->getOptionParser(),
            ]);
        }

        return $parser;
    }
1165570
protected function getDocCommentParser()
    {
        if (!is_object($this->docCommentParser)) {
            $this->docCommentParser = new DocCommentParser;
            $this->docCommentParser->parseDocComment($this->getDocComment());
        }
        return $this->docCommentParser;
    }
1266892
public function getOptionParser()
    {
        $parser = new ConsoleOptionParser('console');
        $parser->setDescription('Validate modules configuration');
        $parser->addArgument('modules', [
            'help' => 'Comma-separated list of modules to validate.  All will be checked if omitted.',
        ]);
        $parser->addOption('no-warnings', [
            'short' => 'n',
            'help' => 'Skip warnings (display only errors)',
            'default' => false,
            'boolean' => true,
        ]);

        return $parser;
    }
1113234
protected function prepareParser()
    {
        return function (InlineParserInterface $stack, AbstractInlineParser $parser) {
            $parser->setNextParser($stack);
            $parser->setContext($this);

            return $parser;
        };
    }
691641
def get_optparser(self):
        """"""
        p = Cmdln.get_optparser(self)
        p.add_option(
            "-M",
            "--maildir",
            action="store",
            dest="maildir"
            )
        p.add_option(
            "-V",
            "--verbose",
            action="store_true",
            dest="verbose"
            )
        return p
1253900
protected function parseRouteProcessor()
    {
        $frameworkProcessors = $this->builder->processors();

        $translator = $this->routeTranslator();
        return $frameworkProcessors->httpParseRoute($translator);
    }
81441
public static function parser()
	{
		if ( ! empty(static::$_parser))
		{
			return static::$_parser;
		}

		// Parser
		static::$_parser = new Smarty();
		static::$_parser->template_dir      = \Config::get('parser.View_Smarty.environment.template_dir', APPPATH.'views'.DS);
		static::$_parser->compile_dir       = \Config::get('parser.View_Smarty.environment.compile_dir', APPPATH.'tmp'.DS.'Smarty'.DS.'templates_c'.DS);
		static::$_parser->config_dir        = \Config::get('parser.View_Smarty.environment.config_dir', APPPATH.'tmp'.DS.'Smarty'.DS.'configs'.DS);
		static::$_parser->cache_dir         = \Config::get('parser.View_Smarty.environment.cache_dir', APPPATH.'cache'.DS.'Smarty'.DS);
		$plugins_dir 						= \Config::get('parser.View_Smarty.environment.plugins_dir', array());
		static::$_parser->addPluginsDir($plugins_dir);

		static::$_parser->caching           = \Config::get('parser.View_Smarty.environment.caching', false);
		static::$_parser->cache_lifetime    = \Config::get('parser.View_Smarty.environment.cache_lifetime', 0);
		static::$_parser->force_compile     = \Config::get('parser.View_Smarty.environment.force_compile', false);
		static::$_parser->compile_check     = \Config::get('parser.View_Smarty.environment.compile_check', true);
		static::$_parser->debugging         = \Config::get('parser.View_Smarty.environment.debugging', false);

		static::$_parser->left_delimiter    = \Config::get('parser.View_Smarty.delimiters.left', '{');
		static::$_parser->right_delimiter   = \Config::get('parser.View_Smarty.delimiters.right', '}');

		static::$_parser->autoload_filters  = \Config::get('parser.View_Smarty.environment.autoload_filters', array());
		static::$_parser->default_modifiers = \Config::get('parser.View_Smarty.environment.default_modifiers', array());
                foreach (\Config::get('parser.View_Smarty.extensions', array()) as $extension){
                    new $extension(static::$_parser);
                }
		return static::$_parser;
	}
1012577
def parser():
    """"""
    query_parser = current_app.config['COLLECTIONS_QUERY_PARSER']
    if isinstance(query_parser, six.string_types):
        query_parser = import_string(query_parser)
        return query_parser
1270046
public function parse()
    {
        // Validate user based regex
        try {
            preg_match(
                config("{$this->configBase}.parser.file_regex"),
                '',
                $matches
            );

        } catch (\Exception $e) {
            $this->warningCount++;

            return $this->failed('Configuration error in the regular expression');
        }

        foreach ($this->parsedMail->getAttachments() as $attachment) {
            if (strpos($attachment->filename, '.zip') !== false
                && ($attachment->contentType == 'application/octet-stream'
                        || $attachment->contentType == 'application/zip'
                )
            ) {
                $zip = new Zipper;

                if (!$this->createWorkingDir()) {
                    return $this->failed(
                        "Unable to create working directory"
                    );
                }

                file_put_contents($this->tempPath . $attachment->filename, $attachment->getContent());

                $zip->zip($this->tempPath . $attachment->filename);
                $zip->extractTo($this->tempPath);

                foreach ($zip->listFiles() as $index => $compressedFile) {
                    if (strpos($compressedFile, '.csv') !== false) {
                        // For each CSV file we find, we are going to do magic (however they usually only send 1 zip)
                        if (preg_match(
                            config("{$this->configBase}.parser.file_regex"),
                            $compressedFile,
                            $matches
                        )) {
                            $this->feedName = $matches[1];

                            // If feed is known and enabled, validate data and save report
                            if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                                $csvReports = new Reader\CsvReader(
                                    new SplFileObject($this->tempPath . $compressedFile)
                                );
                                $csvReports->setHeaderRowNumber(0);

                                foreach ($csvReports as $report) {

                                    // Handle field mappings first
                                    $aliasses = config("{$this->configBase}.feeds.{$this->feedName}.aliasses");
                                    if (is_array($aliasses)) {
                                        foreach ($aliasses as
                                                 $alias => $real) {
                                            if (array_key_exists($alias, $report)) {
                                                $report[$real] = $report[$alias];
                                                unset($report[$alias]);
                                            }
                                        }
                                    }
                                    /*
                                     * Emergency fix for major false positives from shadowserver feed
                                     * This only happens under very specific conditions and will be filtered out
                                     * as specific as possible.
                                     */
                                    if ($this->feedName == 'spam_url') {
                                        $urlFilter = '/([a-zA-Z]{3,5}.[a-zA-Z]{3,5}.com)/';
                                        if( $report['src_geo'] == 'RU' &&
                                            $report['url'] == "http://{$report['host']}" &&
                                            $report['src_asn'] == "8402" &&
                                            preg_match($urlFilter, $report['host'], $filterMatches)
                                        ) {
                                            continue;
                                        }
                                    }

                                    /*
                                     * Legacy 3.x fix for migrations.
                                     *
                                     * This resolves shadowserver errors where the CSV was send in duplicate resulting
                                     * in the header fields being used as data. If the header is detected the row can
                                     * be skipped safely
                                     */
                                    if ($report['ip'] === 'ip') {
                                        continue;
                                    }

                                    // Sanity check
                                    if ($this->hasRequiredFields($report) === true) {
                                        // incident has all requirements met, filter and add!
                                        $report = $this->applyFilters($report);

                                        $incident = new Incident();
                                        $incident->source      = config("{$this->configBase}.parser.name");
                                        $incident->source_id   = false;
                                        $incident->ip          = $report['ip'];
                                        $incident->domain      = false;
                                        $incident->class       =
                                            config("{$this->configBase}.feeds.{$this->feedName}.class");
                                        $incident->type        =
                                            config("{$this->configBase}.feeds.{$this->feedName}.type");
                                        $incident->timestamp   = strtotime($report['timestamp']);
                                        $incident->information = json_encode($report);

                                        // some rows have a domain, which is an optional column we want to register
                                        switch ($this->feedName) {
                                            case "spam_url":
                                                if (isset($report['url'])) {
                                                    $incident->domain = getDomain($report['url']);
                                                }
                                                break;
                                            case "ssl_scan":
                                                if (isset($report['subject_common_name'])) {

                                                    /*
                                                     * Common name does not add http://, but that is required for
                                                     * the domain helper check so lets add it manually
                                                     */
                                                    $testurl = "http://{$report['subject_common_name']}";

                                                    $incident->domain = getDomain($testurl);
                                                }
                                                break;
                                            case "compromised_website":
                                                if (isset($report['http_host'])) {
                                                    $incident->domain = getDomain($report['http_host']);
                                                }
                                                break;
                                        }

                                        $this->incidents[] = $incident;

                                    } //End hasRequired fields
                                } // End foreach report loop
                            } // End isKnown & isEnabled
                        } else { // Pregmatch failed to get feedName from attachment
                            $this->warningCount++;
                        }
                    } else { // Attached file is not a CSV within a ZIP file
                        $this->warningCount++;
                    }
                } // End each file in ZIP attachment loop
            } // End if not a ZIP attachment
        } // End foreach attachment loop

        return $this->success();
    }
990196
public function getOptionParser()
    {
        $parser = parent::getOptionParser();

        $parser->addSubcommand('makedocs', [
            'description' => __('Crawl-generate fresh swagger file system documents for all entries found in the library.')
        ])
        ->addArgument('host', [
            'help' => __("Swagger host FQDN (without protocol) as to be inserted into the swagger doc property 'host'"),
            'required' => true
        ]);

        return $parser;
    }