MCPcopy
hub / github.com/syncthing/syncthing / walkerFor

Function walkerFor

script/translate.go:147–180  ·  view source on GitHub ↗
(basePath string)

Source from the content-addressed store, hash-verified

145}
146
147func walkerFor(basePath string) filepath.WalkFunc {
148 return func(name string, info os.FileInfo, err error) error {
149 if err != nil {
150 return err
151 }
152
153 if !info.Mode().IsRegular() {
154 return nil
155 }
156 fd, err := os.Open(name)
157 if err != nil {
158 log.Fatal(err)
159 }
160 defer fd.Close()
161 switch filepath.Ext(name) {
162 case ".html":
163 doc, err := html.Parse(fd)
164 if err != nil {
165 log.Fatal(err)
166 }
167 generalNode(doc, filepath.Base(name))
168 case ".js":
169 for s := bufio.NewScanner(fd); s.Scan(); {
170 for _, re := range jsRe {
171 for _, matches := range re.FindAllStringSubmatch(s.Text(), -1) {
172 translation("", matches[1])
173 }
174 }
175 }
176 }
177
178 return nil
179 }
180}
181
182func collectThemes(basePath string) {
183 files, err := os.ReadDir(basePath)

Callers 1

mainFunction · 0.70

Calls 9

generalNodeFunction · 0.85
FatalMethod · 0.80
ParseMethod · 0.80
translationFunction · 0.70
IsRegularMethod · 0.65
ModeMethod · 0.65
OpenMethod · 0.65
CloseMethod · 0.65
ScanMethod · 0.65

Tested by

no test coverage detected