// Extract extract from request
19418
func (f ExtractorFunc) Extract(req *http.Request) (string, int64, error) {
	return f(req)
}
3330
func Extract(reader io.Reader, dest string) error {
	tarReader := tar.NewReader(reader)

	for {
		header, err := tarReader.Next()

		if err == io.EOF {
			break
		}

		if err != nil {
			return err
		}

		if header.Name == "." {
			continue
		}

		err = extract(tarReader, header, dest)
		if err != nil {
			return err
		}
	}

	return nil
}
678525
func (s VideoCaptureService) Extract(ctx context.Context, request ExtractRequest) (ExtractResponse, error) {

	name, err := saveFile(tempFileName(path.Ext(request.Name)), request.Video)
	if err != nil {
		return ExtractResponse{}, err
	}

	defer os.Remove(name)

	g, err := screengen.NewGenerator(name)
	if err != nil {
		return ExtractResponse{}, err
	}

	img, err := g.ImageWxH(request.Time, int(request.Width), int(request.Height))
	if err != nil {
		return ExtractResponse{}, err
	}

	result, err := saveToPng(img)
	if err != nil {
		return ExtractResponse{}, err
	}

	return ExtractResponse{Data: result}, nil
}
556512
func Extract(img image.Image, c Channel) *image.Gray {
	if c < 0 || 3 < c {
		panic(fmt.Sprintf("channel index '%v' out of bounds. Red: 0, Green: 1, Blue: 2, Alpha: 3", c))
	}

	src := clone.AsRGBA(img)
	bounds := src.Bounds()
	srcW, srcH := bounds.Dx(), bounds.Dy()

	if bounds.Empty() {
		return &image.Gray{}
	}

	dst := image.NewGray(bounds)

	parallel.Line(srcH, func(start, end int) {
		for y := start; y < end; y++ {
			for x := 0; x < srcW; x++ {
				srcPos := y*src.Stride + x*4
				dstPos := y*dst.Stride + x

				dst.Pix[dstPos] = src.Pix[srcPos+int(c)]
			}
		}
	})

	return dst
}
835905
func extractToken(r *http.Request) []byte {
	// Prefer the header over form value
	sentToken := r.Header.Get(HeaderName)

	// Then POST values
	if len(sentToken) == 0 {
		sentToken = r.PostFormValue(FormFieldName)
	}

	// If all else fails, try a multipart value.
	// PostFormValue() will already have called ParseMultipartForm()
	if len(sentToken) == 0 && r.MultipartForm != nil {
		vals := r.MultipartForm.Value[FormFieldName]
		if len(vals) != 0 {
			sentToken = vals[0]
		}
	}

	return b64decode(sentToken)
}
695991
func (l *SchemaList) Extract(v interface{}) error {
	switch val := v.(type) {
	case []interface{}:
		*l = make([]*Schema, len(val))
		var s *Schema
		for i, d := range val {
			m, ok := d.(map[string]interface{})
			if !ok {
				return errors.Wrap(
					errInvalidType("map[string]interface{}", d),
					"failed to extract schema list",
				)
			}
			if err := extractSingleSchema(&s, m); err != nil {
				return errors.Wrap(err, "failed to extract schema list")
			}
			(*l)[i] = s
		}
		return nil
	case map[string]interface{}:
		var s *Schema
		if err := extractSingleSchema(&s, val); err != nil {
			return errors.Wrap(err, "failed to extract schema list")
		}
		*l = []*Schema{s}
		return nil
	default:
		return errors.Wrap(
			errInvalidType("[]*Schema or *Schema", v),
			"failed to extract schema list",
		)
	}
}
312726
func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error) {
	resp, err := s.cs.newRequest("extractIso", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ExtractIsoResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
549836
func extractReqParams(r *http.Request) map[string]string {
	if r == nil {
		return nil
	}

	region := globalServerConfig.GetRegion()
	cred := getReqAccessCred(r, region)

	// Success.
	return map[string]string{
		"region":          region,
		"accessKey":       cred.AccessKey,
		"sourceIPAddress": handlers.GetSourceIP(r),
		// Add more fields here.
	}
}
547715
func Extract(src string, dest string) error {
	file, err := os.Open(src)

	if err != nil {
		return err
	}

	defer file.Close()

	return tar.Extract(bzip2.NewReader(file), dest)
}
839175
func (m ConfigMap) extract(key string, defval ConfigValue) (ConfigValue, error) {

	v, err := m.get(key, defval)
	if err != nil {
		return nil, err
	}

	delete(m, key)

	return v, nil
}
1145741
func (s *VolumeService) ExtractVolume(p *ExtractVolumeParams) (*ExtractVolumeResponse, error) {
	resp, err := s.cs.newRequest("extractVolume", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ExtractVolumeResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
1033046
func Extract(src string, dest string) error {
	files, err := zip.OpenReader(src)

	if err != nil {
		return err
	}

	defer files.Close()

	for _, file := range files.File {
		err = extractZip(file, dest)

		if err != nil {
			return err
		}
	}

	return nil
}
499215
func Extract(r io.Reader, dir string) error {
	tarball := tar.NewReader(r)

	for {
		header, err := tarball.Next()
		if err == io.EOF {
			break
		} else if err != nil {
			return trace.Wrap(err)
		}

		if err := extractFile(tarball, header, dir); err != nil {
			return trace.Wrap(err)
		}
	}
	return nil
}
68698
func (ar avroRecord) extract(pmm *producers.MetricsMessage, ctr *mesosAgent.ContainerTaskRels) error {
	var fieldType string
	if len(ar) > 0 {
		fieldType = ar[0].Name
	} else {
		return fmt.Errorf("no records found for extract")
	}

	switch fieldType {
	case "dcos.metrics.Tag": // Extract tags
		for _, field := range ar {
			if len(field.Fields) != 2 {
				return fmt.Errorf("tags must have 2 fields, got %d", len(field.Fields))
			}
			fwColLog.Debugf("Adding tag %s", field)
			tagName := fmt.Sprintf("%v", field.Fields[0].Datum)
			tagValue := fmt.Sprintf("%v", field.Fields[1].Datum)

			if tagName == "container_id" {
				pmm.Dimensions.ContainerID = tagValue

				info := ctr.Get(tagValue)
				if info != nil {
					pmm.Dimensions.TaskID = info.ID
					pmm.Dimensions.TaskName = info.Name
					pmm.Dimensions.Labels = convertLabels(info.Labels)
				} else {
					fwColLog.Debugf("Container ID %s had no associated task", tagValue)
				}

			} else if tagName == "framework_id" {
				pmm.Dimensions.FrameworkID = tagValue
			} else if tagName == "executor_id" {
				pmm.Dimensions.ExecutorID = tagValue
			} else {
				// Assumes Labels has been initialized already.
				pmm.Dimensions.Labels[tagName] = tagValue
			}
			pmm.Timestamp = time.Now().Unix()
		}
		return nil

	case "dcos.metrics.Datapoint": // Extract datapoints
		datapoints := []producers.Datapoint{}
		for _, field := range ar {
			if len(field.Fields) != 3 {
				return fmt.Errorf("datapoints must have 3 fields, got %d", len(field.Fields))
			}
			fwColLog.Debugf("Adding datapoint %s", field)

			var (
				name = field.Fields[0].Datum
				//time_ms = field.Fields[1].Datum
				value = field.Fields[2].Datum
			)

			// TODO(roger): the datapoint schema does not contain any fields
			// allowing for the sender to specify units. Therefore we default
			// to the zero value, an empty string.
			dp := producers.Datapoint{
				Name: fmt.Sprintf("%v", name),
				//Unit:      fmt.Sprintf("%v", unit),
				Value:     value,
				Timestamp: time.Now().UTC().Format(time.RFC3339),
			}

			datapoints = append(datapoints, dp)
		}
		pmm.Datapoints = datapoints
		return nil
	}

	return fmt.Errorf("must have dcos.metrics.Tags or dcos.metrics.Datapoint in avro record to use .extract()")
}
1171423
func extract(buf []byte, name string) []byte {
	extractRE := regexp.MustCompile(`\s+` + name + `.+?{`)
	buf = buf[extractRE.FindIndex(buf)[0]:]
	return buf[:endRE.FindIndex(buf)[1]]
}
873566
func extractUploadRequest(req *http.Request) (api.UploadRequest, error) {
	var ur api.UploadRequest

	if req.Header.Get(api.HeaderContentLength) == "" {
		size := req.ContentLength
		// size will be negative if there is no content.
		if size < 0 {
			size = 0
		}
		req.Header.Set(api.HeaderContentLength, fmt.Sprint(size))
	}

	ctype := req.Header.Get(api.HeaderContentType)
	if ctype != api.ContentTypeRaw {
		return ur, errors.Errorf("unsupported content type %q", ctype)
	}

	application, name := api.ExtractEndpointDetails(req.URL)
	fingerprint := req.Header.Get(api.HeaderContentSha384) // This parallels "Content-MD5".
	sizeRaw := req.Header.Get(api.HeaderContentLength)
	pendingID := req.URL.Query().Get(api.QueryParamPendingID)

	fp, err := charmresource.ParseFingerprint(fingerprint)
	if err != nil {
		return ur, errors.Annotate(err, "invalid fingerprint")
	}

	filename, err := extractFilename(req)
	if err != nil {
		return ur, errors.Trace(err)
	}

	size, err := strconv.ParseInt(sizeRaw, 10, 64)
	if err != nil {
		return ur, errors.Annotate(err, "invalid size")
	}

	ur = api.UploadRequest{
		Application: application,
		Name:        name,
		Filename:    filename,
		Size:        size,
		Fingerprint: fp,
		PendingID:   pendingID,
	}
	return ur, nil
}
280894
func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTemplateResponse, error) {
	resp, err := s.cs.newRequest("extractTemplate", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ExtractTemplateResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}