id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
134,000 | henrylee2cn/pholcus | common/session/sess_mem.go | Get | func (st *MemSessionStore) Get(key interface{}) interface{} {
st.lock.RLock()
defer st.lock.RUnlock()
if v, ok := st.value[key]; ok {
return v
}
return nil
} | go | func (st *MemSessionStore) Get(key interface{}) interface{} {
st.lock.RLock()
defer st.lock.RUnlock()
if v, ok := st.value[key]; ok {
return v
}
return nil
} | [
"func",
"(",
"st",
"*",
"MemSessionStore",
")",
"Get",
"(",
"key",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"st",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"v",
"... | // Get value from memory session by key | [
"Get",
"value",
"from",
"memory",
"session",
"by",
"key"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L43-L50 |
134,001 | henrylee2cn/pholcus | common/session/sess_mem.go | Delete | func (st *MemSessionStore) Delete(key interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
delete(st.value, key)
} | go | func (st *MemSessionStore) Delete(key interface{}) {
st.lock.Lock()
defer st.lock.Unlock()
delete(st.value, key)
} | [
"func",
"(",
"st",
"*",
"MemSessionStore",
")",
"Delete",
"(",
"key",
"interface",
"{",
"}",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"st",
".",
"value",
... | // Delete in memory session by key | [
"Delete",
"in",
"memory",
"session",
"by",
"key"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L53-L57 |
134,002 | henrylee2cn/pholcus | common/session/sess_mem.go | Flush | func (st *MemSessionStore) Flush() {
st.lock.Lock()
defer st.lock.Unlock()
st.value = make(map[interface{}]interface{})
} | go | func (st *MemSessionStore) Flush() {
st.lock.Lock()
defer st.lock.Unlock()
st.value = make(map[interface{}]interface{})
} | [
"func",
"(",
"st",
"*",
"MemSessionStore",
")",
"Flush",
"(",
")",
"{",
"st",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"st",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"st",
".",
"value",
"=",
"make",
"(",
"map",
"[",
"interface",
"{... | // Flush clear all values in memory session | [
"Flush",
"clear",
"all",
"values",
"in",
"memory",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L60-L64 |
134,003 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionInit | func (pder *MemProvider) SessionInit(maxlifetime int64, savePath string) error {
pder.maxlifetime = maxlifetime
pder.savePath = savePath
return nil
} | go | func (pder *MemProvider) SessionInit(maxlifetime int64, savePath string) error {
pder.maxlifetime = maxlifetime
pder.savePath = savePath
return nil
} | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionInit",
"(",
"maxlifetime",
"int64",
",",
"savePath",
"string",
")",
"error",
"{",
"pder",
".",
"maxlifetime",
"=",
"maxlifetime",
"\n",
"pder",
".",
"savePath",
"=",
"savePath",
"\n",
"return",
"nil",
"... | // SessionInit init memory session | [
"SessionInit",
"init",
"memory",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L85-L89 |
134,004 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionRead | func (pder *MemProvider) SessionRead(sid string) (Store, error) {
pder.lock.RLock()
if element, ok := pder.sessions[sid]; ok {
go pder.SessionUpdate(sid)
pder.lock.RUnlock()
return element.Value.(*MemSessionStore), nil
}
pder.lock.RUnlock()
pder.lock.Lock()
newsess := &MemSessionStore{sid: sid, timeAccessed... | go | func (pder *MemProvider) SessionRead(sid string) (Store, error) {
pder.lock.RLock()
if element, ok := pder.sessions[sid]; ok {
go pder.SessionUpdate(sid)
pder.lock.RUnlock()
return element.Value.(*MemSessionStore), nil
}
pder.lock.RUnlock()
pder.lock.Lock()
newsess := &MemSessionStore{sid: sid, timeAccessed... | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionRead",
"(",
"sid",
"string",
")",
"(",
"Store",
",",
"error",
")",
"{",
"pder",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"if",
"element",
",",
"ok",
":=",
"pder",
".",
"sessions",
"[",
"sid",
... | // SessionRead get memory session store by sid | [
"SessionRead",
"get",
"memory",
"session",
"store",
"by",
"sid"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L92-L106 |
134,005 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionExist | func (pder *MemProvider) SessionExist(sid string) bool {
pder.lock.RLock()
defer pder.lock.RUnlock()
if _, ok := pder.sessions[sid]; ok {
return true
}
return false
} | go | func (pder *MemProvider) SessionExist(sid string) bool {
pder.lock.RLock()
defer pder.lock.RUnlock()
if _, ok := pder.sessions[sid]; ok {
return true
}
return false
} | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionExist",
"(",
"sid",
"string",
")",
"bool",
"{",
"pder",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"pder",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"pd... | // SessionExist check session store exist in memory session by sid | [
"SessionExist",
"check",
"session",
"store",
"exist",
"in",
"memory",
"session",
"by",
"sid"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L109-L116 |
134,006 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionDestroy | func (pder *MemProvider) SessionDestroy(sid string) error {
pder.lock.Lock()
defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok {
delete(pder.sessions, sid)
pder.list.Remove(element)
return nil
}
return nil
} | go | func (pder *MemProvider) SessionDestroy(sid string) error {
pder.lock.Lock()
defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok {
delete(pder.sessions, sid)
pder.list.Remove(element)
return nil
}
return nil
} | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionDestroy",
"(",
"sid",
"string",
")",
"error",
"{",
"pder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"element",
",",
"ok",
":="... | // SessionDestroy delete session store in memory session by id | [
"SessionDestroy",
"delete",
"session",
"store",
"in",
"memory",
"session",
"by",
"id"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L141-L150 |
134,007 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionGC | func (pder *MemProvider) SessionGC() {
pder.lock.RLock()
for {
element := pder.list.Back()
if element == nil {
break
}
if (element.Value.(*MemSessionStore).timeAccessed.Unix() + pder.maxlifetime) < time.Now().Unix() {
pder.lock.RUnlock()
pder.lock.Lock()
pder.list.Remove(element)
delete(pder.se... | go | func (pder *MemProvider) SessionGC() {
pder.lock.RLock()
for {
element := pder.list.Back()
if element == nil {
break
}
if (element.Value.(*MemSessionStore).timeAccessed.Unix() + pder.maxlifetime) < time.Now().Unix() {
pder.lock.RUnlock()
pder.lock.Lock()
pder.list.Remove(element)
delete(pder.se... | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionGC",
"(",
")",
"{",
"pder",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"for",
"{",
"element",
":=",
"pder",
".",
"list",
".",
"Back",
"(",
")",
"\n",
"if",
"element",
"==",
"nil",
"{",
"break"... | // SessionGC clean expired session stores in memory session | [
"SessionGC",
"clean",
"expired",
"session",
"stores",
"in",
"memory",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L153-L172 |
134,008 | henrylee2cn/pholcus | common/session/sess_mem.go | SessionUpdate | func (pder *MemProvider) SessionUpdate(sid string) error {
pder.lock.Lock()
defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok {
element.Value.(*MemSessionStore).timeAccessed = time.Now()
pder.list.MoveToFront(element)
return nil
}
return nil
} | go | func (pder *MemProvider) SessionUpdate(sid string) error {
pder.lock.Lock()
defer pder.lock.Unlock()
if element, ok := pder.sessions[sid]; ok {
element.Value.(*MemSessionStore).timeAccessed = time.Now()
pder.list.MoveToFront(element)
return nil
}
return nil
} | [
"func",
"(",
"pder",
"*",
"MemProvider",
")",
"SessionUpdate",
"(",
"sid",
"string",
")",
"error",
"{",
"pder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"pder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"element",
",",
"ok",
":=",... | // SessionUpdate expand time of session store by id in memory session | [
"SessionUpdate",
"expand",
"time",
"of",
"session",
"store",
"by",
"id",
"in",
"memory",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_mem.go#L180-L189 |
134,009 | henrylee2cn/pholcus | common/config/ini.go | Parse | func (ini *IniConfig) Parse(name string) (Configer, error) {
return ini.parseFile(name)
} | go | func (ini *IniConfig) Parse(name string) (Configer, error) {
return ini.parseFile(name)
} | [
"func",
"(",
"ini",
"*",
"IniConfig",
")",
"Parse",
"(",
"name",
"string",
")",
"(",
"Configer",
",",
"error",
")",
"{",
"return",
"ini",
".",
"parseFile",
"(",
"name",
")",
"\n",
"}"
] | // Parse creates a new Config and parses the file configuration from the named file. | [
"Parse",
"creates",
"a",
"new",
"Config",
"and",
"parses",
"the",
"file",
"configuration",
"from",
"the",
"named",
"file",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L50-L52 |
134,010 | henrylee2cn/pholcus | common/config/ini.go | ParseData | func (ini *IniConfig) ParseData(data []byte) (Configer, error) {
// Save memory data to temporary file
tmpName := path.Join(os.TempDir(), "beego", fmt.Sprintf("%d", time.Now().Nanosecond()))
os.MkdirAll(path.Dir(tmpName), os.ModePerm)
if err := ioutil.WriteFile(tmpName, data, 0655); err != nil {
return nil, err
... | go | func (ini *IniConfig) ParseData(data []byte) (Configer, error) {
// Save memory data to temporary file
tmpName := path.Join(os.TempDir(), "beego", fmt.Sprintf("%d", time.Now().Nanosecond()))
os.MkdirAll(path.Dir(tmpName), os.ModePerm)
if err := ioutil.WriteFile(tmpName, data, 0655); err != nil {
return nil, err
... | [
"func",
"(",
"ini",
"*",
"IniConfig",
")",
"ParseData",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"Configer",
",",
"error",
")",
"{",
"// Save memory data to temporary file",
"tmpName",
":=",
"path",
".",
"Join",
"(",
"os",
".",
"TempDir",
"(",
")",
",",
... | // ParseData parse ini the data | [
"ParseData",
"parse",
"ini",
"the",
"data"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L177-L185 |
134,011 | henrylee2cn/pholcus | common/config/ini.go | DefaultBool | func (c *IniConfigContainer) DefaultBool(key string, defaultval bool) bool {
v, err := c.Bool(key)
if err != nil {
return defaultval
}
return v
} | go | func (c *IniConfigContainer) DefaultBool(key string, defaultval bool) bool {
v, err := c.Bool(key)
if err != nil {
return defaultval
}
return v
} | [
"func",
"(",
"c",
"*",
"IniConfigContainer",
")",
"DefaultBool",
"(",
"key",
"string",
",",
"defaultval",
"bool",
")",
"bool",
"{",
"v",
",",
"err",
":=",
"c",
".",
"Bool",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defaultval",... | // DefaultBool returns the boolean value for a given key.
// if err != nil return defaltval | [
"DefaultBool",
"returns",
"the",
"boolean",
"value",
"for",
"a",
"given",
"key",
".",
"if",
"err",
"!",
"=",
"nil",
"return",
"defaltval"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L240-L246 |
134,012 | henrylee2cn/pholcus | common/config/ini.go | Int64 | func (c *IniConfigContainer) Int64(key string) (int64, error) {
return strconv.ParseInt(c.getdata(key), 10, 64)
} | go | func (c *IniConfigContainer) Int64(key string) (int64, error) {
return strconv.ParseInt(c.getdata(key), 10, 64)
} | [
"func",
"(",
"c",
"*",
"IniConfigContainer",
")",
"Int64",
"(",
"key",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"return",
"strconv",
".",
"ParseInt",
"(",
"c",
".",
"getdata",
"(",
"key",
")",
",",
"10",
",",
"64",
")",
"\n",
"}"
] | // Int64 returns the int64 value for a given key. | [
"Int64",
"returns",
"the",
"int64",
"value",
"for",
"a",
"given",
"key",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L264-L266 |
134,013 | henrylee2cn/pholcus | common/config/ini.go | Float | func (c *IniConfigContainer) Float(key string) (float64, error) {
return strconv.ParseFloat(c.getdata(key), 64)
} | go | func (c *IniConfigContainer) Float(key string) (float64, error) {
return strconv.ParseFloat(c.getdata(key), 64)
} | [
"func",
"(",
"c",
"*",
"IniConfigContainer",
")",
"Float",
"(",
"key",
"string",
")",
"(",
"float64",
",",
"error",
")",
"{",
"return",
"strconv",
".",
"ParseFloat",
"(",
"c",
".",
"getdata",
"(",
"key",
")",
",",
"64",
")",
"\n",
"}"
] | // Float returns the float value for a given key. | [
"Float",
"returns",
"the",
"float",
"value",
"for",
"a",
"given",
"key",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L279-L281 |
134,014 | henrylee2cn/pholcus | common/config/ini.go | DefaultFloat | func (c *IniConfigContainer) DefaultFloat(key string, defaultval float64) float64 {
v, err := c.Float(key)
if err != nil {
return defaultval
}
return v
} | go | func (c *IniConfigContainer) DefaultFloat(key string, defaultval float64) float64 {
v, err := c.Float(key)
if err != nil {
return defaultval
}
return v
} | [
"func",
"(",
"c",
"*",
"IniConfigContainer",
")",
"DefaultFloat",
"(",
"key",
"string",
",",
"defaultval",
"float64",
")",
"float64",
"{",
"v",
",",
"err",
":=",
"c",
".",
"Float",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"defa... | // DefaultFloat returns the float64 value for a given key.
// if err != nil return defaltval | [
"DefaultFloat",
"returns",
"the",
"float64",
"value",
"for",
"a",
"given",
"key",
".",
"if",
"err",
"!",
"=",
"nil",
"return",
"defaltval"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L285-L291 |
134,015 | henrylee2cn/pholcus | common/config/ini.go | GetSection | func (c *IniConfigContainer) GetSection(section string) (map[string]string, error) {
if v, ok := c.data[section]; ok {
return v, nil
}
return nil, errors.New("not exist setction")
} | go | func (c *IniConfigContainer) GetSection(section string) (map[string]string, error) {
if v, ok := c.data[section]; ok {
return v, nil
}
return nil, errors.New("not exist setction")
} | [
"func",
"(",
"c",
"*",
"IniConfigContainer",
")",
"GetSection",
"(",
"section",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"if",
"v",
",",
"ok",
":=",
"c",
".",
"data",
"[",
"section",
"]",
";",
"ok",
"{",
"r... | // GetSection returns map for the given section | [
"GetSection",
"returns",
"map",
"for",
"the",
"given",
"section"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/ini.go#L329-L334 |
134,016 | henrylee2cn/pholcus | common/xlsx/xmlStyle.go | addNumFmt | func (styles *xlsxStyleSheet) addNumFmt(xNumFmt xlsxNumFmt) {
// don't add built in NumFmt
if xNumFmt.NumFmtId <= builtinNumFmtsCount {
return
}
_, ok := styles.numFmtRefTable[xNumFmt.NumFmtId]
if !ok {
if styles.numFmtRefTable == nil {
styles.numFmtRefTable = make(map[int]xlsxNumFmt)
}
styles.NumFmts.N... | go | func (styles *xlsxStyleSheet) addNumFmt(xNumFmt xlsxNumFmt) {
// don't add built in NumFmt
if xNumFmt.NumFmtId <= builtinNumFmtsCount {
return
}
_, ok := styles.numFmtRefTable[xNumFmt.NumFmtId]
if !ok {
if styles.numFmtRefTable == nil {
styles.numFmtRefTable = make(map[int]xlsxNumFmt)
}
styles.NumFmts.N... | [
"func",
"(",
"styles",
"*",
"xlsxStyleSheet",
")",
"addNumFmt",
"(",
"xNumFmt",
"xlsxNumFmt",
")",
"{",
"// don't add built in NumFmt",
"if",
"xNumFmt",
".",
"NumFmtId",
"<=",
"builtinNumFmtsCount",
"{",
"return",
"\n",
"}",
"\n",
"_",
",",
"ok",
":=",
"styles... | // addNumFmt add xlsxNumFmt if its not exist. | [
"addNumFmt",
"add",
"xlsxNumFmt",
"if",
"its",
"not",
"exist",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/xmlStyle.go#L329-L343 |
134,017 | henrylee2cn/pholcus | common/mahonia/translate.go | Translate | func (d Decoder) Translate(data []byte, eof bool) (n int, cdata []byte, err error) {
cdata = make([]byte, len(data)+1)
destPos := 0
for n < len(data) {
rune, size, status := d(data[n:])
switch status {
case STATE_ONLY:
n += size
continue
case NO_ROOM:
if !eof {
return n, cdata[:destPos], nil
... | go | func (d Decoder) Translate(data []byte, eof bool) (n int, cdata []byte, err error) {
cdata = make([]byte, len(data)+1)
destPos := 0
for n < len(data) {
rune, size, status := d(data[n:])
switch status {
case STATE_ONLY:
n += size
continue
case NO_ROOM:
if !eof {
return n, cdata[:destPos], nil
... | [
"func",
"(",
"d",
"Decoder",
")",
"Translate",
"(",
"data",
"[",
"]",
"byte",
",",
"eof",
"bool",
")",
"(",
"n",
"int",
",",
"cdata",
"[",
"]",
"byte",
",",
"err",
"error",
")",
"{",
"cdata",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"len",
"(... | // Translate enables a Decoder to implement go-charset's Translator interface. | [
"Translate",
"enables",
"a",
"Decoder",
"to",
"implement",
"go",
"-",
"charset",
"s",
"Translator",
"interface",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/translate.go#L6-L44 |
134,018 | henrylee2cn/pholcus | common/goquery/expand.go | Add | func (s *Selection) Add(selector string) *Selection {
return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, compileMatcher(selector))...)
} | go | func (s *Selection) Add(selector string) *Selection {
return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, compileMatcher(selector))...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Add",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AddNodes",
"(",
"findWithMatcher",
"(",
"[",
"]",
"*",
"html",
".",
"Node",
"{",
"s",
".",
"document",
".",
"rootNode",
"}",
... | // Add adds the selector string's matching nodes to those in the current
// selection and returns a new Selection object.
// The selector string is run in the context of the document of the current
// Selection object. | [
"Add",
"adds",
"the",
"selector",
"string",
"s",
"matching",
"nodes",
"to",
"those",
"in",
"the",
"current",
"selection",
"and",
"returns",
"a",
"new",
"Selection",
"object",
".",
"The",
"selector",
"string",
"is",
"run",
"in",
"the",
"context",
"of",
"the... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/expand.go#L9-L11 |
134,019 | henrylee2cn/pholcus | common/goquery/expand.go | AddMatcher | func (s *Selection) AddMatcher(m Matcher) *Selection {
return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...)
} | go | func (s *Selection) AddMatcher(m Matcher) *Selection {
return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AddMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AddNodes",
"(",
"findWithMatcher",
"(",
"[",
"]",
"*",
"html",
".",
"Node",
"{",
"s",
".",
"document",
".",
"rootNode",
"}",
... | // AddMatcher adds the matcher's matching nodes to those in the current
// selection and returns a new Selection object.
// The matcher is run in the context of the document of the current
// Selection object. | [
"AddMatcher",
"adds",
"the",
"matcher",
"s",
"matching",
"nodes",
"to",
"those",
"in",
"the",
"current",
"selection",
"and",
"returns",
"a",
"new",
"Selection",
"object",
".",
"The",
"matcher",
"is",
"run",
"in",
"the",
"context",
"of",
"the",
"document",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/expand.go#L17-L19 |
134,020 | henrylee2cn/pholcus | common/goquery/expand.go | AddSelection | func (s *Selection) AddSelection(sel *Selection) *Selection {
if sel == nil {
return s.AddNodes()
}
return s.AddNodes(sel.Nodes...)
} | go | func (s *Selection) AddSelection(sel *Selection) *Selection {
if sel == nil {
return s.AddNodes()
}
return s.AddNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AddSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"if",
"sel",
"==",
"nil",
"{",
"return",
"s",
".",
"AddNodes",
"(",
")",
"\n",
"}",
"\n",
"return",
"s",
".",
"AddNodes",
"(",
"sel",... | // AddSelection adds the specified Selection object's nodes to those in the
// current selection and returns a new Selection object. | [
"AddSelection",
"adds",
"the",
"specified",
"Selection",
"object",
"s",
"nodes",
"to",
"those",
"in",
"the",
"current",
"selection",
"and",
"returns",
"a",
"new",
"Selection",
"object",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/expand.go#L23-L28 |
134,021 | henrylee2cn/pholcus | common/goquery/expand.go | AddNodes | func (s *Selection) AddNodes(nodes ...*html.Node) *Selection {
return pushStack(s, appendWithoutDuplicates(s.Nodes, nodes, nil))
} | go | func (s *Selection) AddNodes(nodes ...*html.Node) *Selection {
return pushStack(s, appendWithoutDuplicates(s.Nodes, nodes, nil))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AddNodes",
"(",
"nodes",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"pushStack",
"(",
"s",
",",
"appendWithoutDuplicates",
"(",
"s",
".",
"Nodes",
",",
"nodes",
",",
"nil",
")",
")... | // AddNodes adds the specified nodes to those in the
// current selection and returns a new Selection object. | [
"AddNodes",
"adds",
"the",
"specified",
"nodes",
"to",
"those",
"in",
"the",
"current",
"selection",
"and",
"returns",
"a",
"new",
"Selection",
"object",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/expand.go#L37-L39 |
134,022 | henrylee2cn/pholcus | app/downloader/surfer/util.go | IsDirExists | func IsDirExists(path string) bool {
fi, err := os.Stat(path)
if err != nil {
return os.IsExist(err)
} else {
return fi.IsDir()
}
panic("util isDirExists not reached")
} | go | func IsDirExists(path string) bool {
fi, err := os.Stat(path)
if err != nil {
return os.IsExist(err)
} else {
return fi.IsDir()
}
panic("util isDirExists not reached")
} | [
"func",
"IsDirExists",
"(",
"path",
"string",
")",
"bool",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"os",
".",
"IsExist",
"(",
"err",
")",
"\n",
"}",
"else",
"{",
"return",... | // The IsDirExists judges path is directory or not. | [
"The",
"IsDirExists",
"judges",
"path",
"is",
"directory",
"or",
"not",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/app/downloader/surfer/util.go#L67-L77 |
134,023 | henrylee2cn/pholcus | common/session/sess_file.go | Set | func (fs *FileSessionStore) Set(key, value interface{}) {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.values[key] = value
} | go | func (fs *FileSessionStore) Set(key, value interface{}) {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.values[key] = value
} | [
"func",
"(",
"fs",
"*",
"FileSessionStore",
")",
"Set",
"(",
"key",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"fs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"fs",
".",
"values",
"... | // Set value to file session | [
"Set",
"value",
"to",
"file",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L42-L46 |
134,024 | henrylee2cn/pholcus | common/session/sess_file.go | Get | func (fs *FileSessionStore) Get(key interface{}) interface{} {
fs.lock.RLock()
defer fs.lock.RUnlock()
if v, ok := fs.values[key]; ok {
return v
}
return nil
} | go | func (fs *FileSessionStore) Get(key interface{}) interface{} {
fs.lock.RLock()
defer fs.lock.RUnlock()
if v, ok := fs.values[key]; ok {
return v
}
return nil
} | [
"func",
"(",
"fs",
"*",
"FileSessionStore",
")",
"Get",
"(",
"key",
"interface",
"{",
"}",
")",
"interface",
"{",
"}",
"{",
"fs",
".",
"lock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"fs",
".",
"lock",
".",
"RUnlock",
"(",
")",
"\n",
"if",
"v",
... | // Get value from file session | [
"Get",
"value",
"from",
"file",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L49-L56 |
134,025 | henrylee2cn/pholcus | common/session/sess_file.go | Delete | func (fs *FileSessionStore) Delete(key interface{}) {
fs.lock.Lock()
defer fs.lock.Unlock()
delete(fs.values, key)
} | go | func (fs *FileSessionStore) Delete(key interface{}) {
fs.lock.Lock()
defer fs.lock.Unlock()
delete(fs.values, key)
} | [
"func",
"(",
"fs",
"*",
"FileSessionStore",
")",
"Delete",
"(",
"key",
"interface",
"{",
"}",
")",
"{",
"fs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"fs",
".",
"values",... | // Delete value in file session by given key | [
"Delete",
"value",
"in",
"file",
"session",
"by",
"given",
"key"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L59-L63 |
134,026 | henrylee2cn/pholcus | common/session/sess_file.go | Flush | func (fs *FileSessionStore) Flush() {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.values = make(map[interface{}]interface{})
} | go | func (fs *FileSessionStore) Flush() {
fs.lock.Lock()
defer fs.lock.Unlock()
fs.values = make(map[interface{}]interface{})
} | [
"func",
"(",
"fs",
"*",
"FileSessionStore",
")",
"Flush",
"(",
")",
"{",
"fs",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"fs",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"fs",
".",
"values",
"=",
"make",
"(",
"map",
"[",
"interface",
... | // Flush Clean all values in file session | [
"Flush",
"Clean",
"all",
"values",
"in",
"file",
"session"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L66-L70 |
134,027 | henrylee2cn/pholcus | common/session/sess_file.go | SessionRelease | func (fs *FileSessionStore) SessionRelease(w http.ResponseWriter) {
b, err := EncodeGob(fs.values)
if err != nil {
SLogger.Println(err)
return
}
_, err = os.Stat(path.Join(filepder.savePath, string(fs.sid[0]), string(fs.sid[1]), fs.sid))
var f *os.File
if err == nil {
f, err = os.OpenFile(path.Join(filepder... | go | func (fs *FileSessionStore) SessionRelease(w http.ResponseWriter) {
b, err := EncodeGob(fs.values)
if err != nil {
SLogger.Println(err)
return
}
_, err = os.Stat(path.Join(filepder.savePath, string(fs.sid[0]), string(fs.sid[1]), fs.sid))
var f *os.File
if err == nil {
f, err = os.OpenFile(path.Join(filepder... | [
"func",
"(",
"fs",
"*",
"FileSessionStore",
")",
"SessionRelease",
"(",
"w",
"http",
".",
"ResponseWriter",
")",
"{",
"b",
",",
"err",
":=",
"EncodeGob",
"(",
"fs",
".",
"values",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"SLogger",
".",
"Println",
"... | // SessionRelease Write file session to local file with Gob string | [
"SessionRelease",
"Write",
"file",
"session",
"to",
"local",
"file",
"with",
"Gob",
"string"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L78-L99 |
134,028 | henrylee2cn/pholcus | common/session/sess_file.go | SessionInit | func (fp *FileProvider) SessionInit(maxlifetime int64, savePath string) error {
fp.maxlifetime = maxlifetime
fp.savePath = savePath
return nil
} | go | func (fp *FileProvider) SessionInit(maxlifetime int64, savePath string) error {
fp.maxlifetime = maxlifetime
fp.savePath = savePath
return nil
} | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionInit",
"(",
"maxlifetime",
"int64",
",",
"savePath",
"string",
")",
"error",
"{",
"fp",
".",
"maxlifetime",
"=",
"maxlifetime",
"\n",
"fp",
".",
"savePath",
"=",
"savePath",
"\n",
"return",
"nil",
"\n",
... | // SessionInit Init file session provider.
// savePath sets the session files path. | [
"SessionInit",
"Init",
"file",
"session",
"provider",
".",
"savePath",
"sets",
"the",
"session",
"files",
"path",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L110-L114 |
134,029 | henrylee2cn/pholcus | common/session/sess_file.go | SessionRead | func (fp *FileProvider) SessionRead(sid string) (Store, error) {
filepder.lock.Lock()
defer filepder.lock.Unlock()
err := os.MkdirAll(path.Join(fp.savePath, string(sid[0]), string(sid[1])), 0777)
if err != nil {
SLogger.Println(err.Error())
}
_, err = os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1... | go | func (fp *FileProvider) SessionRead(sid string) (Store, error) {
filepder.lock.Lock()
defer filepder.lock.Unlock()
err := os.MkdirAll(path.Join(fp.savePath, string(sid[0]), string(sid[1])), 0777)
if err != nil {
SLogger.Println(err.Error())
}
_, err = os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1... | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionRead",
"(",
"sid",
"string",
")",
"(",
"Store",
",",
"error",
")",
"{",
"filepder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"filepder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"e... | // SessionRead Read file session by sid.
// if file is not exist, create it.
// the file path is generated from sid string. | [
"SessionRead",
"Read",
"file",
"session",
"by",
"sid",
".",
"if",
"file",
"is",
"not",
"exist",
"create",
"it",
".",
"the",
"file",
"path",
"is",
"generated",
"from",
"sid",
"string",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L119-L153 |
134,030 | henrylee2cn/pholcus | common/session/sess_file.go | SessionExist | func (fp *FileProvider) SessionExist(sid string) bool {
filepder.lock.Lock()
defer filepder.lock.Unlock()
_, err := os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
if err == nil {
return true
}
return false
} | go | func (fp *FileProvider) SessionExist(sid string) bool {
filepder.lock.Lock()
defer filepder.lock.Unlock()
_, err := os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
if err == nil {
return true
}
return false
} | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionExist",
"(",
"sid",
"string",
")",
"bool",
"{",
"filepder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"filepder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"os... | // SessionExist Check file session exist.
// it checkes the file named from sid exist or not. | [
"SessionExist",
"Check",
"file",
"session",
"exist",
".",
"it",
"checkes",
"the",
"file",
"named",
"from",
"sid",
"exist",
"or",
"not",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L157-L166 |
134,031 | henrylee2cn/pholcus | common/session/sess_file.go | SessionDestroy | func (fp *FileProvider) SessionDestroy(sid string) error {
filepder.lock.Lock()
defer filepder.lock.Unlock()
os.Remove(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
return nil
} | go | func (fp *FileProvider) SessionDestroy(sid string) error {
filepder.lock.Lock()
defer filepder.lock.Unlock()
os.Remove(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
return nil
} | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionDestroy",
"(",
"sid",
"string",
")",
"error",
"{",
"filepder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"filepder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n",
"os",
".",
"Remove",
"(",
... | // SessionDestroy Remove all files in this save path | [
"SessionDestroy",
"Remove",
"all",
"files",
"in",
"this",
"save",
"path"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L169-L174 |
134,032 | henrylee2cn/pholcus | common/session/sess_file.go | SessionGC | func (fp *FileProvider) SessionGC() {
filepder.lock.Lock()
defer filepder.lock.Unlock()
gcmaxlifetime = fp.maxlifetime
filepath.Walk(fp.savePath, gcpath)
} | go | func (fp *FileProvider) SessionGC() {
filepder.lock.Lock()
defer filepder.lock.Unlock()
gcmaxlifetime = fp.maxlifetime
filepath.Walk(fp.savePath, gcpath)
} | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionGC",
"(",
")",
"{",
"filepder",
".",
"lock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"filepder",
".",
"lock",
".",
"Unlock",
"(",
")",
"\n\n",
"gcmaxlifetime",
"=",
"fp",
".",
"maxlifetime",
"\n",
"f... | // SessionGC Recycle files in save path | [
"SessionGC",
"Recycle",
"files",
"in",
"save",
"path"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L177-L183 |
134,033 | henrylee2cn/pholcus | common/session/sess_file.go | SessionAll | func (fp *FileProvider) SessionAll() int {
a := &activeSession{}
err := filepath.Walk(fp.savePath, func(path string, f os.FileInfo, err error) error {
return a.visit(path, f, err)
})
if err != nil {
SLogger.Printf("filepath.Walk() returned %v\n", err)
return 0
}
return a.total
} | go | func (fp *FileProvider) SessionAll() int {
a := &activeSession{}
err := filepath.Walk(fp.savePath, func(path string, f os.FileInfo, err error) error {
return a.visit(path, f, err)
})
if err != nil {
SLogger.Printf("filepath.Walk() returned %v\n", err)
return 0
}
return a.total
} | [
"func",
"(",
"fp",
"*",
"FileProvider",
")",
"SessionAll",
"(",
")",
"int",
"{",
"a",
":=",
"&",
"activeSession",
"{",
"}",
"\n",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"fp",
".",
"savePath",
",",
"func",
"(",
"path",
"string",
",",
"f",
"os",
... | // SessionAll Get active file session number.
// it walks save path to count files. | [
"SessionAll",
"Get",
"active",
"file",
"session",
"number",
".",
"it",
"walks",
"save",
"path",
"to",
"count",
"files",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L187-L197 |
134,034 | henrylee2cn/pholcus | common/session/sess_file.go | gcpath | func gcpath(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if (info.ModTime().Unix() + gcmaxlifetime) < time.Now().Unix() {
os.Remove(path)
}
return nil
} | go | func gcpath(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if (info.ModTime().Unix() + gcmaxlifetime) < time.Now().Unix() {
os.Remove(path)
}
return nil
} | [
"func",
"gcpath",
"(",
"path",
"string",
",",
"info",
"os",
".",
"FileInfo",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"info",
".",
"IsDir",
"(",
")",
"{",
"return",
"nil",
"\n"... | // remove file in save path if expired | [
"remove",
"file",
"in",
"save",
"path",
"if",
"expired"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/session/sess_file.go#L252-L263 |
134,035 | henrylee2cn/pholcus | common/mahonia/mbcs.go | AddCharacter | func (table *MBCSTable) AddCharacter(c rune, bytes string) {
if table.fromUnicode == nil {
table.fromUnicode = make(map[rune]string)
}
table.fromUnicode[c] = bytes
trie := &table.toUnicode
for i := 0; i < len(bytes); i++ {
if trie.children == nil {
trie.children = make([]mbcsTrie, 256)
}
b := bytes[i... | go | func (table *MBCSTable) AddCharacter(c rune, bytes string) {
if table.fromUnicode == nil {
table.fromUnicode = make(map[rune]string)
}
table.fromUnicode[c] = bytes
trie := &table.toUnicode
for i := 0; i < len(bytes); i++ {
if trie.children == nil {
trie.children = make([]mbcsTrie, 256)
}
b := bytes[i... | [
"func",
"(",
"table",
"*",
"MBCSTable",
")",
"AddCharacter",
"(",
"c",
"rune",
",",
"bytes",
"string",
")",
"{",
"if",
"table",
".",
"fromUnicode",
"==",
"nil",
"{",
"table",
".",
"fromUnicode",
"=",
"make",
"(",
"map",
"[",
"rune",
"]",
"string",
")... | // AddCharacter adds a character to the table. rune is its Unicode code point,
// and bytes contains the bytes used to encode it in the character set. | [
"AddCharacter",
"adds",
"a",
"character",
"to",
"the",
"table",
".",
"rune",
"is",
"its",
"Unicode",
"code",
"point",
"and",
"bytes",
"contains",
"the",
"bytes",
"used",
"to",
"encode",
"it",
"in",
"the",
"character",
"set",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/mbcs.go#L24-L42 |
134,036 | henrylee2cn/pholcus | common/config/json.go | Parse | func (js *JSONConfig) Parse(filename string) (Configer, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return js.ParseData(content)
} | go | func (js *JSONConfig) Parse(filename string) (Configer, error) {
file, err := os.Open(filename)
if err != nil {
return nil, err
}
defer file.Close()
content, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return js.ParseData(content)
} | [
"func",
"(",
"js",
"*",
"JSONConfig",
")",
"Parse",
"(",
"filename",
"string",
")",
"(",
"Configer",
",",
"error",
")",
"{",
"file",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"filename",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
... | // Parse returns a ConfigContainer with parsed json config map. | [
"Parse",
"returns",
"a",
"ConfigContainer",
"with",
"parsed",
"json",
"config",
"map",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L32-L44 |
134,037 | henrylee2cn/pholcus | common/config/json.go | ParseData | func (js *JSONConfig) ParseData(data []byte) (Configer, error) {
x := &JSONConfigContainer{
data: make(map[string]interface{}),
}
err := json.Unmarshal(data, &x.data)
if err != nil {
var wrappingArray []interface{}
err2 := json.Unmarshal(data, &wrappingArray)
if err2 != nil {
return nil, err
}
x.data... | go | func (js *JSONConfig) ParseData(data []byte) (Configer, error) {
x := &JSONConfigContainer{
data: make(map[string]interface{}),
}
err := json.Unmarshal(data, &x.data)
if err != nil {
var wrappingArray []interface{}
err2 := json.Unmarshal(data, &wrappingArray)
if err2 != nil {
return nil, err
}
x.data... | [
"func",
"(",
"js",
"*",
"JSONConfig",
")",
"ParseData",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"Configer",
",",
"error",
")",
"{",
"x",
":=",
"&",
"JSONConfigContainer",
"{",
"data",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"interface",
"{",
... | // ParseData returns a ConfigContainer with json string | [
"ParseData",
"returns",
"a",
"ConfigContainer",
"with",
"json",
"string"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L47-L61 |
134,038 | henrylee2cn/pholcus | common/config/json.go | DefaultInt | func (c *JSONConfigContainer) DefaultInt(key string, defaultval int) int {
if v, err := c.Int(key); err == nil {
return v
}
return defaultval
} | go | func (c *JSONConfigContainer) DefaultInt(key string, defaultval int) int {
if v, err := c.Int(key); err == nil {
return v
}
return defaultval
} | [
"func",
"(",
"c",
"*",
"JSONConfigContainer",
")",
"DefaultInt",
"(",
"key",
"string",
",",
"defaultval",
"int",
")",
"int",
"{",
"if",
"v",
",",
"err",
":=",
"c",
".",
"Int",
"(",
"key",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"v",
"\n",
"}... | // DefaultInt returns the integer value for a given key.
// if err != nil return defaltval | [
"DefaultInt",
"returns",
"the",
"integer",
"value",
"for",
"a",
"given",
"key",
".",
"if",
"err",
"!",
"=",
"nil",
"return",
"defaltval"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L102-L107 |
134,039 | henrylee2cn/pholcus | common/config/json.go | DefaultInt64 | func (c *JSONConfigContainer) DefaultInt64(key string, defaultval int64) int64 {
if v, err := c.Int64(key); err == nil {
return v
}
return defaultval
} | go | func (c *JSONConfigContainer) DefaultInt64(key string, defaultval int64) int64 {
if v, err := c.Int64(key); err == nil {
return v
}
return defaultval
} | [
"func",
"(",
"c",
"*",
"JSONConfigContainer",
")",
"DefaultInt64",
"(",
"key",
"string",
",",
"defaultval",
"int64",
")",
"int64",
"{",
"if",
"v",
",",
"err",
":=",
"c",
".",
"Int64",
"(",
"key",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"v",
"\... | // DefaultInt64 returns the int64 value for a given key.
// if err != nil return defaltval | [
"DefaultInt64",
"returns",
"the",
"int64",
"value",
"for",
"a",
"given",
"key",
".",
"if",
"err",
"!",
"=",
"nil",
"return",
"defaltval"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L123-L128 |
134,040 | henrylee2cn/pholcus | common/config/json.go | String | func (c *JSONConfigContainer) String(key string) string {
val := c.getData(key)
if val != nil {
if v, ok := val.(string); ok {
return v
}
}
return ""
} | go | func (c *JSONConfigContainer) String(key string) string {
val := c.getData(key)
if val != nil {
if v, ok := val.(string); ok {
return v
}
}
return ""
} | [
"func",
"(",
"c",
"*",
"JSONConfigContainer",
")",
"String",
"(",
"key",
"string",
")",
"string",
"{",
"val",
":=",
"c",
".",
"getData",
"(",
"key",
")",
"\n",
"if",
"val",
"!=",
"nil",
"{",
"if",
"v",
",",
"ok",
":=",
"val",
".",
"(",
"string",
... | // String returns the string value for a given key. | [
"String",
"returns",
"the",
"string",
"value",
"for",
"a",
"given",
"key",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L152-L160 |
134,041 | henrylee2cn/pholcus | common/config/json.go | Set | func (c *JSONConfigContainer) Set(key, val string) error {
c.Lock()
defer c.Unlock()
c.data[key] = val
return nil
} | go | func (c *JSONConfigContainer) Set(key, val string) error {
c.Lock()
defer c.Unlock()
c.data[key] = val
return nil
} | [
"func",
"(",
"c",
"*",
"JSONConfigContainer",
")",
"Set",
"(",
"key",
",",
"val",
"string",
")",
"error",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n",
"c",
".",
"data",
"[",
"key",
"]",
"=",
"val",
"\n",
... | // Set writes a new value for key. | [
"Set",
"writes",
"a",
"new",
"value",
"for",
"key",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L215-L220 |
134,042 | henrylee2cn/pholcus | common/config/json.go | DIY | func (c *JSONConfigContainer) DIY(key string) (v interface{}, err error) {
val := c.getData(key)
if val != nil {
return val, nil
}
return nil, errors.New("not exist key")
} | go | func (c *JSONConfigContainer) DIY(key string) (v interface{}, err error) {
val := c.getData(key)
if val != nil {
return val, nil
}
return nil, errors.New("not exist key")
} | [
"func",
"(",
"c",
"*",
"JSONConfigContainer",
")",
"DIY",
"(",
"key",
"string",
")",
"(",
"v",
"interface",
"{",
"}",
",",
"err",
"error",
")",
"{",
"val",
":=",
"c",
".",
"getData",
"(",
"key",
")",
"\n",
"if",
"val",
"!=",
"nil",
"{",
"return",... | // DIY returns the raw value by a given key. | [
"DIY",
"returns",
"the",
"raw",
"value",
"by",
"a",
"given",
"key",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/config/json.go#L223-L229 |
134,043 | henrylee2cn/pholcus | logs/logs/smtp.go | WriteMsg | func (s *SmtpWriter) WriteMsg(msg string, level int) error {
if level > s.Level {
return nil
}
hp := strings.Split(s.Host, ":")
// Set up authentication information.
auth := s.GetSmtpAuth(hp[0])
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
con... | go | func (s *SmtpWriter) WriteMsg(msg string, level int) error {
if level > s.Level {
return nil
}
hp := strings.Split(s.Host, ":")
// Set up authentication information.
auth := s.GetSmtpAuth(hp[0])
// Connect to the server, authenticate, set the sender and recipient,
// and send the email all in one step.
con... | [
"func",
"(",
"s",
"*",
"SmtpWriter",
")",
"WriteMsg",
"(",
"msg",
"string",
",",
"level",
"int",
")",
"error",
"{",
"if",
"level",
">",
"s",
".",
"Level",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"hp",
":=",
"strings",
".",
"Split",
"(",
"s",
"."... | // write message in smtp writer.
// it will send an email with subject and only this message. | [
"write",
"message",
"in",
"smtp",
"writer",
".",
"it",
"will",
"send",
"an",
"email",
"with",
"subject",
"and",
"only",
"this",
"message",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/logs/logs/smtp.go#L134-L151 |
134,044 | henrylee2cn/pholcus | common/goquery/manipulation.go | After | func (s *Selection) After(selector string) *Selection {
return s.AfterMatcher(compileMatcher(selector))
} | go | func (s *Selection) After(selector string) *Selection {
return s.AfterMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"After",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AfterMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // After applies the selector from the root document and inserts the matched elements
// after the elements in the set of matched elements.
//
// If one of the matched elements in the selection is not currently in the
// document, it's impossible to insert nodes after it, so it will be ignored.
//
// This follows the s... | [
"After",
"applies",
"the",
"selector",
"from",
"the",
"root",
"document",
"and",
"inserts",
"the",
"matched",
"elements",
"after",
"the",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"If",
"one",
"of",
"the",
"matched",
"elements",
"in",... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L16-L18 |
134,045 | henrylee2cn/pholcus | common/goquery/manipulation.go | AfterMatcher | func (s *Selection) AfterMatcher(m Matcher) *Selection {
return s.AfterNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) AfterMatcher(m Matcher) *Selection {
return s.AfterNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AfterMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AfterNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // AfterMatcher applies the matcher from the root document and inserts the matched elements
// after the elements in the set of matched elements.
//
// If one of the matched elements in the selection is not currently in the
// document, it's impossible to insert nodes after it, so it will be ignored.
//
// This follows... | [
"AfterMatcher",
"applies",
"the",
"matcher",
"from",
"the",
"root",
"document",
"and",
"inserts",
"the",
"matched",
"elements",
"after",
"the",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"If",
"one",
"of",
"the",
"matched",
"elements",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L27-L29 |
134,046 | henrylee2cn/pholcus | common/goquery/manipulation.go | AfterSelection | func (s *Selection) AfterSelection(sel *Selection) *Selection {
return s.AfterNodes(sel.Nodes...)
} | go | func (s *Selection) AfterSelection(sel *Selection) *Selection {
return s.AfterNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AfterSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AfterNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // AfterSelection inserts the elements in the selection after each element in the set of matched
// elements.
//
// This follows the same rules as Selection.Append. | [
"AfterSelection",
"inserts",
"the",
"elements",
"in",
"the",
"selection",
"after",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L35-L37 |
134,047 | henrylee2cn/pholcus | common/goquery/manipulation.go | AfterHtml | func (s *Selection) AfterHtml(html string) *Selection {
return s.AfterNodes(parseHtml(html)...)
} | go | func (s *Selection) AfterHtml(html string) *Selection {
return s.AfterNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AfterHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AfterNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // AfterHtml parses the html and inserts it after the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"AfterHtml",
"parses",
"the",
"html",
"and",
"inserts",
"it",
"after",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L42-L44 |
134,048 | henrylee2cn/pholcus | common/goquery/manipulation.go | AfterNodes | func (s *Selection) AfterNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, true, func(sn *html.Node, n *html.Node) {
if sn.Parent != nil {
sn.Parent.InsertBefore(n, sn.NextSibling)
}
})
} | go | func (s *Selection) AfterNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, true, func(sn *html.Node, n *html.Node) {
if sn.Parent != nil {
sn.Parent.InsertBefore(n, sn.NextSibling)
}
})
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AfterNodes",
"(",
"ns",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"manipulateNodes",
"(",
"ns",
",",
"true",
",",
"func",
"(",
"sn",
"*",
"html",
".",
"Node",
",",
"... | // AfterNodes inserts the nodes after each element in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"AfterNodes",
"inserts",
"the",
"nodes",
"after",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L49-L55 |
134,049 | henrylee2cn/pholcus | common/goquery/manipulation.go | AppendMatcher | func (s *Selection) AppendMatcher(m Matcher) *Selection {
return s.AppendNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) AppendMatcher(m Matcher) *Selection {
return s.AppendNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AppendMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AppendNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // AppendMatcher appends the elements specified by the matcher to the end of each element
// in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"AppendMatcher",
"appends",
"the",
"elements",
"specified",
"by",
"the",
"matcher",
"to",
"the",
"end",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append"... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L75-L77 |
134,050 | henrylee2cn/pholcus | common/goquery/manipulation.go | AppendSelection | func (s *Selection) AppendSelection(sel *Selection) *Selection {
return s.AppendNodes(sel.Nodes...)
} | go | func (s *Selection) AppendSelection(sel *Selection) *Selection {
return s.AppendNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AppendSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AppendNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // AppendSelection appends the elements in the selection to the end of each element
// in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"AppendSelection",
"appends",
"the",
"elements",
"in",
"the",
"selection",
"to",
"the",
"end",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L83-L85 |
134,051 | henrylee2cn/pholcus | common/goquery/manipulation.go | AppendHtml | func (s *Selection) AppendHtml(html string) *Selection {
return s.AppendNodes(parseHtml(html)...)
} | go | func (s *Selection) AppendHtml(html string) *Selection {
return s.AppendNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AppendHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"AppendNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // AppendHtml parses the html and appends it to the set of matched elements. | [
"AppendHtml",
"parses",
"the",
"html",
"and",
"appends",
"it",
"to",
"the",
"set",
"of",
"matched",
"elements",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L88-L90 |
134,052 | henrylee2cn/pholcus | common/goquery/manipulation.go | AppendNodes | func (s *Selection) AppendNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, false, func(sn *html.Node, n *html.Node) {
sn.AppendChild(n)
})
} | go | func (s *Selection) AppendNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, false, func(sn *html.Node, n *html.Node) {
sn.AppendChild(n)
})
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"AppendNodes",
"(",
"ns",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"manipulateNodes",
"(",
"ns",
",",
"false",
",",
"func",
"(",
"sn",
"*",
"html",
".",
"Node",
",",
... | // AppendNodes appends the specified nodes to each node in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"AppendNodes",
"appends",
"the",
"specified",
"nodes",
"to",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L95-L99 |
134,053 | henrylee2cn/pholcus | common/goquery/manipulation.go | Before | func (s *Selection) Before(selector string) *Selection {
return s.BeforeMatcher(compileMatcher(selector))
} | go | func (s *Selection) Before(selector string) *Selection {
return s.BeforeMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Before",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"BeforeMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // Before inserts the matched elements before each element in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"Before",
"inserts",
"the",
"matched",
"elements",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L104-L106 |
134,054 | henrylee2cn/pholcus | common/goquery/manipulation.go | BeforeMatcher | func (s *Selection) BeforeMatcher(m Matcher) *Selection {
return s.BeforeNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) BeforeMatcher(m Matcher) *Selection {
return s.BeforeNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"BeforeMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"BeforeNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // BeforeMatcher inserts the matched elements before each element in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"BeforeMatcher",
"inserts",
"the",
"matched",
"elements",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L111-L113 |
134,055 | henrylee2cn/pholcus | common/goquery/manipulation.go | BeforeSelection | func (s *Selection) BeforeSelection(sel *Selection) *Selection {
return s.BeforeNodes(sel.Nodes...)
} | go | func (s *Selection) BeforeSelection(sel *Selection) *Selection {
return s.BeforeNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"BeforeSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"BeforeNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // BeforeSelection inserts the elements in the selection before each element in the set of matched
// elements.
//
// This follows the same rules as Selection.Append. | [
"BeforeSelection",
"inserts",
"the",
"elements",
"in",
"the",
"selection",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L119-L121 |
134,056 | henrylee2cn/pholcus | common/goquery/manipulation.go | BeforeHtml | func (s *Selection) BeforeHtml(html string) *Selection {
return s.BeforeNodes(parseHtml(html)...)
} | go | func (s *Selection) BeforeHtml(html string) *Selection {
return s.BeforeNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"BeforeHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"BeforeNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // BeforeHtml parses the html and inserts it before the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"BeforeHtml",
"parses",
"the",
"html",
"and",
"inserts",
"it",
"before",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L126-L128 |
134,057 | henrylee2cn/pholcus | common/goquery/manipulation.go | BeforeNodes | func (s *Selection) BeforeNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, false, func(sn *html.Node, n *html.Node) {
if sn.Parent != nil {
sn.Parent.InsertBefore(n, sn)
}
})
} | go | func (s *Selection) BeforeNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, false, func(sn *html.Node, n *html.Node) {
if sn.Parent != nil {
sn.Parent.InsertBefore(n, sn)
}
})
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"BeforeNodes",
"(",
"ns",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"manipulateNodes",
"(",
"ns",
",",
"false",
",",
"func",
"(",
"sn",
"*",
"html",
".",
"Node",
",",
... | // BeforeNodes inserts the nodes before each element in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"BeforeNodes",
"inserts",
"the",
"nodes",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L133-L139 |
134,058 | henrylee2cn/pholcus | common/goquery/manipulation.go | Clone | func (s *Selection) Clone() *Selection {
ns := newEmptySelection(s.document)
ns.Nodes = cloneNodes(s.Nodes)
return ns
} | go | func (s *Selection) Clone() *Selection {
ns := newEmptySelection(s.document)
ns.Nodes = cloneNodes(s.Nodes)
return ns
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Clone",
"(",
")",
"*",
"Selection",
"{",
"ns",
":=",
"newEmptySelection",
"(",
"s",
".",
"document",
")",
"\n",
"ns",
".",
"Nodes",
"=",
"cloneNodes",
"(",
"s",
".",
"Nodes",
")",
"\n",
"return",
"ns",
"\n"... | // Clone creates a deep copy of the set of matched nodes. The new nodes will not be
// attached to the document. | [
"Clone",
"creates",
"a",
"deep",
"copy",
"of",
"the",
"set",
"of",
"matched",
"nodes",
".",
"The",
"new",
"nodes",
"will",
"not",
"be",
"attached",
"to",
"the",
"document",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L143-L147 |
134,059 | henrylee2cn/pholcus | common/goquery/manipulation.go | Empty | func (s *Selection) Empty() *Selection {
var nodes []*html.Node
for _, n := range s.Nodes {
for c := n.FirstChild; c != nil; c = n.FirstChild {
n.RemoveChild(c)
nodes = append(nodes, c)
}
}
return pushStack(s, nodes)
} | go | func (s *Selection) Empty() *Selection {
var nodes []*html.Node
for _, n := range s.Nodes {
for c := n.FirstChild; c != nil; c = n.FirstChild {
n.RemoveChild(c)
nodes = append(nodes, c)
}
}
return pushStack(s, nodes)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Empty",
"(",
")",
"*",
"Selection",
"{",
"var",
"nodes",
"[",
"]",
"*",
"html",
".",
"Node",
"\n\n",
"for",
"_",
",",
"n",
":=",
"range",
"s",
".",
"Nodes",
"{",
"for",
"c",
":=",
"n",
".",
"FirstChild"... | // Empty removes all children nodes from the set of matched elements.
// It returns the children nodes in a new Selection. | [
"Empty",
"removes",
"all",
"children",
"nodes",
"from",
"the",
"set",
"of",
"matched",
"elements",
".",
"It",
"returns",
"the",
"children",
"nodes",
"in",
"a",
"new",
"Selection",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L151-L162 |
134,060 | henrylee2cn/pholcus | common/goquery/manipulation.go | Prepend | func (s *Selection) Prepend(selector string) *Selection {
return s.PrependMatcher(compileMatcher(selector))
} | go | func (s *Selection) Prepend(selector string) *Selection {
return s.PrependMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Prepend",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"PrependMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // Prepend prepends the elements specified by the selector to each element in
// the set of matched elements, following the same rules as Append. | [
"Prepend",
"prepends",
"the",
"elements",
"specified",
"by",
"the",
"selector",
"to",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"following",
"the",
"same",
"rules",
"as",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L166-L168 |
134,061 | henrylee2cn/pholcus | common/goquery/manipulation.go | PrependMatcher | func (s *Selection) PrependMatcher(m Matcher) *Selection {
return s.PrependNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) PrependMatcher(m Matcher) *Selection {
return s.PrependNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"PrependMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"PrependNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // PrependMatcher prepends the elements specified by the matcher to each
// element in the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"PrependMatcher",
"prepends",
"the",
"elements",
"specified",
"by",
"the",
"matcher",
"to",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L174-L176 |
134,062 | henrylee2cn/pholcus | common/goquery/manipulation.go | PrependSelection | func (s *Selection) PrependSelection(sel *Selection) *Selection {
return s.PrependNodes(sel.Nodes...)
} | go | func (s *Selection) PrependSelection(sel *Selection) *Selection {
return s.PrependNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"PrependSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"PrependNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // PrependSelection prepends the elements in the selection to each element in
// the set of matched elements.
//
// This follows the same rules as Selection.Append. | [
"PrependSelection",
"prepends",
"the",
"elements",
"in",
"the",
"selection",
"to",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L182-L184 |
134,063 | henrylee2cn/pholcus | common/goquery/manipulation.go | PrependHtml | func (s *Selection) PrependHtml(html string) *Selection {
return s.PrependNodes(parseHtml(html)...)
} | go | func (s *Selection) PrependHtml(html string) *Selection {
return s.PrependNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"PrependHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"PrependNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // PrependHtml parses the html and prepends it to the set of matched elements. | [
"PrependHtml",
"parses",
"the",
"html",
"and",
"prepends",
"it",
"to",
"the",
"set",
"of",
"matched",
"elements",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L187-L189 |
134,064 | henrylee2cn/pholcus | common/goquery/manipulation.go | PrependNodes | func (s *Selection) PrependNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, true, func(sn *html.Node, n *html.Node) {
// sn.FirstChild may be nil, in which case this functions like
// sn.AppendChild()
sn.InsertBefore(n, sn.FirstChild)
})
} | go | func (s *Selection) PrependNodes(ns ...*html.Node) *Selection {
return s.manipulateNodes(ns, true, func(sn *html.Node, n *html.Node) {
// sn.FirstChild may be nil, in which case this functions like
// sn.AppendChild()
sn.InsertBefore(n, sn.FirstChild)
})
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"PrependNodes",
"(",
"ns",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"manipulateNodes",
"(",
"ns",
",",
"true",
",",
"func",
"(",
"sn",
"*",
"html",
".",
"Node",
",",
... | // PrependNodes prepends the specified nodes to each node in the set of
// matched elements.
//
// This follows the same rules as Selection.Append. | [
"PrependNodes",
"prepends",
"the",
"specified",
"nodes",
"to",
"each",
"node",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"Append",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L195-L201 |
134,065 | henrylee2cn/pholcus | common/goquery/manipulation.go | Remove | func (s *Selection) Remove() *Selection {
for _, n := range s.Nodes {
if n.Parent != nil {
n.Parent.RemoveChild(n)
}
}
return s
} | go | func (s *Selection) Remove() *Selection {
for _, n := range s.Nodes {
if n.Parent != nil {
n.Parent.RemoveChild(n)
}
}
return s
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Remove",
"(",
")",
"*",
"Selection",
"{",
"for",
"_",
",",
"n",
":=",
"range",
"s",
".",
"Nodes",
"{",
"if",
"n",
".",
"Parent",
"!=",
"nil",
"{",
"n",
".",
"Parent",
".",
"RemoveChild",
"(",
"n",
")",
... | // Remove removes the set of matched elements from the document.
// It returns the same selection, now consisting of nodes not in the document. | [
"Remove",
"removes",
"the",
"set",
"of",
"matched",
"elements",
"from",
"the",
"document",
".",
"It",
"returns",
"the",
"same",
"selection",
"now",
"consisting",
"of",
"nodes",
"not",
"in",
"the",
"document",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L205-L213 |
134,066 | henrylee2cn/pholcus | common/goquery/manipulation.go | RemoveFiltered | func (s *Selection) RemoveFiltered(selector string) *Selection {
return s.RemoveMatcher(compileMatcher(selector))
} | go | func (s *Selection) RemoveFiltered(selector string) *Selection {
return s.RemoveMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"RemoveFiltered",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"RemoveMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // RemoveFiltered removes the set of matched elements by selector.
// It returns the Selection of removed nodes. | [
"RemoveFiltered",
"removes",
"the",
"set",
"of",
"matched",
"elements",
"by",
"selector",
".",
"It",
"returns",
"the",
"Selection",
"of",
"removed",
"nodes",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L217-L219 |
134,067 | henrylee2cn/pholcus | common/goquery/manipulation.go | RemoveMatcher | func (s *Selection) RemoveMatcher(m Matcher) *Selection {
return s.FilterMatcher(m).Remove()
} | go | func (s *Selection) RemoveMatcher(m Matcher) *Selection {
return s.FilterMatcher(m).Remove()
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"RemoveMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"FilterMatcher",
"(",
"m",
")",
".",
"Remove",
"(",
")",
"\n",
"}"
] | // RemoveMatcher removes the set of matched elements.
// It returns the Selection of removed nodes. | [
"RemoveMatcher",
"removes",
"the",
"set",
"of",
"matched",
"elements",
".",
"It",
"returns",
"the",
"Selection",
"of",
"removed",
"nodes",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L223-L225 |
134,068 | henrylee2cn/pholcus | common/goquery/manipulation.go | ReplaceWith | func (s *Selection) ReplaceWith(selector string) *Selection {
return s.ReplaceWithMatcher(compileMatcher(selector))
} | go | func (s *Selection) ReplaceWith(selector string) *Selection {
return s.ReplaceWithMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"ReplaceWith",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"ReplaceWithMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // ReplaceWith replaces each element in the set of matched elements with the
// nodes matched by the given selector.
// It returns the removed elements.
//
// This follows the same rules as Selection.Append. | [
"ReplaceWith",
"replaces",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"nodes",
"matched",
"by",
"the",
"given",
"selector",
".",
"It",
"returns",
"the",
"removed",
"elements",
".",
"This",
"follows",
"the",
"same",
"ru... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L232-L234 |
134,069 | henrylee2cn/pholcus | common/goquery/manipulation.go | ReplaceWithMatcher | func (s *Selection) ReplaceWithMatcher(m Matcher) *Selection {
return s.ReplaceWithNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) ReplaceWithMatcher(m Matcher) *Selection {
return s.ReplaceWithNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"ReplaceWithMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"ReplaceWithNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // ReplaceWithMatcher replaces each element in the set of matched elements with
// the nodes matched by the given Matcher.
// It returns the removed elements.
//
// This follows the same rules as Selection.Append. | [
"ReplaceWithMatcher",
"replaces",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"nodes",
"matched",
"by",
"the",
"given",
"Matcher",
".",
"It",
"returns",
"the",
"removed",
"elements",
".",
"This",
"follows",
"the",
"same",... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L241-L243 |
134,070 | henrylee2cn/pholcus | common/goquery/manipulation.go | ReplaceWithSelection | func (s *Selection) ReplaceWithSelection(sel *Selection) *Selection {
return s.ReplaceWithNodes(sel.Nodes...)
} | go | func (s *Selection) ReplaceWithSelection(sel *Selection) *Selection {
return s.ReplaceWithNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"ReplaceWithSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"ReplaceWithNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // ReplaceWithSelection replaces each element in the set of matched elements with
// the nodes from the given Selection.
// It returns the removed elements.
//
// This follows the same rules as Selection.Append. | [
"ReplaceWithSelection",
"replaces",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"nodes",
"from",
"the",
"given",
"Selection",
".",
"It",
"returns",
"the",
"removed",
"elements",
".",
"This",
"follows",
"the",
"same",
"rul... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L250-L252 |
134,071 | henrylee2cn/pholcus | common/goquery/manipulation.go | ReplaceWithHtml | func (s *Selection) ReplaceWithHtml(html string) *Selection {
return s.ReplaceWithNodes(parseHtml(html)...)
} | go | func (s *Selection) ReplaceWithHtml(html string) *Selection {
return s.ReplaceWithNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"ReplaceWithHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"ReplaceWithNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // ReplaceWithHtml replaces each element in the set of matched elements with
// the parsed HTML.
// It returns the removed elements.
//
// This follows the same rules as Selection.Append. | [
"ReplaceWithHtml",
"replaces",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"parsed",
"HTML",
".",
"It",
"returns",
"the",
"removed",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"A... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L259-L261 |
134,072 | henrylee2cn/pholcus | common/goquery/manipulation.go | ReplaceWithNodes | func (s *Selection) ReplaceWithNodes(ns ...*html.Node) *Selection {
s.AfterNodes(ns...)
return s.Remove()
} | go | func (s *Selection) ReplaceWithNodes(ns ...*html.Node) *Selection {
s.AfterNodes(ns...)
return s.Remove()
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"ReplaceWithNodes",
"(",
"ns",
"...",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"s",
".",
"AfterNodes",
"(",
"ns",
"...",
")",
"\n",
"return",
"s",
".",
"Remove",
"(",
")",
"\n",
"}"
] | // ReplaceWithNodes replaces each element in the set of matched elements with
// the given nodes.
// It returns the removed elements.
//
// This follows the same rules as Selection.Append. | [
"ReplaceWithNodes",
"replaces",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"given",
"nodes",
".",
"It",
"returns",
"the",
"removed",
"elements",
".",
"This",
"follows",
"the",
"same",
"rules",
"as",
"Selection",
".",
"... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L268-L271 |
134,073 | henrylee2cn/pholcus | common/goquery/manipulation.go | Wrap | func (s *Selection) Wrap(selector string) *Selection {
return s.WrapMatcher(compileMatcher(selector))
} | go | func (s *Selection) Wrap(selector string) *Selection {
return s.WrapMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"Wrap",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"WrapMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // Wrap wraps each element in the set of matched elements inside the first
// element matched by the given selector. The matched child is cloned before
// being inserted into the document.
//
// It returns the original set of elements. | [
"Wrap",
"wraps",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"inside",
"the",
"first",
"element",
"matched",
"by",
"the",
"given",
"selector",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"inserted",
"into",
"the... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L294-L296 |
134,074 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapMatcher | func (s *Selection) WrapMatcher(m Matcher) *Selection {
return s.wrapNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) WrapMatcher(m Matcher) *Selection {
return s.wrapNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // WrapMatcher wraps each element in the set of matched elements inside the
// first element matched by the given matcher. The matched child is cloned
// before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapMatcher",
"wraps",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"inside",
"the",
"first",
"element",
"matched",
"by",
"the",
"given",
"matcher",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"inserted",
"into",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L303-L305 |
134,075 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapSelection | func (s *Selection) WrapSelection(sel *Selection) *Selection {
return s.wrapNodes(sel.Nodes...)
} | go | func (s *Selection) WrapSelection(sel *Selection) *Selection {
return s.wrapNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // WrapSelection wraps each element in the set of matched elements inside the
// first element in the given Selection. The element is cloned before being
// inserted into the document.
//
// It returns the original set of elements. | [
"WrapSelection",
"wraps",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"inside",
"the",
"first",
"element",
"in",
"the",
"given",
"Selection",
".",
"The",
"element",
"is",
"cloned",
"before",
"being",
"inserted",
"into",
"the",
"document... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L312-L314 |
134,076 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapHtml | func (s *Selection) WrapHtml(html string) *Selection {
return s.wrapNodes(parseHtml(html)...)
} | go | func (s *Selection) WrapHtml(html string) *Selection {
return s.wrapNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // WrapHtml wraps each element in the set of matched elements inside the inner-
// most child of the given HTML.
//
// It returns the original set of elements. | [
"WrapHtml",
"wraps",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"inside",
"the",
"inner",
"-",
"most",
"child",
"of",
"the",
"given",
"HTML",
".",
"It",
"returns",
"the",
"original",
"set",
"of",
"elements",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L320-L322 |
134,077 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapNode | func (s *Selection) WrapNode(n *html.Node) *Selection {
return s.wrapNodes(n)
} | go | func (s *Selection) WrapNode(n *html.Node) *Selection {
return s.wrapNodes(n)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapNode",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapNodes",
"(",
"n",
")",
"\n",
"}"
] | // WrapNode wraps each element in the set of matched elements inside the inner-
// most child of the given node. The given node is copied before being inserted
// into the document.
//
// It returns the original set of elements. | [
"WrapNode",
"wraps",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"inside",
"the",
"inner",
"-",
"most",
"child",
"of",
"the",
"given",
"node",
".",
"The",
"given",
"node",
"is",
"copied",
"before",
"being",
"inserted",
"into",
"the"... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L329-L331 |
134,078 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapAll | func (s *Selection) WrapAll(selector string) *Selection {
return s.WrapAllMatcher(compileMatcher(selector))
} | go | func (s *Selection) WrapAll(selector string) *Selection {
return s.WrapAllMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapAll",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"WrapAllMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // WrapAll wraps a single HTML structure, matched by the given selector, around
// all elements in the set of matched elements. The matched child is cloned
// before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapAll",
"wraps",
"a",
"single",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"all",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"inserted",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L346-L348 |
134,079 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapAllMatcher | func (s *Selection) WrapAllMatcher(m Matcher) *Selection {
return s.wrapAllNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) WrapAllMatcher(m Matcher) *Selection {
return s.wrapAllNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapAllMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapAllNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // WrapAllMatcher wraps a single HTML structure, matched by the given Matcher,
// around all elements in the set of matched elements. The matched child is
// cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapAllMatcher",
"wraps",
"a",
"single",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"Matcher",
"around",
"all",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"inserte... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L355-L357 |
134,080 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapAllSelection | func (s *Selection) WrapAllSelection(sel *Selection) *Selection {
return s.wrapAllNodes(sel.Nodes...)
} | go | func (s *Selection) WrapAllSelection(sel *Selection) *Selection {
return s.wrapAllNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapAllSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapAllNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // WrapAllSelection wraps a single HTML structure, the first node of the given
// Selection, around all elements in the set of matched elements. The matched
// child is cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapAllSelection",
"wraps",
"a",
"single",
"HTML",
"structure",
"the",
"first",
"node",
"of",
"the",
"given",
"Selection",
"around",
"all",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L364-L366 |
134,081 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapAllHtml | func (s *Selection) WrapAllHtml(html string) *Selection {
return s.wrapAllNodes(parseHtml(html)...)
} | go | func (s *Selection) WrapAllHtml(html string) *Selection {
return s.wrapAllNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapAllHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapAllNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // WrapAllHtml wraps the given HTML structure around all elements in the set of
// matched elements. The matched child is cloned before being inserted into the
// document.
//
// It returns the original set of elements. | [
"WrapAllHtml",
"wraps",
"the",
"given",
"HTML",
"structure",
"around",
"all",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"inserted",
"into",
"the",
"document",
".",
"It",
"r... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L373-L375 |
134,082 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapAllNode | func (s *Selection) WrapAllNode(n *html.Node) *Selection {
if s.Size() == 0 {
return s
}
wrap := cloneNode(n)
first := s.Nodes[0]
if first.Parent != nil {
first.Parent.InsertBefore(wrap, first)
first.Parent.RemoveChild(first)
}
for c := getFirstChildEl(wrap); c != nil; c = getFirstChildEl(wrap) {
wrap... | go | func (s *Selection) WrapAllNode(n *html.Node) *Selection {
if s.Size() == 0 {
return s
}
wrap := cloneNode(n)
first := s.Nodes[0]
if first.Parent != nil {
first.Parent.InsertBefore(wrap, first)
first.Parent.RemoveChild(first)
}
for c := getFirstChildEl(wrap); c != nil; c = getFirstChildEl(wrap) {
wrap... | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapAllNode",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"if",
"s",
".",
"Size",
"(",
")",
"==",
"0",
"{",
"return",
"s",
"\n",
"}",
"\n\n",
"wrap",
":=",
"cloneNode",
"(",
"n",
")"... | // WrapAllNode wraps the given node around the first element in the Selection,
// making all other nodes in the Selection children of the given node. The node
// is cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapAllNode",
"wraps",
"the",
"given",
"node",
"around",
"the",
"first",
"element",
"in",
"the",
"Selection",
"making",
"all",
"other",
"nodes",
"in",
"the",
"Selection",
"children",
"of",
"the",
"given",
"node",
".",
"The",
"node",
"is",
"cloned",
"before"... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L389-L409 |
134,083 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapInner | func (s *Selection) WrapInner(selector string) *Selection {
return s.WrapInnerMatcher(compileMatcher(selector))
} | go | func (s *Selection) WrapInner(selector string) *Selection {
return s.WrapInnerMatcher(compileMatcher(selector))
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapInner",
"(",
"selector",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"WrapInnerMatcher",
"(",
"compileMatcher",
"(",
"selector",
")",
")",
"\n",
"}"
] | // WrapInner wraps an HTML structure, matched by the given selector, around the
// content of element in the set of matched elements. The matched child is
// cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapInner",
"wraps",
"an",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"the",
"content",
"of",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
"in... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L416-L418 |
134,084 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapInnerMatcher | func (s *Selection) WrapInnerMatcher(m Matcher) *Selection {
return s.wrapInnerNodes(m.MatchAll(s.document.rootNode)...)
} | go | func (s *Selection) WrapInnerMatcher(m Matcher) *Selection {
return s.wrapInnerNodes(m.MatchAll(s.document.rootNode)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapInnerMatcher",
"(",
"m",
"Matcher",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapInnerNodes",
"(",
"m",
".",
"MatchAll",
"(",
"s",
".",
"document",
".",
"rootNode",
")",
"...",
")",
"\n",
"}"
] | // WrapInnerMatcher wraps an HTML structure, matched by the given selector,
// around the content of element in the set of matched elements. The matched
// child is cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapInnerMatcher",
"wraps",
"an",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"the",
"content",
"of",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being"... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L425-L427 |
134,085 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapInnerSelection | func (s *Selection) WrapInnerSelection(sel *Selection) *Selection {
return s.wrapInnerNodes(sel.Nodes...)
} | go | func (s *Selection) WrapInnerSelection(sel *Selection) *Selection {
return s.wrapInnerNodes(sel.Nodes...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapInnerSelection",
"(",
"sel",
"*",
"Selection",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapInnerNodes",
"(",
"sel",
".",
"Nodes",
"...",
")",
"\n",
"}"
] | // WrapInnerSelection wraps an HTML structure, matched by the given selector,
// around the content of element in the set of matched elements. The matched
// child is cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapInnerSelection",
"wraps",
"an",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"the",
"content",
"of",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"bein... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L434-L436 |
134,086 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapInnerHtml | func (s *Selection) WrapInnerHtml(html string) *Selection {
return s.wrapInnerNodes(parseHtml(html)...)
} | go | func (s *Selection) WrapInnerHtml(html string) *Selection {
return s.wrapInnerNodes(parseHtml(html)...)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapInnerHtml",
"(",
"html",
"string",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapInnerNodes",
"(",
"parseHtml",
"(",
"html",
")",
"...",
")",
"\n",
"}"
] | // WrapInnerHtml wraps an HTML structure, matched by the given selector, around
// the content of element in the set of matched elements. The matched child is
// cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapInnerHtml",
"wraps",
"an",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"the",
"content",
"of",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L443-L445 |
134,087 | henrylee2cn/pholcus | common/goquery/manipulation.go | WrapInnerNode | func (s *Selection) WrapInnerNode(n *html.Node) *Selection {
return s.wrapInnerNodes(n)
} | go | func (s *Selection) WrapInnerNode(n *html.Node) *Selection {
return s.wrapInnerNodes(n)
} | [
"func",
"(",
"s",
"*",
"Selection",
")",
"WrapInnerNode",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"*",
"Selection",
"{",
"return",
"s",
".",
"wrapInnerNodes",
"(",
"n",
")",
"\n",
"}"
] | // WrapInnerNode wraps an HTML structure, matched by the given selector, around
// the content of element in the set of matched elements. The matched child is
// cloned before being inserted into the document.
//
// It returns the original set of elements. | [
"WrapInnerNode",
"wraps",
"an",
"HTML",
"structure",
"matched",
"by",
"the",
"given",
"selector",
"around",
"the",
"content",
"of",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"The",
"matched",
"child",
"is",
"cloned",
"before",
"being",
... | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L452-L454 |
134,088 | henrylee2cn/pholcus | common/goquery/manipulation.go | getFirstChildEl | func getFirstChildEl(n *html.Node) *html.Node {
c := n.FirstChild
for c != nil && c.Type != html.ElementNode {
c = c.NextSibling
}
return c
} | go | func getFirstChildEl(n *html.Node) *html.Node {
c := n.FirstChild
for c != nil && c.Type != html.ElementNode {
c = c.NextSibling
}
return c
} | [
"func",
"getFirstChildEl",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"*",
"html",
".",
"Node",
"{",
"c",
":=",
"n",
".",
"FirstChild",
"\n",
"for",
"c",
"!=",
"nil",
"&&",
"c",
".",
"Type",
"!=",
"html",
".",
"ElementNode",
"{",
"c",
"=",
"c",
"... | // Get the first child that is an ElementNode | [
"Get",
"the",
"first",
"child",
"that",
"is",
"an",
"ElementNode"
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L485-L491 |
134,089 | henrylee2cn/pholcus | common/goquery/manipulation.go | cloneNodes | func cloneNodes(ns []*html.Node) []*html.Node {
cns := make([]*html.Node, 0, len(ns))
for _, n := range ns {
cns = append(cns, cloneNode(n))
}
return cns
} | go | func cloneNodes(ns []*html.Node) []*html.Node {
cns := make([]*html.Node, 0, len(ns))
for _, n := range ns {
cns = append(cns, cloneNode(n))
}
return cns
} | [
"func",
"cloneNodes",
"(",
"ns",
"[",
"]",
"*",
"html",
".",
"Node",
")",
"[",
"]",
"*",
"html",
".",
"Node",
"{",
"cns",
":=",
"make",
"(",
"[",
"]",
"*",
"html",
".",
"Node",
",",
"0",
",",
"len",
"(",
"ns",
")",
")",
"\n\n",
"for",
"_",
... | // Deep copy a slice of nodes. | [
"Deep",
"copy",
"a",
"slice",
"of",
"nodes",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L494-L502 |
134,090 | henrylee2cn/pholcus | common/goquery/manipulation.go | cloneNode | func cloneNode(n *html.Node) *html.Node {
nn := &html.Node{
Type: n.Type,
DataAtom: n.DataAtom,
Data: n.Data,
Attr: make([]html.Attribute, len(n.Attr)),
}
copy(nn.Attr, n.Attr)
for c := n.FirstChild; c != nil; c = c.NextSibling {
nn.AppendChild(cloneNode(c))
}
return nn
} | go | func cloneNode(n *html.Node) *html.Node {
nn := &html.Node{
Type: n.Type,
DataAtom: n.DataAtom,
Data: n.Data,
Attr: make([]html.Attribute, len(n.Attr)),
}
copy(nn.Attr, n.Attr)
for c := n.FirstChild; c != nil; c = c.NextSibling {
nn.AppendChild(cloneNode(c))
}
return nn
} | [
"func",
"cloneNode",
"(",
"n",
"*",
"html",
".",
"Node",
")",
"*",
"html",
".",
"Node",
"{",
"nn",
":=",
"&",
"html",
".",
"Node",
"{",
"Type",
":",
"n",
".",
"Type",
",",
"DataAtom",
":",
"n",
".",
"DataAtom",
",",
"Data",
":",
"n",
".",
"Da... | // Deep copy a node. The new node has clones of all the original node's
// children but none of its parents or siblings. | [
"Deep",
"copy",
"a",
"node",
".",
"The",
"new",
"node",
"has",
"clones",
"of",
"all",
"the",
"original",
"node",
"s",
"children",
"but",
"none",
"of",
"its",
"parents",
"or",
"siblings",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/goquery/manipulation.go#L506-L520 |
134,091 | henrylee2cn/pholcus | common/xlsx/date.go | fractionOfADay | func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
f := 5184000000000000 * fraction
nanoseconds = int(math.Mod(f, 1000000000))
f = f / 1000000000
seconds = int(math.Mod(f, 3600))
f = f / 3600
minutes = int(math.Mod(f, 60))
f = f / 60
hours = int(f)
return hours, minutes, seconds... | go | func fractionOfADay(fraction float64) (hours, minutes, seconds, nanoseconds int) {
f := 5184000000000000 * fraction
nanoseconds = int(math.Mod(f, 1000000000))
f = f / 1000000000
seconds = int(math.Mod(f, 3600))
f = f / 3600
minutes = int(math.Mod(f, 60))
f = f / 60
hours = int(f)
return hours, minutes, seconds... | [
"func",
"fractionOfADay",
"(",
"fraction",
"float64",
")",
"(",
"hours",
",",
"minutes",
",",
"seconds",
",",
"nanoseconds",
"int",
")",
"{",
"f",
":=",
"5184000000000000",
"*",
"fraction",
"\n",
"nanoseconds",
"=",
"int",
"(",
"math",
".",
"Mod",
"(",
"... | // Return the integer values for hour, minutes, seconds and
// nanoseconds that comprised a given fraction of a day. | [
"Return",
"the",
"integer",
"values",
"for",
"hour",
"minutes",
"seconds",
"and",
"nanoseconds",
"that",
"comprised",
"a",
"given",
"fraction",
"of",
"a",
"day",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/xlsx/date.go#L27-L37 |
134,092 | henrylee2cn/pholcus | common/websocket/client.go | NewConfig | func NewConfig(server, origin string) (config *Config, err error) {
config = new(Config)
config.Version = ProtocolVersionHybi13
config.Location, err = url.ParseRequestURI(server)
if err != nil {
return
}
config.Origin, err = url.ParseRequestURI(origin)
if err != nil {
return
}
config.Header = http.Header(m... | go | func NewConfig(server, origin string) (config *Config, err error) {
config = new(Config)
config.Version = ProtocolVersionHybi13
config.Location, err = url.ParseRequestURI(server)
if err != nil {
return
}
config.Origin, err = url.ParseRequestURI(origin)
if err != nil {
return
}
config.Header = http.Header(m... | [
"func",
"NewConfig",
"(",
"server",
",",
"origin",
"string",
")",
"(",
"config",
"*",
"Config",
",",
"err",
"error",
")",
"{",
"config",
"=",
"new",
"(",
"Config",
")",
"\n",
"config",
".",
"Version",
"=",
"ProtocolVersionHybi13",
"\n",
"config",
".",
... | // NewConfig creates a new WebSocket config for client connection. | [
"NewConfig",
"creates",
"a",
"new",
"WebSocket",
"config",
"for",
"client",
"connection",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/client.go#L27-L40 |
134,093 | henrylee2cn/pholcus | common/websocket/client.go | NewClient | func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) {
br := bufio.NewReader(rwc)
bw := bufio.NewWriter(rwc)
err = hybiClientHandshake(config, br, bw)
if err != nil {
return
}
buf := bufio.NewReadWriter(br, bw)
ws = newHybiClientConn(config, buf, rwc)
return
} | go | func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) {
br := bufio.NewReader(rwc)
bw := bufio.NewWriter(rwc)
err = hybiClientHandshake(config, br, bw)
if err != nil {
return
}
buf := bufio.NewReadWriter(br, bw)
ws = newHybiClientConn(config, buf, rwc)
return
} | [
"func",
"NewClient",
"(",
"config",
"*",
"Config",
",",
"rwc",
"io",
".",
"ReadWriteCloser",
")",
"(",
"ws",
"*",
"Conn",
",",
"err",
"error",
")",
"{",
"br",
":=",
"bufio",
".",
"NewReader",
"(",
"rwc",
")",
"\n",
"bw",
":=",
"bufio",
".",
"NewWri... | // NewClient creates a new WebSocket client connection over rwc. | [
"NewClient",
"creates",
"a",
"new",
"WebSocket",
"client",
"connection",
"over",
"rwc",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/client.go#L43-L53 |
134,094 | henrylee2cn/pholcus | common/websocket/client.go | Dial | func Dial(url_, protocol, origin string) (ws *Conn, err error) {
config, err := NewConfig(url_, origin)
if err != nil {
return nil, err
}
if protocol != "" {
config.Protocol = []string{protocol}
}
return DialConfig(config)
} | go | func Dial(url_, protocol, origin string) (ws *Conn, err error) {
config, err := NewConfig(url_, origin)
if err != nil {
return nil, err
}
if protocol != "" {
config.Protocol = []string{protocol}
}
return DialConfig(config)
} | [
"func",
"Dial",
"(",
"url_",
",",
"protocol",
",",
"origin",
"string",
")",
"(",
"ws",
"*",
"Conn",
",",
"err",
"error",
")",
"{",
"config",
",",
"err",
":=",
"NewConfig",
"(",
"url_",
",",
"origin",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"ret... | // Dial opens a new client connection to a WebSocket. | [
"Dial",
"opens",
"a",
"new",
"client",
"connection",
"to",
"a",
"WebSocket",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/client.go#L56-L65 |
134,095 | henrylee2cn/pholcus | common/websocket/client.go | DialConfig | func DialConfig(config *Config) (ws *Conn, err error) {
var client net.Conn
if config.Location == nil {
return nil, &DialError{config, ErrBadWebSocketLocation}
}
if config.Origin == nil {
return nil, &DialError{config, ErrBadWebSocketOrigin}
}
switch config.Location.Scheme {
case "ws":
client, err = net.Di... | go | func DialConfig(config *Config) (ws *Conn, err error) {
var client net.Conn
if config.Location == nil {
return nil, &DialError{config, ErrBadWebSocketLocation}
}
if config.Origin == nil {
return nil, &DialError{config, ErrBadWebSocketOrigin}
}
switch config.Location.Scheme {
case "ws":
client, err = net.Di... | [
"func",
"DialConfig",
"(",
"config",
"*",
"Config",
")",
"(",
"ws",
"*",
"Conn",
",",
"err",
"error",
")",
"{",
"var",
"client",
"net",
".",
"Conn",
"\n",
"if",
"config",
".",
"Location",
"==",
"nil",
"{",
"return",
"nil",
",",
"&",
"DialError",
"{... | // DialConfig opens a new client connection to a WebSocket with a config. | [
"DialConfig",
"opens",
"a",
"new",
"client",
"connection",
"to",
"a",
"WebSocket",
"with",
"a",
"config",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/websocket/client.go#L68-L98 |
134,096 | henrylee2cn/pholcus | common/mahonia/charset.go | simplifyName | func simplifyName(name string) string {
var buf bytes.Buffer
for _, c := range name {
switch {
case unicode.IsDigit(c):
buf.WriteRune(c)
case unicode.IsLetter(c):
buf.WriteRune(unicode.ToLower(c))
default:
}
}
return buf.String()
} | go | func simplifyName(name string) string {
var buf bytes.Buffer
for _, c := range name {
switch {
case unicode.IsDigit(c):
buf.WriteRune(c)
case unicode.IsLetter(c):
buf.WriteRune(unicode.ToLower(c))
default:
}
}
return buf.String()
} | [
"func",
"simplifyName",
"(",
"name",
"string",
")",
"string",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"name",
"{",
"switch",
"{",
"case",
"unicode",
".",
"IsDigit",
"(",
"c",
")",
":",
"buf",
".",
"Writ... | // simplifyName converts a name to lower case and removes non-alphanumeric characters.
// This is how the names are used as keys to the maps. | [
"simplifyName",
"converts",
"a",
"name",
"to",
"lower",
"case",
"and",
"removes",
"non",
"-",
"alphanumeric",
"characters",
".",
"This",
"is",
"how",
"the",
"names",
"are",
"used",
"as",
"keys",
"to",
"the",
"maps",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/charset.go#L66-L80 |
134,097 | henrylee2cn/pholcus | common/mahonia/charset.go | RegisterCharset | func RegisterCharset(cs *Charset) {
name := cs.Name
charsets[name] = cs
aliases[simplifyName(name)] = name
for _, alias := range cs.Aliases {
aliases[simplifyName(alias)] = name
}
} | go | func RegisterCharset(cs *Charset) {
name := cs.Name
charsets[name] = cs
aliases[simplifyName(name)] = name
for _, alias := range cs.Aliases {
aliases[simplifyName(alias)] = name
}
} | [
"func",
"RegisterCharset",
"(",
"cs",
"*",
"Charset",
")",
"{",
"name",
":=",
"cs",
".",
"Name",
"\n",
"charsets",
"[",
"name",
"]",
"=",
"cs",
"\n",
"aliases",
"[",
"simplifyName",
"(",
"name",
")",
"]",
"=",
"name",
"\n",
"for",
"_",
",",
"alias"... | // RegisterCharset adds a charset to the charsetMap. | [
"RegisterCharset",
"adds",
"a",
"charset",
"to",
"the",
"charsetMap",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/charset.go#L83-L90 |
134,098 | henrylee2cn/pholcus | common/mahonia/charset.go | NewDecoder | func NewDecoder(name string) Decoder {
cs := GetCharset(name)
if cs == nil {
return nil
}
return cs.NewDecoder()
} | go | func NewDecoder(name string) Decoder {
cs := GetCharset(name)
if cs == nil {
return nil
}
return cs.NewDecoder()
} | [
"func",
"NewDecoder",
"(",
"name",
"string",
")",
"Decoder",
"{",
"cs",
":=",
"GetCharset",
"(",
"name",
")",
"\n",
"if",
"cs",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"cs",
".",
"NewDecoder",
"(",
")",
"\n",
"}"
] | // NewDecoder returns a Decoder to decode the named charset.
// If the name is not found, it returns nil. | [
"NewDecoder",
"returns",
"a",
"Decoder",
"to",
"decode",
"the",
"named",
"charset",
".",
"If",
"the",
"name",
"is",
"not",
"found",
"it",
"returns",
"nil",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/charset.go#L100-L106 |
134,099 | henrylee2cn/pholcus | common/mahonia/charset.go | NewEncoder | func NewEncoder(name string) Encoder {
cs := GetCharset(name)
if cs == nil {
return nil
}
return cs.NewEncoder()
} | go | func NewEncoder(name string) Encoder {
cs := GetCharset(name)
if cs == nil {
return nil
}
return cs.NewEncoder()
} | [
"func",
"NewEncoder",
"(",
"name",
"string",
")",
"Encoder",
"{",
"cs",
":=",
"GetCharset",
"(",
"name",
")",
"\n",
"if",
"cs",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"cs",
".",
"NewEncoder",
"(",
")",
"\n",
"}"
] | // NewEncoder returns an Encoder to encode the named charset. | [
"NewEncoder",
"returns",
"an",
"Encoder",
"to",
"encode",
"the",
"named",
"charset",
"."
] | 5e73d3ff534090b22e8dde1950abe5d0fce5f746 | https://github.com/henrylee2cn/pholcus/blob/5e73d3ff534090b22e8dde1950abe5d0fce5f746/common/mahonia/charset.go#L109-L115 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.