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

Issue when only http.group.file.name is set #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

braffes
Copy link
Contributor

@braffes braffes commented Feb 14, 2025

Hi,

I encountered an issue with the following configuration for the bank jaspar.elixir.no/download/data/2024/pfm:

http.group.file.name=1
http.group.file.size=-1
http.group.file.date=-1

Normally, the output of this code is a list of tuples. However, in my case, with only one matching pattern, it becomes just a list.

files = re.findall(self.http_parse.file_line, result)

Thus, with the old code the filename became M instead of MA089D.012.2.pfm

rfile['name'] = foundfile[self.http_parse.file_name - 1]

I created a small reproducer:

import re

# Example HTML content
html_content = '''
<li><a href="example4.pfm">MA089D.012.2.pfm</a></li>
'''
# Regular expression pattern
pattern = r'<li><a href=".*?">(MA089.*\.2\.pfm)</a>(</li>)'
# Find all matches
matches = re.findall(pattern, html_content)
print("Double pattern")
print(matches)

pattern = r'<li><a href=".*?">(MA089.*\.2\.pfm)</a></li>'
matches = re.findall(pattern, html_content)
print("Simple pattern")
print(matches)

The output will be:

double pattern
[('MA089D.012.2.pfm', '</li>')]
simple pattern
['MA089D.012.2.pfm']

So, to avoid this issue, I just check if it is a tuple, and if it's not, I assume that we only have the filename.

Best,
Brice

@braffes braffes changed the title Issue when Issue when only http.group.file.name is set Feb 14, 2025
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.

1 participant