<commit_before>// Copyright 2012 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package juju

import (
	"bytes"
	"regexp"
)

// filterOutput filters output from juju.
//
// It removes all lines that do not contain useful output, like juju's logging
// and Python's deprecation warnings.
func filterOutput(output []byte) []byte {
	var result [][]byte
	var ignore bool
	deprecation := []byte("DeprecationWarning")
	regexLog := regexp.MustCompile(`^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}`)
	regexSshWarning := regexp.MustCompile(`^Warning: Permanently added`)
	regexPythonWarning := regexp.MustCompile(`^.*warnings.warn`)
	regexUserWarning := regexp.MustCompile(`^.*UserWarning`)
	lines := bytes.Split(output, []byte{'\n'})
	for _, line := range lines {
		if ignore {
			ignore = false
			continue
		}
		if bytes.Contains(line, deprecation) {
			ignore = true
			continue
		}
		if !regexSshWarning.Match(line) &&
			!regexLog.Match(line) &&
			!regexPythonWarning.Match(line) &&
			!regexUserWarning.Match(line) {
			result = append(result, line)
		}
	}
	return bytes.Join(result, []byte{'\n'})
}<commit_msg>provision/juju: log output beforing filtering<commit_after>// Copyright 2013 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package juju

import (
	"bytes"
	"github.com/globocom/tsuru/log"
	"regexp"
)

// filterOutput filters output from juju.
//
// It removes all lines that do not contain useful output, like juju's logging
// and Python's deprecation warnings.
func filterOutput(output []byte) []byte {
	log.Printf("[juju] filtering output:\n%s", output)
	var result [][]byte
	var ignore bool
	deprecation := []byte("DeprecationWarning")
	regexLog := regexp.MustCompile(`^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}`)
	regexSshWarning := regexp.MustCompile(`^Warning: Permanently added`)
	regexPythonWarning := regexp.MustCompile(`^.*warnings.warn`)
	regexUserWarning := regexp.MustCompile(`^.*UserWarning`)
	lines := bytes.Split(output, []byte{'\n'})
	for _, line := range lines {
		if ignore {
			ignore = false
			continue
		}
		if bytes.Contains(line, deprecation) {
			ignore = true
			continue
		}
		if !regexSshWarning.Match(line) &&
			!regexLog.Match(line) &&
			!regexPythonWarning.Match(line) &&
			!regexUserWarning.Match(line) {
			result = append(result, line)
		}
	}
	return bytes.Join(result, []byte{'\n'})
}
{'fraction_non_alphanumeric': 0.1509358821186778, 'fraction_numerical': 0.00796495420151334, 'mean_word_length': 4.179381443298969, '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': '2193548', 'n_tokens_mistral': 909, 'n_tokens_neox': 831, 'n_words': 219}