MCPcopy
hub / github.com/wtfutil/wtf / Add

Method Add

modules/power/managed_devices.go:94–108  ·  view source on GitHub ↗

* -------------------- Exported Functions -------------------- */ Add takes a chunk of raw text and attempts to parse it as managed device data and create an attribute map from it. * A typical chunk will look like: "LowBatteryNotificationPercentage" = 2 "BatteryFaultNotificationType" = "T

(chunk string)

Source from the content-addressed store, hash-verified

92 }
93*/
94func (manDev *ManagedDevice) Add(chunk string) {
95 scanner := bufio.NewScanner(strings.NewReader(chunk))
96
97 for scanner.Scan() {
98 line := strings.ReplaceAll(scanner.Text(), "\"", "")
99
100 pieces := strings.Split(line, "=")
101 if len(pieces) == 2 {
102 left := strings.TrimSpace(pieces[0])
103 right := strings.TrimSpace(pieces[1])
104
105 manDev.Attributes[left] = right
106 }
107 }
108}
109
110// Dump writes out all the device attributes as a single string
111func (manDev *ManagedDevice) Dump() string {

Callers 15

Test_AddFunction · 0.95
Test_AttributesFunction · 0.95
parseMethod · 0.95
travisBuildRequestFunction · 0.45
recentBuildsMethod · 0.45
doGetMethod · 0.45
encodeGetParamsFunction · 0.45
getStatusFunction · 0.45
getTopItemsFunction · 0.45

Calls

no outgoing calls

Tested by 5

Test_AddFunction · 0.76
Test_AttributesFunction · 0.76