python

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Extensions = []string{
	"py",
}

Functions

func MakePythonLanguage

func MakePythonLanguage(ctx context.Context, entrypoint string) (context.Context, language.Language[Data, python_grammar.File], error)

Types

type Data

type Data struct{}

type DirectoryResult

type DirectoryResult struct {
	Path        string
	PythonFiles []string
}

type FileResult

type FileResult struct {
	Path string
}

type InitModuleResult

type InitModuleResult struct {
	Path        string
	PythonFiles []string
}

type Language

type Language struct {
	IgnoreModuleImports bool
	PythonPath          []string
}

func (*Language) MakeNode

func (l *Language) MakeNode(path string) (*graph.Node[Data], error)

func (*Language) ParseExports

func (l *Language) ParseExports(file *python_grammar.File) (*language.ExportsResult, error)

func (*Language) ParseFile

func (l *Language) ParseFile(id string) (*python_grammar.File, error)

func (*Language) ParseImports

func (l *Language) ParseImports(file *python_grammar.File) (*language.ImportsResult, error)

func (*Language) ResolveAbsolute

func (l *Language) ResolveAbsolute(slices []string) *ResolveResult

ResolveAbsolute never fails, if nothing is found it just returns nil.

This is fine because we assume that an un-resolved absolute import is pointing to a library or something like that, so no need to take it into account.

type ResolveResult

type ResolveResult struct {
	InitModule *InitModuleResult
	Directory  *DirectoryResult
	File       *FileResult
}

func ResolveRelative

func ResolveRelative(slices []string, dir string, stepsBack int) (*ResolveResult, error)

ResolveRelative cannot return an empty []string, unless an error happened.

In contrary to ResolveAbsolute, this method can return an error as a relative import is always expected to be found.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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