Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return matching lines instead of printing them #15

Open
danihodovic opened this issue Apr 8, 2020 · 2 comments
Open

Return matching lines instead of printing them #15

danihodovic opened this issue Apr 8, 2020 · 2 comments

Comments

@danihodovic
Copy link

search("core", ".//Call/func/Name[@id='AccountFrozenEmail']", recurse=True, print_matches=True)
[('core/services/account.py', 15)]

Instead of printing matches, would it be possible to return the matches as strings?

@danihodovic
Copy link
Author

Workaround for python 3.4+ using a context manager

https://stackoverflow.com/a/40984270/2966951

@spookylukey
Copy link

This is addressed in my fork which separates out searching/printing - https://github.com/spookylukey/pyastgrep/blob/122343e1cbe370e1d6995cd67f2258eb860623a3/src/pyastgrep/search.py#L84

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants