{"modulePath":"github.com/nickheyer/icebath","version":"v1.2.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pythonutil\n\n## Functions\n\n```go\nfunc ChildNodes(n *Node) iter.Seq[*Node]\n```\nDirect child nodes in field order, contexts and operators included\n\n```go\nfunc Compile(src []byte, filename string) error\n```\nError Python's compiler would raise for the bytes of a file, nil when it compiles: parse errors and the later ones a parser alone misses, such as return outside a function or a nonlocal with no binding; a \\*SyntaxError naming filename, or a \\*LimitError\n\n```go\nfunc LauncherInterpreter(data []byte) (string, bool)\n```\nInterpreter path a Windows console script launcher executable embeds: the loader stub, a \"#!\\\u003cpython\u003e -I\" line, then a zip archive; false for any other layout\n\n```go\nfunc Literal(v any) string\n```\nPython source text of a literal value: a Constant value of a tree or a value LiteralEval gives\n\n```go\nfunc LiteralEval(src string) (any, error)\n```\nValue of a Python literal expression: nil for None, bool, int64, \\*big.Int past int64, float64, complex128, string, \\[]byte, Ellipsis, \\[]any for a list, Tuple, Set or \\*Dict\n\n```go\nfunc LiteralStrings(src string) ([]string, bool)\n```\nItems of a Python list literal as text, a string item as it is, None items left out and any other item in its literal form, false when src is not a list literal\n\n```go\nfunc Quote(s string) string\n```\ns as a Python string literal, single quoted unless only double quotes spare an escape, escaped as Python's repr writes it; a byte that is not UTF-8 becomes the \\\\udcXX escape Python's surrogateescape gives it, so the literal encodes back to the same bytes as a file name or argument, as the embedded interpreter receives such a string\n\n```go\nfunc Unparse(n *Node) (s string, err error)\n```\nPython source text of a tree or of any node in it, written with the minimal parentheses and the quotes that need fewest escapes\n\n```go\nfunc Walk(n *Node) iter.Seq[*Node]\n```\nEvery node of the tree breadth first, the root first\n\n## Types\n\n```go\ntype Dict struct{ Keys, Values []any }\n```\nValue of a dict literal, keys in source order, a repeated key keeping its first place and its last value\n\n```go\ntype Ellipsis struct{}\n```\nValue of the ... constant\n\n```go\ntype ErrorKind uint8\n```\nCategory of a syntax error, told apart the way Python reports it\n\n```go\nconst (\n\t// Source that breaks the grammar or a compile time rule\n\tKindSyntax ErrorKind = iota\n\t// An unexpected, missing or unmatched indent\n\tKindIndentation\n\t// Tabs and spaces mixed so the indentation is ambiguous\n\tKindTab\n)\n```\n\n```go\nfunc (k ErrorKind) String() string\n```\nWords naming the kind: syntax error, indentation error or tab error\n\n```go\ntype LimitError struct {\n\tLine, Limit int\n}\n```\nSource nested deeper than the parser accepts, the guard that keeps hostile input from exhausting the stack\n\n```go\nfunc (e *LimitError) Error() string\n```\nLimit crossed and the line where it happened\n\n```go\ntype LiteralError struct {\n\tLine int\n\tMsg  string\n}\n```\nExpression that parses but is not a literal, or a literal whose set member or dict key cannot be one\n\n```go\nfunc (e *LiteralError) Error() string\n```\nMessage prefixed with the line of the offending expression when it is known\n\n```go\ntype Node struct {\n\tType                       string\n\tLine, Col, EndLine, EndCol int\n\t// contains filtered or unexported fields\n}\n```\nOne syntax tree node: Type is the class name the Python ast module uses, lines count from 1 and columns are 0-based UTF-8 byte offsets, all zero for a node without a position\n\n```go\nfunc Parse(src string) (*Node, error)\n```\nModule tree of Python source text, already decoded so a coding declaration is not applied; the error is a \\*SyntaxError or a \\*LimitError\n\n```go\nfunc ParseBytes(src []byte) (*Node, error)\n```\nModule tree of the bytes of a Python file, decoded as its BOM or coding declaration says and as UTF-8 otherwise; the error is a \\*SyntaxError or a \\*LimitError\n\n```go\nfunc (n *Node) Child(name string) *Node\n```\nNode a field holds, nil when the field is unset or holds no node\n\n```go\nfunc (n *Node) Children(name string) []*Node\n```\nNodes of a list field, nil when the field holds no node list\n\n```go\nfunc (n *Node) Get(name string) any\n```\nValue of a field, nil when absent or None; a Constant value is a bool, int64, \\*big.Int past int64, float64, complex128, string, \\[]byte or Ellipsis\n\n```go\nfunc (n *Node) Int(name string) (int, bool)\n```\nInteger of a field such as an import level and whether it is set\n\n```go\nfunc (n *Node) Is(types ...string) bool\n```\nWhether the node exists and is of one of the classes\n\n```go\nfunc (n *Node) Names(name string) []string\n```\nIdentifiers of a list field such as the names of a global statement\n\n```go\nfunc (n *Node) Str(name string) (string, bool)\n```\nIdentifier or string of a field and whether it is set\n\n```go\ntype Set []any\n```\nValue of a set literal, its distinct members in source order\n\n```go\ntype SyntaxError struct {\n\tKind                             ErrorKind\n\tMsg                              string\n\tLine, Column, EndLine, EndColumn int\n\tText                             string\n\tFilename                         string\n}\n```\nPython source the parser or the compiler rejects, with Python's own message, 1-based character columns and the source line, Line zero when the error has no position\n\n```go\nfunc (e *SyntaxError) Error() string\n```\nLocation and message as file:line:column: message, the parts that are not known left out\n\n```go\ntype Tuple []any\n```\nValue of a tuple literal\n\n","path":"github.com/nickheyer/icebath/pkg/utils/python","name":"pythonutil","synopsis":"","isRedistributable":true}
