// NewCSVLineParser factory
968762
func NewCSVLineParser(fieldsString string, trimLeadingSpace bool) (*CSVLineParser, error) {
	// Is building a reader for every single line a good idea?
	// Potential for future optimization here
	reader := strings.NewReader(fieldsString)
	csvReader := csv.NewReader(reader)
	csvReader.TrimLeadingSpace = trimLeadingSpace

	fields, err := csvReader.Read()
	if err != nil {
		logrus.WithError(err).WithField("fields", fieldsString).
			Error("unable to parse list of fields")
		return nil, err
	}
	logrus.WithFields(logrus.Fields{
		"fields": fields,
	}).Debug("generated CSV fields")
	return &CSVLineParser{
		fields:           fields,
		numFields:        len(fields),
		trimLeadingSpace: trimLeadingSpace}, nil
}
705758
func NewCSV(path string) (*TokenAuthenticator, error) {
	file, err := os.Open(path)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	recordNum := 0
	tokens := make(map[string]*user.DefaultInfo)
	reader := csv.NewReader(file)
	reader.FieldsPerRecord = -1
	for {
		record, err := reader.Read()
		if err == io.EOF {
			break
		}
		if err != nil {
			return nil, err
		}
		if len(record) < 3 {
			return nil, fmt.Errorf("token file '%s' must have at least 3 columns (token, user name, user uid), found %d", path, len(record))
		}

		recordNum++
		if record[0] == "" {
			klog.Warningf("empty token has been found in token file '%s', record number '%d'", path, recordNum)
			continue
		}

		obj := &user.DefaultInfo{
			Name: record[1],
			UID:  record[2],
		}
		if _, exist := tokens[record[0]]; exist {
			klog.Warningf("duplicate token has been found in token file '%s', record number '%d'", path, recordNum)
		}
		tokens[record[0]] = obj

		if len(record) >= 4 {
			obj.Groups = strings.Split(record[3], ",")
		}
	}

	return &TokenAuthenticator{
		tokens: tokens,
	}, nil
}
764367
func (f *File) drawingParser(path string) (*xlsxWsDr, int) {
	cNvPrID := 1
	if f.Drawings[path] == nil {
		content := xlsxWsDr{}
		content.A = NameSpaceDrawingML
		content.Xdr = NameSpaceDrawingMLSpreadSheet
		_, ok := f.XLSX[path]
		if ok { // Append Model
			decodeWsDr := decodeWsDr{}
			_ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML(path)), &decodeWsDr)
			content.R = decodeWsDr.R
			cNvPrID = len(decodeWsDr.OneCellAnchor) + len(decodeWsDr.TwoCellAnchor) + 1
			for _, v := range decodeWsDr.OneCellAnchor {
				content.OneCellAnchor = append(content.OneCellAnchor, &xdrCellAnchor{
					EditAs:       v.EditAs,
					GraphicFrame: v.Content,
				})
			}
			for _, v := range decodeWsDr.TwoCellAnchor {
				content.TwoCellAnchor = append(content.TwoCellAnchor, &xdrCellAnchor{
					EditAs:       v.EditAs,
					GraphicFrame: v.Content,
				})
			}
		}
		f.Drawings[path] = &content
	}
	return f.Drawings[path], cNvPrID
}
136452
func (l *lexer) newline() {
	// adjust the counters for the new line
	if l._previous == nil {
		l._previous = make([]int, 0)
	}
	l._previous = append(l._previous, l._column)
	l._column = 1
	l._line++
}
469480
func NewParser(fs FileSystem) (Parser, error) {

	p := &parser{
		fs:        fs,
		rootScope: newScope(),
	}

	return p, nil
}
267423
func NewLineStringFlat(layout Layout, flatCoords []float64) *LineString {
	g := new(LineString)
	g.layout = layout
	g.stride = layout.Stride()
	g.flatCoords = flatCoords
	return g
}
322709
func NewParser(containerOS string) Parser {
	switch containerOS {
	case OSWindows:
		return &windowsParser{}
	}
	if runtime.GOOS == OSWindows {
		return &lcowParser{}
	}
	return &linuxParser{}
}
1270103
func NewParser(handler *MetricHandler) *Parser {
	return &Parser{
		machine: NewMachine(handler),
		handler: handler,
	}
}
410260
func NewLine(a, b *Point) *Line {
	return &Line{*a.Clone(), *b.Clone()}
}
1335919
func NewRegexLineParser(regexStrs []string) (*RegexLineParser, error) {
	lineRegexes, err := ParseLineRegexes(regexStrs)
	if err != nil {
		return nil, err
	}
	logrus.WithFields(logrus.Fields{
		"lineRegexes": lineRegexes,
	}).Debug("Compiled line regexes")
	return &RegexLineParser{lineRegexes}, nil
}
202883
func (w *Writer) CreateInline() (*InlineWriter, error) {
	var h message.Header
	h.Set("Content-Type", "multipart/alternative")

	mw, err := w.mw.CreatePart(h)
	if err != nil {
		return nil, err
	}
	return &InlineWriter{mw}, nil
}
309105
func zSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
	zz := make([]Z, n/2)
	for i := int64(0); i < n; i += 2 {
		var err error

		z := &zz[i/2]

		z.Member, err = rd.ReadString()
		if err != nil {
			return nil, err
		}

		z.Score, err = rd.ReadFloatReply()
		if err != nil {
			return nil, err
		}
	}
	return zz, nil
}
1247492
func NewGtParser(in io.Reader) Parser {
	return &GtParser{
		suite: nil,
		tests: make(map[string]*Test),
		lex:   NewGotestLexer(in),
	}
}
818984
func NewLine(pos position, ws string, item Item, le string) *Line {
	return &Line{
		pos: pos,

		ws:   ws,
		item: item,
		le:   le,
	}
}
1344533
func inlineCSS(filePath string) {
	input := readFile(filePath)

	output, err := inliner.Inline(string(input))
	if err != nil {
		fmt.Println("Inlining error: ", err)
		os.Exit(1)
	}

	fmt.Println(output)
}
367297
func NewCSVEncoder(w io.Writer) Encoder {
	enc := csv.NewWriter(w)
	return func(r *Result) error {
		err := enc.Write([]string{
			strconv.FormatInt(r.Timestamp.UnixNano(), 10),
			strconv.FormatUint(uint64(r.Code), 10),
			strconv.FormatInt(r.Latency.Nanoseconds(), 10),
			strconv.FormatUint(r.BytesOut, 10),
			strconv.FormatUint(r.BytesIn, 10),
			r.Error,
			base64.StdEncoding.EncodeToString(r.Body),
			r.Attack,
			strconv.FormatUint(r.Seq, 10),
		})

		if err != nil {
			return err
		}

		enc.Flush()

		return enc.Error()
	}
}
1139648
func NewParser(rd io.Reader) *Parser {
	p := Parser{}
	p.rd = rd
	p.lastByte = bufSize
	p.buf = make([]byte, bufSize)
	p.ev = &SimpleEventHandler{}
	p.r = -1
	p.fill()
	return &p
}