Compare commits
No commits in common. "8b4f77b223d2a811395f3cf82fc65b84c3838659" and "5b9c1ed1ef9b7b772712867b9f95d2c43051de16" have entirely different histories.
8b4f77b223
...
5b9c1ed1ef
@ -94,8 +94,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme,
|
|||||||
instances := []string { }
|
instances := []string { }
|
||||||
for _, dir := range path {
|
for _, dir := range path {
|
||||||
entries, err := os.ReadDir(dir)
|
entries, err := os.ReadDir(dir)
|
||||||
if err != nil { continue }
|
if err != nil { return Theme { }, err }
|
||||||
|
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
if entry.Name() == name {
|
if entry.Name() == name {
|
||||||
instances = append (
|
instances = append (
|
||||||
@ -144,7 +143,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
if warn {
|
if warn {
|
||||||
log.Printf (
|
log.Printf (
|
||||||
"xdg: could not parse inherited theme '%s': %v",
|
"xdg: could not parse inherited theme %s: %v",
|
||||||
parent, err)
|
parent, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
@ -66,7 +66,7 @@ func Parse (reader io.Reader) (File, error) {
|
|||||||
var specifiedValues map[string] struct { }
|
var specifiedValues map[string] struct { }
|
||||||
for {
|
for {
|
||||||
line, err := buffer.ReadString('\n')
|
line, err := buffer.ReadString('\n')
|
||||||
if errors.Is(err, io.EOF) { break }
|
if errors.Is(err, io.EOF) { return file, nil }
|
||||||
if err != nil { return nil, err }
|
if err != nil { return nil, err }
|
||||||
|
|
||||||
line = strings.TrimSpace(line)
|
line = strings.TrimSpace(line)
|
||||||
@ -109,20 +109,15 @@ func Parse (reader io.Reader) (File, error) {
|
|||||||
group[key] = entry
|
group[key] = entry
|
||||||
} else {
|
} else {
|
||||||
// default value
|
// default value
|
||||||
_, specified := specifiedValues[key]
|
_, exists := group[key]
|
||||||
if specified { return nil, ErrDuplicateEntry }
|
if exists { return nil, ErrDuplicateEntry }
|
||||||
|
entry := newEntry()
|
||||||
entry, exists := group[key]
|
|
||||||
if !exists { entry = newEntry() }
|
|
||||||
|
|
||||||
entry.Value = value
|
entry.Value = value
|
||||||
group[key] = entry
|
group[key] = entry
|
||||||
specifiedValues[key] = struct { } { }
|
specifiedValues[key] = struct { } { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return file, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newEntry () Entry {
|
func newEntry () Entry {
|
||||||
|
@ -168,57 +168,3 @@ File {
|
|||||||
"Icon": testEntry("fooview-new"),
|
"Icon": testEntry("fooview-new"),
|
||||||
},
|
},
|
||||||
})}
|
})}
|
||||||
|
|
||||||
func TestParseLocalized (test *testing.T) {
|
|
||||||
testParseString(test, `
|
|
||||||
[Group 0]
|
|
||||||
Name=something
|
|
||||||
Name[xx_XX]=other thing
|
|
||||||
Name[yy_YY]=another thing
|
|
||||||
Name[zz_ZZ]=yet another thing
|
|
||||||
[Group 1]
|
|
||||||
Name[xx_XX]=other thing
|
|
||||||
Name[yy_YY]=another thing
|
|
||||||
Name=something
|
|
||||||
Name[zz_ZZ]=yet another thing
|
|
||||||
`,
|
|
||||||
File {
|
|
||||||
"Group 0": Group {
|
|
||||||
"Name": Entry {
|
|
||||||
Value: "something",
|
|
||||||
Localized: map[locale.Locale] string {
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "xx",
|
|
||||||
Country: "XX",
|
|
||||||
}: "other thing",
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "yy",
|
|
||||||
Country: "YY",
|
|
||||||
}: "another thing",
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "zz",
|
|
||||||
Country: "ZZ",
|
|
||||||
}: "yet another thing",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"Group 1": Group {
|
|
||||||
"Name": Entry {
|
|
||||||
Value: "something",
|
|
||||||
Localized: map[locale.Locale] string {
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "xx",
|
|
||||||
Country: "XX",
|
|
||||||
}: "other thing",
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "yy",
|
|
||||||
Country: "YY",
|
|
||||||
}: "another thing",
|
|
||||||
locale.Locale {
|
|
||||||
Lang: "zz",
|
|
||||||
Country: "ZZ",
|
|
||||||
}: "yet another thing",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user