
Reiz.io es un motor de búsqueda de código fuente estructural para Python. En comparación con las alternativas populares (por ejemplo, la búsqueda de código GitHub) ejecuta consultas sobre los árboles de sintaxis (en lugar del código fuente sin procesar) e intenta recuperar el conocimiento estructural (sin semántica aplicada). Para obtener más información, consulte los documentos.
Reiz es el marco de búsqueda de códigos en el que Reiz.io está construido en la parte superior. Debido a su naturaleza, trabaja únicamente con los ASTS e intencionalmente evita hacer cualquier trabajo semántico.
Some ASTs attach a bit of contextual knowledge (e.g `Name(ctx=...)`
on python) which can be queried through simple matcher queries but
reiz.io doesn't include them when comparing references (see
matchers#reference-matcher for details).
Aquí hay una consulta Reizql simple que busca una función que termine con una declaración de prueba en la que devuelvamos una llamada a una función que tiene el mismo nombre que la función en la que estamos.
FunctionDef ( ~ func , body = [ * ..., Try ( body = [ Return ( Call ( Name ( ~ func )))])])que coincidiría con lo siguiente;
def foo ( spam ):
eggs = bar ()
try :
return foo ( spam + eggs )
except ValueError :
return NoneEn el sentido muy básico, está generando el AST del código anterior y verifica si se ajusta al patrón (consulta Reizql) o no.;
FunctionDef (
name = 'foo' ,
args = arguments (
posonlyargs = [],
args = [ arg ( arg = 'spam' , annotation = None , type_comment = None )],
vararg = None ,
kwonlyargs = [],
kw_defaults = [],
kwarg = None ,
defaults = [],
),
body = [
Assign (
targets = [ Name ( id = 'eggs' , ctx = Store ())],
value = Call (
func = Name ( id = 'bar' , ctx = Load ()),
args = [],
keywords = [],
),
type_comment = None ,
),
Try (
body = [
Return (
value = Call (
func = Name ( id = 'foo' , ctx = Load ()),
args = [
BinOp (
left = Name ( id = 'spam' , ctx = Load ()),
op = Add (),
right = Name ( id = 'eggs' , ctx = Load ()),
),
],
keywords = [],
),
),
],
handlers = [
ExceptHandler (
type = Name ( id = 'ValueError' , ctx = Load ()),
name = None ,
body = [
Return (
value = Constant ( value = None , kind = None ),
),
],
),
],
orelse = [],
finalbody = [],
),
],
decorator_list = [],
returns = None ,
type_comment = None ,
)