MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / pythonRepr

Function pythonRepr

agentContext/tokens.go:42–81  ·  view source on GitHub ↗
(value any)

Source from the content-addressed store, hash-verified

40}
41
42func pythonRepr(value any) string {
43 switch v := value.(type) {
44 case nil:
45 return "None"
46 case string:
47 return pythonStringRepr(v)
48 case bool:
49 if v {
50 return "True"
51 }
52 return "False"
53 case int, int32, int64, float32, float64, json.Number:
54 return strings.TrimSpace(fmtAny(v))
55 case map[string]any:
56 keys := make([]string, 0, len(v))
57 for key := range v {
58 keys = append(keys, key)
59 }
60 sort.Strings(keys)
61 parts := make([]string, 0, len(keys))
62 for _, key := range keys {
63 parts = append(parts, pythonStringRepr(key)+": "+pythonRepr(v[key]))
64 }
65 return "{" + strings.Join(parts, ", ") + "}"
66 case []any:
67 parts := make([]string, 0, len(v))
68 for _, item := range v {
69 parts = append(parts, pythonRepr(item))
70 }
71 return "[" + strings.Join(parts, ", ") + "]"
72 case []map[string]any:
73 parts := make([]string, 0, len(v))
74 for _, item := range v {
75 parts = append(parts, pythonRepr(item))
76 }
77 return "[" + strings.Join(parts, ", ") + "]"
78 default:
79 return pythonStringRepr(fmtAny(v))
80 }
81}
82
83func pythonStringRepr(value string) string {
84 replacer := strings.NewReplacer(

Callers 1

RoughEstimateFunction · 0.85

Calls 2

pythonStringReprFunction · 0.85
fmtAnyFunction · 0.85

Tested by

no test coverage detected