python

package
v0.6.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//go:embed queries/find_qualified_attr_usage.scm
	FindQualifiedAttrUsage string
)
View Source
var Language = core.SourceLanguage{
	ID:               py,
	Sitter:           python.GetLanguage(),
	CapabilityFinder: lang.NewCapabilityFinder("comment", lang.RegexpRemovePreprocessor(`^#\s*`)),
	TurnIntoComment:  lang.MakeLineCommenter("# "),
}

Functions

func AddRequirements

func AddRequirements(unit *core.ExecutionUnit, requirements string)

func AddRuntimeFile

func AddRuntimeFile(unit *core.ExecutionUnit, templateData any, path string, content []byte) error

func AddRuntimeFiles

func AddRuntimeFiles(unit *core.ExecutionUnit, files embed.FS, templateData any) error

func AddRuntimeImport

func AddRuntimeImport(importString string, file *core.SourceFile) error

AddRuntimeImport injects the supplied import string above the first non-comment statement in the supplied file.

func DoQuery

func DoQuery(c *sitter.Node, q string) query.NextMatchFunc

DoQuery is a thin wrapper around `query.Exec` to use python as the Language.

func NewFile

func NewFile(path string, content io.Reader) (f *core.SourceFile, err error)

func ResolveFileDependencies

func ResolveFileDependencies(files map[string]core.File) (execunit.FileDependencies, error)

func RuntimePath

func RuntimePath(sourcePath string, runtimeModule string) (string, error)

func UnitFileDependencyResolver

func UnitFileDependencyResolver(unit *core.ExecutionUnit) (execunit.FileDependencies, error)

Types

type AddExecRuntimeFiles

type AddExecRuntimeFiles struct {
	// contains filtered or unexported fields
}

func (*AddExecRuntimeFiles) Name

func (p *AddExecRuntimeFiles) Name() string

func (*AddExecRuntimeFiles) Transform

func (p *AddExecRuntimeFiles) Transform(result *core.CompilationResult, deps *core.Dependencies) error

type Attribute

type Attribute struct {
	Name  string
	Node  *sitter.Node
	Alias string
}

type Expose

type Expose struct{}

func (*Expose) Name

func (p *Expose) Name() string

func (Expose) Transform

func (p Expose) Transform(result *core.CompilationResult, deps *core.Dependencies) error

type FunctionArg

type FunctionArg struct {
	Name  string
	Value string
}

func AddOrReplaceArg

func AddOrReplaceArg(arg FunctionArg, args []FunctionArg) []FunctionArg

func (FunctionArg) String

func (a FunctionArg) String() string

type FunctionCallDetails

type FunctionCallDetails struct {
	Name      string
	Arguments []FunctionArg
}

type Import

type Import struct {
	ParentModule string
	Name         string
	// ImportedAttributes is a map from attribute name, to information about that attribute.
	// Given a statement `from foo import bar as the_bar` the attribute name is `bar`.
	ImportedAttributes map[string]Attribute
	Node               *sitter.Node
	ImportedSelf       bool
	Alias              string
}

TODO: capture import scope (e.g. IsGlobal/IsLocal)

func (Import) ImportedAs

func (imp Import) ImportedAs() string

ImportedAs returns the name of the module as it will be used in the (python) code. This is either the (possibly qualified) module name, or the alias.

type Imports

type Imports map[string]Import

func FindImports

func FindImports(file *core.SourceFile) Imports

FindImports returns a map containing each import statement within the file, as a map keyed by the import's qualified name.

For example:

import module_a                     # key is "module_a"
import module_b as the_b            # key is "module_b"
import module_c.module_cc as the_c  # key is "module_c.module_cc"

type KVConfig

type KVConfig struct {
	Imports                        string
	CacheClassArg                  FunctionArg
	AdditionalCacheConstructorArgs []FunctionArg
}

type Persist

type Persist struct {
	// contains filtered or unexported fields
}

func (Persist) Name

func (p Persist) Name() string

func (Persist) Transform

func (p Persist) Transform(result *core.CompilationResult, deps *core.Dependencies) error

type PythonExecutable

type PythonExecutable struct {
}

func (PythonExecutable) Name

func (l PythonExecutable) Name() string

func (PythonExecutable) Transform

func (l PythonExecutable) Transform(result *core.CompilationResult, dependencies *core.Dependencies) error

type PythonPlugins

type PythonPlugins struct {
	Plugins []core.Plugin
}

func NewPythonPlugins

func NewPythonPlugins(cfg *config.Application, runtime Runtime) *PythonPlugins

func (PythonPlugins) Name

func (c PythonPlugins) Name() string

func (PythonPlugins) Transform

func (c PythonPlugins) Transform(result *core.CompilationResult, deps *core.Dependencies) error

type RequirementsTxt

type RequirementsTxt struct {
	// contains filtered or unexported fields
}

func NewRequirementsTxt

func NewRequirementsTxt(path string, content io.Reader) (*RequirementsTxt, error)

func (*RequirementsTxt) AddLine

func (pf *RequirementsTxt) AddLine(text string)

func (*RequirementsTxt) Clone

func (pf *RequirementsTxt) Clone() core.File

func (*RequirementsTxt) Path

func (pf *RequirementsTxt) Path() string

func (*RequirementsTxt) WriteTo

func (pf *RequirementsTxt) WriteTo(out io.Writer) (int64, error)

type Runtime

type Runtime interface {
	AddExecRuntimeFiles(*core.ExecutionUnit, *core.CompilationResult, *core.Dependencies) error
	AddExposeRuntimeFiles(*core.ExecutionUnit) error
	AddKvRuntimeFiles(unit *core.ExecutionUnit) error
	AddFsRuntimeFiles(unit *core.ExecutionUnit, envVarName string, id string) error
	AddOrmRuntimeFiles(unit *core.ExecutionUnit) error
	AddProxyRuntimeFiles(unit *core.ExecutionUnit, proxyType string) error
	AddSecretRuntimeFiles(unit *core.ExecutionUnit) error
	GetKvRuntimeConfig() KVConfig
	GetFsRuntimeImportClass(id string, varName string) string
	GetSecretRuntimeImportClass(varName string) string
	GetAppName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL