reizio/reiz.io

reizql: META(filename=...) matcher

isidentical opened this issue · 2 comments

Currently, there is no way to search in a specific project while using Reiz. Considering the intended dataset size (thousands of packages) it might be a cool idea to somehow add META() matcher for searching custom filenames. Here is an example;

Call(
    Name('something'),
    __metadata__ = META(
        filename=f'requests/%'
    )
)

this would match files only under requests/ prefix, which internally means only the requests/ repo.

Here is an example about how to search a specific filename;

query.filters = IR.combine_filters(
query.filters,
IR.filter(
IR.attribute(IR.attribute(None, "_module"), "filename"),
IR.literal(self.expected_filename),
"=",
),
)

And this is the place where you could add new metadata matchers;

@Signature.register("META", ["parent"], {"parent": None})
def convert_meta(node, state, arguments):
state.ensure(node, state.pointer == "__metadata__")
filters = None
if arguments.parent:
filters = IR.combine_filters(
filters, metadata_parent(arguments.parent, state)
)
return filters