// Export returns a serialized representation of the model associated
// with the API connection. The charms used by the model are also
// returned.
3725
func (c *Client) Export() (migration.SerializedModel, error) {
	var empty migration.SerializedModel
	var serialized params.SerializedModel
	err := c.caller.FacadeCall("Export", nil, &serialized)
	if err != nil {
		return empty, errors.Trace(err)
	}

	// Convert tools info to output map.
	tools := make(map[version.Binary]string)
	for _, toolsInfo := range serialized.Tools {
		v, err := version.ParseBinary(toolsInfo.Version)
		if err != nil {
			return migration.SerializedModel{}, errors.Annotate(err, "error parsing agent binary version")
		}
		tools[v] = toolsInfo.URI
	}

	resources, err := convertResources(serialized.Resources)
	if err != nil {
		return empty, errors.Trace(err)
	}

	return migration.SerializedModel{
		Bytes:     serialized.Bytes,
		Charms:    serialized.Charms,
		Tools:     tools,
		Resources: resources,
	}, nil
}
163503
func (c CurrentStatus) Export() (ret keybase1.GetCurrentStatusRes) {
	ret.Configured = c.Configured
	ret.Registered = c.Registered
	ret.LoggedIn = c.LoggedIn
	ret.SessionIsValid = c.SessionIsValid
	if c.User != nil {
		ret.User = c.User.Export()
	}
	// ret.ServerUri = G.Env.GetServerUri();
	return
}
1149505
func (l ExportList) MarshalJSON() ([]byte, error) {
	exports := struct {
		Exports []*Export `json:"exports,omitempty"`
	}{l}
	return json.Marshal(exports)
}
625291
func (conn *Conn) export(methods map[string]reflect.Value, path ObjectPath, iface string, includeSubtree bool) error {
	h, ok := conn.handler.(*defaultHandler)
	if !ok {
		return fmt.Errorf(
			`dbus: export only allowed on the default hander handler have %T"`,
			conn.handler)
	}

	if !path.IsValid() {
		return fmt.Errorf(`dbus: Invalid path name: "%s"`, path)
	}

	// Remove a previous export if the interface is nil
	if methods == nil {
		return conn.unexport(h, path, iface)
	}

	// If this is the first handler for this path, make a new map to hold all
	// handlers for this path.
	if !h.PathExists(path) {
		h.AddObject(path, newExportedObject())
	}

	exportedMethods := make(map[string]Method)
	for name, method := range methods {
		exportedMethods[name] = exportedMethod{method}
	}

	// Finally, save this handler
	obj := h.objects[path]
	obj.AddInterface(iface, newExportedIntf(exportedMethods, includeSubtree))

	return nil
}
1093936
func (c CryptocurrencyChainLink) Export() (ret keybase1.Cryptocurrency) {
	ret.Pkhash = c.pkhash
	ret.Address = c.address
	ret.SigID = c.GetSigID()
	ret.Type = c.typ.String()
	ret.Family = string(c.typ.ToCryptocurrencyFamily())
	return ret
}
1149475
func (c *Client) GetExports(ctx context.Context) (ExportList, error) {
	return api.ExportsList(ctx, c.API)
}
815128
func (s *StatusCheck) Export() (JSONMetric, error) {
	var buf bytes.Buffer

	err := binary.Write(&buf, binary.LittleEndian, s.Value)
	if err != nil {
		return JSONMetric{}, err
	}

	return JSONMetric{
		MetricKey: MetricKey{
			Name:       s.Name,
			Type:       "status",
			JoinedTags: strings.Join(s.Tags, ","),
		},
		Tags:  s.Tags,
		Value: buf.Bytes(),
	}, nil
}
1034778
func (i item) export(f gregor.ObjFactory) (gregor.Item, error) {
	md := i.item.Metadata()
	return f.MakeItem(md.UID(), md.MsgID(), md.DeviceID(), i.ctime, i.item.Category(), i.dtime, i.item.Body())
}
801545
func (b *BundleAPI) ExportBundle() (params.StringResult, error) {
	fail := func(failErr error) (params.StringResult, error) {
		return params.StringResult{}, common.ServerError(failErr)
	}

	if err := b.checkCanRead(); err != nil {
		return fail(err)
	}

	exportConfig := b.backend.GetExportConfig()
	model, err := b.backend.ExportPartial(exportConfig)
	if err != nil {
		return fail(err)
	}

	// Fill it in charm.BundleData data structure.
	bundleData, err := b.fillBundleData(model)
	if err != nil {
		return fail(err)
	}

	bytes, err := yaml.Marshal(bundleData)
	if err != nil {
		return fail(err)
	}

	return params.StringResult{
		Result: string(bytes),
	}, nil
}
725452
func (t *UniversalTranslator) Export(format ImportExportFormat, dirname string) error {

	_, err := os.Stat(dirname)
	fmt.Println(dirname, err, os.IsNotExist(err))
	if err != nil {

		if !os.IsNotExist(err) {
			return err
		}

		if err = os.MkdirAll(dirname, 0744); err != nil {
			return err
		}
	}

	// build up translations
	var trans []translation
	var b []byte
	var ext string

	for _, locale := range t.translators {

		for k, v := range locale.(*translator).translations {
			trans = append(trans, translation{
				Locale:      locale.Locale(),
				Key:         k,
				Translation: v.text,
			})
		}

		for k, pluralTrans := range locale.(*translator).cardinalTanslations {

			for i, plural := range pluralTrans {

				// leave enough for all plural rules
				// but not all are set for all languages.
				if plural == nil {
					continue
				}

				trans = append(trans, translation{
					Locale:      locale.Locale(),
					Key:         k.(string),
					Translation: plural.text,
					PluralType:  cardinalType,
					PluralRule:  locales.PluralRule(i).String(),
				})
			}
		}

		for k, pluralTrans := range locale.(*translator).ordinalTanslations {

			for i, plural := range pluralTrans {

				// leave enough for all plural rules
				// but not all are set for all languages.
				if plural == nil {
					continue
				}

				trans = append(trans, translation{
					Locale:      locale.Locale(),
					Key:         k.(string),
					Translation: plural.text,
					PluralType:  ordinalType,
					PluralRule:  locales.PluralRule(i).String(),
				})
			}
		}

		for k, pluralTrans := range locale.(*translator).rangeTanslations {

			for i, plural := range pluralTrans {

				// leave enough for all plural rules
				// but not all are set for all languages.
				if plural == nil {
					continue
				}

				trans = append(trans, translation{
					Locale:      locale.Locale(),
					Key:         k.(string),
					Translation: plural.text,
					PluralType:  rangeType,
					PluralRule:  locales.PluralRule(i).String(),
				})
			}
		}

		switch format {
		case FormatJSON:
			b, err = json.MarshalIndent(trans, "", "    ")
			ext = ".json"
		}

		if err != nil {
			return err
		}

		err = ioutil.WriteFile(filepath.Join(dirname, fmt.Sprintf("%s%s", locale.Locale(), ext)), b, 0644)
		if err != nil {
			return err
		}

		trans = trans[0:0]
	}

	return nil
}
1290451
func (r *Repo) Export(ctx context.Context, ref string) (*Export, error) {
	dir, err := r.workingClone(ctx, "")
	if err != nil {
		return nil, err
	}
	if err = checkout(ctx, dir, ref); err != nil {
		return nil, err
	}
	return &Export{dir}, nil
}
435323
func (v *DeviceMapperVolume) Export(label, parent string, writer io.Writer, excludes []string) error {
	glog.V(2).Infof("Export() (%s) START", v.name)
	defer glog.V(2).Infof("Export() (%s) END", v.name)
	if !v.snapshotExists(label) {
		return volume.ErrSnapshotDoesNotExist
	}
	label = v.rawSnapshotLabel(label)
	mountpoint, err := ioutil.TempDir("", "serviced-export-volume-")
	if err != nil {
		return err
	}
	defer os.RemoveAll(mountpoint)
	deviceHash, err := v.Metadata.LookupSnapshotDevice(label)
	if err != nil {
		return err
	}
	glog.V(2).Infof("Mounting temporary export device %s", deviceHash)
	if err := v.driver.DeviceSet.MountDevice(deviceHash, mountpoint, label); err != nil {
		return err
	}
	defer func(d *DeviceMapperDriver, deviceHash, mountpoint string) {
		// We use the provided UnmountDevice func here, rather than our own
		// unmount(), because we DO care about Docker's internal bookkeeping
		// here. Without this, DeviceSet.DeleteDevice will fail.
		if err := d.DeviceSet.UnmountDevice(deviceHash, mountpoint); err != nil {
			glog.V(2).Infof("Error unmounting %s (device: %s): %s", mountpoint, deviceHash, err)
		}
		d.DeviceSet.Lock()
		if err := d.DeactivateDevice(deviceHash); err != nil {
			glog.V(2).Infof("Error deactivating device %s: %s", deviceHash, err)
		}
		d.DeviceSet.Unlock()
	}(v.driver, deviceHash, mountpoint)

	tarOut := tar.NewWriter(writer)

	// Set the driver type
	drivertype := []byte(v.Driver().DriverType())
	header := &tar.Header{Name: fmt.Sprintf("%s-driver", label), Size: int64(len(drivertype))}
	if err := tarOut.WriteHeader(header); err != nil {
		glog.Errorf("Could not export driver type header for snapshot %s: %s", label, err)
		return err
	}
	if _, err := tarOut.Write(drivertype); err != nil {
		glog.Errorf("Could not export driver type for snapshot %s: %s", label, err)
		return err
	}

	// Set the device metadata
	size, err := v.SizeOf()
	if err != nil {
		glog.Errorf("Could not get the size of the device for snapshot %s: %s", label, err)
		return err
	}
	volInfo, err := json.Marshal(volumeInfo{Size: size})
	if err != nil {
		glog.Errorf("Could not marshal device info for snapshot %s: %s", label, err)
		return err
	}
	header = &tar.Header{Name: fmt.Sprintf("%s-device", label), Size: int64(len(volInfo))}
	if err := tarOut.WriteHeader(header); err != nil {
		glog.Errorf("Could not export device info header for snapshot %s: %s", label, err)
		return err
	}
	if _, err := tarOut.Write(volInfo); err != nil {
		glog.Errorf("Could not export device info for snapshot %s: %s", label, err)
		return err
	}

	// Write metadata
	mdpath := filepath.Join(v.driver.MetadataDir(), label)

	if err := exportDirectoryAsTar(mdpath, fmt.Sprintf("%s-metadata", label), tarOut, []string{}); err != nil {
		return err
	}
	if err := exportDirectoryAsTar(mountpoint, fmt.Sprintf("%s-volume", label), tarOut, excludes); err != nil {
		return err
	}

	return tarOut.Close()
}
205643
func (id Identity) Export() (ret keybase1.PGPIdentity) {
	ret.Username = id.Username
	ret.Email = id.Email
	ret.Comment = id.Comment
	return
}
337516
func (res *Resource) Export(container Container, context *qor.Context, callbacks ...func(Progress) error) error {
	var (
		total   uint
		results = res.NewSlice()
		err     = context.GetDB().Find(results).Count(&total).Error
	)

	if err == nil {
		reflectValue := reflect.Indirect(reflect.ValueOf(results))

		writer, err := container.NewWriter(res, context)

		if err == nil {
			writer.WriteHeader()

			for i := 0; i < reflectValue.Len(); i++ {
				var result = reflectValue.Index(i).Interface()
				var metaValues *resource.MetaValues
				if metaValues, err = writer.WriteRow(result); err != nil {
					return err
				}

				var progress = Progress{
					Current: uint(i + 1),
					Total:   total,
					Value:   result,
				}

				for _, metaValue := range metaValues.Values {
					progress.Cells = append(progress.Cells, Cell{
						Header: metaValue.Name,
						Value:  metaValue.Value,
					})
				}

				for _, callback := range callbacks {
					if err := callback(progress); err != nil {
						return err
					}
				}
			}
			err = writer.Flush()
		}

		return err
	}

	return err
}
1178371
func (p *gc_parser) parse_export(callback func(string, ast.Decl)) {
	p.expect_keyword("package")
	p.pfc.defalias = p.expect(scanner.Ident)
	if p.tok != '\n' {
		p.expect_keyword("safe")
	}
	p.expect('\n')

	for p.tok != '$' && p.tok != scanner.EOF {
		pkg, decl := p.parse_decl()
		if decl != nil {
			callback(pkg, decl)
		}
	}
}
1094927
func (r *Runtime) ExportTo(v Value, target interface{}) error {
	tval := reflect.ValueOf(target)
	if tval.Kind() != reflect.Ptr || tval.IsNil() {
		return errors.New("target must be a non-nil pointer")
	}
	vv, err := r.toReflectValue(v, tval.Elem().Type())
	if err != nil {
		return err
	}
	tval.Elem().Set(vv)
	return nil
}
549995
func (s *Set) Export() (JSONMetric, error) {
	val, err := s.Hll.MarshalBinary()
	if err != nil {
		return JSONMetric{}, err
	}
	return JSONMetric{
		MetricKey: MetricKey{
			Name:       s.Name,
			Type:       "set",
			JoinedTags: strings.Join(s.Tags, ","),
		},
		Tags:  s.Tags,
		Value: val,
	}, nil
}