Skip to content

search_pypi_top: add --multiline option - #24

Open
StanFromIreland wants to merge 1 commit into
vstinner:mainfrom
StanFromIreland:multiline
Open

StanFromIreland wants to merge 1 commit into
vstinner:mainfrom
StanFromIreland:multiline

Conversation

@StanFromIreland

Copy link
Copy Markdown

It searches the whole file at once so the regex can match across lines. The regex is also compiled with re.MULTILINE, and each line is reported at most once. This was helpful to me to gather data for a PEP I'm working on, as the idioms I was looking for spanned two or three lines.

CC @hugovk @vstinner

@StanFromIreland StanFromIreland mentioned this pull request Oct 27, 2026
25 of 29 tasks
yield from _grep_lines(archive_filename, filename, fp, regex)


def _grep_lines(archive_filename, filename, fp, regex):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible, I would prefer to not have to maintain two implementatons. Can't we just use _grep_multiline() in all cases (multiline or not)? Just inline _grep_multiline() again in grep().

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would slow down (by a noticeable amount) searches that could be done on a line by line basis, as such I opted to make it optional.

if IGNORE_CYTHON and CYTHON_REGEX.match(data):
logger.info(f"ignore Cython file: {archive_filename}: {filename}")
return
last_start = -1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
last_start = -1
last_start = None

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

Successfully merging this pull request may close these issues.

2 participants