// Create a new adapter by name and direction, or nil if doesn't exist
502370
func (m *Manifest) NewAdapter(name string, dir Direction) Adapter {
	m.mu.Lock()
	defer m.mu.Unlock()

	switch dir {
	case Upload:
		if u, ok := m.uploadAdapterFuncs[name]; ok {
			return u(name, dir)
		}
	case Download:
		if d, ok := m.downloadAdapterFuncs[name]; ok {
			return d(name, dir)
		}
	}
	return nil
}
588652
func (d *Driver) Create(id, parent, mountLabel string) error {
	if err := d.DeviceSet.AddDevice(id, parent); err != nil {
		return err
	}

	return nil
}
1002037
func NewAccelerator(items ...string) (a *Accelerator) {
	a = &Accelerator{}
	for _, i := range items {
		*a = append(*a, i)
	}
	return
}
946223
func (r *Route) AdapterTransport(dfault string) string {
	parts := strings.Split(r.Adapter, "+")
	if len(parts) > 1 {
		return parts[1]
	}
	return dfault
}
364401
func New(adapter Adapter) Repo {
	return Repo{
		adapter: adapter,
		logger:  []Logger{DefaultLogger},
	}
}
163013
func (e *Adaptor) Connect() (err error) {
	e.mutex.Lock()
	defer e.mutex.Unlock()

	e.digitalPins = make(map[int]*sysfs.DigitalPin)
	e.pwmPins = make(map[int]*sysfs.PWMPin)
	err = e.connect(e)
	return
}
1015904
func New(r *hal.Robot) (hal.Adapter, error) {
	a := &adapter{
		out:  bufio.NewWriter(os.Stdout),
		in:   bufio.NewReader(os.Stdin),
		quit: make(chan bool),
	}
	a.SetRobot(r)
	return a, nil
}
1094000
func AddAdapter(name string, adapter AdapterPod) {
	lock.Lock()
	adapters[name] = adapter
	lock.Unlock()
}
281952
func (s *BillablesService) Create(parms map[string]string) (*BillableItem, *Response, error) {
	a := new(BillableItem)
	resp, err := do(s.client, Params{parms: parms, u: "addbillableitem"}, a)
	if err != nil {
		return nil, resp, err
	}
	return a, resp, err
}
1022302
func (a *Adaptor) Connect() (err error) {
	a.client = paho.NewClient(a.createClientOptions())
	if token := a.client.Connect(); token.Wait() && token.Error() != nil {
		err = multierror.Append(err, token.Error())
	}

	return
}
421498
func (vrsConnection *VRSConnection) CreatePort(name string, attributes port.Attributes,
	metadata map[port.MetadataKey]string) error {

	portMetadata := make(map[string]string)

	for k, v := range metadata {
		portMetadata[string(k)] = v
	}

	nuagePortRow := ovsdb.NuagePortTableRow{
		Name:             name,
		Mac:              attributes.MAC,
		Bridge:           attributes.Bridge,
		NuageDomain:      metadata[port.MetadataKeyDomain],
		NuageNetwork:     metadata[port.MetadataKeyNetwork],
		NuageNetworkType: metadata[port.MetadataKeyNetworkType],
		NuageZone:        metadata[port.MetadataKeyZone],
		VMDomain:         attributes.Platform,
		Metadata:         portMetadata,
	}

	if err := vrsConnection.portTable.InsertRow(vrsConnection.ovsdbClient, &nuagePortRow); err != nil {
		return fmt.Errorf("Problem adding port info to VRS %v", err)
	}

	return nil
}
43312
func SetAdapterConfig(name string, config map[string]interface{}) {
	lock.Lock()
	a := adapters[name]
	a.Config = config
	adapters[name] = a
	lock.Unlock()
}
521305
func NewDevice(name string, database db.Database) (Device, error) {
	var e db.Entity
	var err error

	if e, err = database.EntityWithName(name); err != nil {
		if e, err = db.NewRandomEntityWithName(name); err == nil {
			err = database.SaveEntity(e)
		}
	}

	return &device{e}, err
}
146376
func New(r *hal.Robot) (hal.Adapter, error) {
	c := &config{}
	env.MustProcess(c)
	channels := strings.Split(c.Channels, ",")
	a := &adapter{
		token:          c.Token,
		team:           c.Team,
		channels:       channels,
		channelMode:    c.ChannelMode,
		mode:           c.Mode,
		botname:        c.Botname,
		iconEmoji:      c.IconEmoji,
		ircEnabled:     c.IrcEnabled,
		ircPassword:    c.IrcPassword,
		responseMethod: c.ResponseMethod,
	}
	spew.Dump(c)
	hal.Logger.Debugf("%v", os.Getenv("HAL_SLACK_CHANNEL_MODE"))
	hal.Logger.Debugf("channel mode: %v", a.channelMode)
	// if a.channelMode == "" {
	// a.channelMode = "whitelist"
	// }
	a.SetRobot(r)
	return a, nil
}
683389
func NewAdaptor(v ...string) *Adaptor {
	a := &Adaptor{
		name: gobot.DefaultName("ARDrone"),
		connect: func(a *Adaptor) (drone, error) {
			return client.Connect(a.config)
		},
	}

	a.config = client.DefaultConfig()
	if len(v) > 0 {
		a.config.Ip = v[0]
	}

	return a
}
710528
func NewAdaptor(device string) *Adaptor {
	c := &serial.Mode{BaudRate: 115200}
	return &Adaptor{
		name:              "MegaPi",
		connection:        nil,
		port:              device,
		serialMode:        c,
		writeBytesChannel: make(chan []byte),
		finalizeChannel:   make(chan struct{}),
	}
}
82081
func (a *Adaptor) Connect() (err error) {
	a.client, err = a.connect()
	return
}