Skip to content

Commit

Permalink
Temporarily got fid of #2 without a complete resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
Karmenzind committed Dec 15, 2023
1 parent 4c8f73c commit 6697c94
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cmd/kd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"os/user"
"runtime"
"strings"
"syscall"
Expand Down Expand Up @@ -166,6 +167,10 @@ func main() {
config.InitConfig()
cfg := config.Cfg
d.ApplyConfig(cfg.EnableEmoji)
if u, _ := user.Current(); u.Username == "root" {
d.EchoWrong("不支持Root用户")
os.Exit(1)
}
if cfg.Logging.Enable {
l, err := logger.InitLogger(&cfg.Logging)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/model/dataobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (r *Result) PrettyFormat(onlyEN bool) string {
// TODO wth is de morgan's law
if !(onlyEN && r.IsEN) {
for _, para := range r.Paraphrase {
if para == "" {
// FIXME (k): <2023-12-15> 从收集步骤规避
continue
}
if normalSentence.MatchString(para) {
s = append(s, d.Para(para))
} else {
Expand Down
15 changes: 11 additions & 4 deletions internal/query/online.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,22 @@ func FetchOnline(r *model.Result) (err error) {
trans := doc.Find("div", "class", "trans-container")
if trans.Error == nil {
// XXX 此处可以输出warning
var para string
if r.IsEN {
for _, v := range trans.FindAll("li") {
r.Paraphrase = append(r.Paraphrase, str.Simplify(v.Text()))
zap.S().Debugf("Got para: %s\n", str.Simplify(v.Text()))
para = str.Simplify(v.Text())
if para != "" {
r.Paraphrase = append(r.Paraphrase, para)
zap.S().Debugf("Got para: %s\n", para)
}
}
} else {
for _, wg := range trans.FindAll("p", "class", "wordGroup") {
r.Paraphrase = append(r.Paraphrase, str.Simplify(wg.FullText()))
zap.S().Debugf("Got para: %s\n", str.Simplify(wg.FullText()))
para = str.Simplify(wg.FullText())
if para != "" {
r.Paraphrase = append(r.Paraphrase, para)
zap.S().Debugf("Got para: %s\n", para)
}
}
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

# BUG

后又查到,remove from notfound

## Risk
- 实际文件名 不改的时候的process_name

Expand Down

0 comments on commit 6697c94

Please sign in to comment.