// Rel fetches and expands the Hyperlink by its given key in the Relations map.
549243
func (h Relations) Rel(name string, m M) (*url.URL, error) {
	if rel, ok := h[name]; ok {
		return rel.Expand(m)
	}
	return nil, fmt.Errorf("No %s relation found", name)
}
231744
func (r *Resource) AddNewLink(rel Relation, href string) {
	r.AddLink(rel, NewLink(href, nil))
}
911905
func (f *freelist) reindex() {
	f.cache = make(map[pgid]bool, len(f.ids))
	for _, id := range f.ids {
		f.cache[id] = true
	}
	for _, pendingIDs := range f.pending {
		for _, pendingID := range pendingIDs {
			f.cache[pendingID] = true
		}
	}
}
470945
func (us *HtdigestUserStore) Reload(onbad BadLineHandler) error {
	f, err := os.Open(us.filename)
	if err != nil {
		return err
	}
	defer f.Close()

	c := csv.NewReader(f)
	c.Comma = ':'
	c.Comment = '#'
	c.TrimLeadingSpace = true
	c.FieldsPerRecord = -1 // don't check

	n := map[string]string{}
	for {
		r, err := c.Read()
		if err == io.EOF {
			break
		}
		if err != nil {
			return err
		}

		if len(r) != 3 {
			if onbad != nil {
				// sad error message, there is some wreckage of better errors in encoding/csv, but
				// I'm not sure it is in use anymore.
				onbad(fmt.Errorf("line is not three fields: %v", r))
			}
			// skip this line, it isn't three fields
			continue
		}

		n[r[0]+":"+r[1]] = strings.TrimSpace(r[2]) // might have trailing space
	}

	us.mutex.Lock()
	defer us.mutex.Unlock()

	us.userToHA1 = n
	return nil
}
225736
func (l Hyperlink) Expand(m M) (*url.URL, error) {
	template, err := uritemplates.Parse(string(l))
	if err != nil {
		return nil, err
	}

	// clone M to map[string]interface{}
	// if we don't do this type assertion will
	// fail on jtacoma/uritemplates
	// see https://github.com/jtacoma/uritemplates/blob/master/uritemplates.go#L189
	mm := make(map[string]interface{}, len(m))
	for k, v := range m {
		mm[k] = v
	}

	expanded, err := template.Expand(mm)
	if err != nil {
		return nil, err
	}

	return url.Parse(expanded)
}
1358118
func (mrt MarkdownRichText) URL(text string, url string) string {
	repalcer := strings.NewReplacer("[", "⟦", "]", "⟧", "(", "❨", ")", "❩")
	text = fmt.Sprintf("[%s](%s)", repalcer.Replace(text), url)
	return text
}
1153156
func (c *DOM) QuerySelectorAll(nodeId int, selector string) ([]int, error) {
	var v DOMQuerySelectorAllParams
	v.NodeId = nodeId
	v.Selector = selector
	return c.QuerySelectorAllWithParams(&v)
}
287693
func (d *domainClient) QuerySelectorAll(ctx context.Context, args *QuerySelectorAllArgs) (reply *QuerySelectorAllReply, err error) {
	reply = new(QuerySelectorAllReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "DOM.querySelectorAll", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "DOM.querySelectorAll", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "DOM", Op: "QuerySelectorAll", Err: err}
	}
	return
}
1272247
func (db *DB) HDel(key []byte, args ...[]byte) (int64, error) {
	t := db.hashBatch

	var ek []byte
	var v []byte
	var err error

	t.Lock()
	defer t.Unlock()

	it := db.bucket.NewIterator()
	defer it.Close()

	var num int64
	for i := 0; i < len(args); i++ {
		if err := checkHashKFSize(key, args[i]); err != nil {
			return 0, err
		}

		ek = db.hEncodeHashKey(key, args[i])

		v = it.RawFind(ek)
		if v == nil {
			continue
		} else {
			num++
			t.Delete(ek)
		}
	}

	if _, err = db.hIncrSize(key, -num); err != nil {
		return 0, err
	}

	err = t.Commit()

	return num, err
}
248365
func (r *Response) Rels() (hypermedia.Relations, bool) {
	if r.rels != nil {
		return r.rels, true
	}
	return nil, false
}
811697
func (l Links) Link(rel, href string, args ...interface{}) Links {
	if len(args) != 0 {
		href = fmt.Sprintf(href, args...)
	}

	templated, _ := regexp.Match("{.*?}", []byte(href))

	return l.Add(rel, Link{Href: href, Templated: templated})
}
930734
func rel(basepath, targpath string) (string, error) {
	// filepath.Rel can't handle UUID paths in windows
	if runtime.GOOS == "windows" {
		pfx := basepath + `\`
		if strings.HasPrefix(targpath, pfx) {
			p := strings.TrimPrefix(targpath, pfx)
			if p == "" {
				p = "."
			}
			return p, nil
		}
	}
	return filepath.Rel(basepath, targpath)
}
190729
func (db *RedisDB) HDel(k, f string) {
	db.master.Lock()
	defer db.master.Unlock()
	db.hdel(k, f)
}
762933
func (c *Connection) Reload(model interface{}) error {
	sm := Model{Value: model}
	return sm.iterate(func(m *Model) error {
		return c.Find(m.Value, m.ID())
	})
}
703691
func Eval(n EvalNode, ctx EvalContext) (interface{}, error) {
	// Call the lower level eval which doesn't understand early exit,
	// and if we early exit, it isn't an error.
	result, err := EvalRaw(n, ctx)
	if err != nil {
		if _, ok := err.(EvalEarlyExitError); ok {
			return nil, nil
		}
	}

	return result, err
}
291333
func (c CurieHandle) AddNewLink(rel Relation, href string) {
	rel = Relation(c.Name) + ":" + rel
	c.Resource.AddLink(rel, NewLink(href, nil))
}
1138138
func (r *Node) Reload() (*Node, error) {
	return r.collection.Get(r.Metadata.Name)
}