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

Refactor WFAU image retrieval to reject deprecated images #2809

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
20 changes: 20 additions & 0 deletions astroquery/wfau/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,26 @@ def parse_imagequery_page(self, html_in, radius=None):
for row in html_in.split("\n")])
return ascii.read(html, format='html')

def extract_urls(self, html_in):
Copy link
Member

Choose a reason for hiding this comment

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

I think I commented this before in another module: I think methods like this should not be class methods, definitely not public ones, but instead private functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I agree - happy to make this, and get_image_list, both private

Copy link
Member

Choose a reason for hiding this comment

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

you can't make get_image_list private, at least not without a deprecation period.

"""
Helper function that uses regexps to extract the image urls from the
given HTML.

Parameters
----------
html_in : str
source from which the urls are to be extracted.

Returns
-------
links : list
The list of URLS extracted from the input.
"""
# Parse html input for links
ahref = re.compile(r'href="([a-zA-Z0-9_\.&\?=%/:-]+)"')
links = ahref.findall(html_in)
return links

def query_region(self, coordinates, *, radius=1 * u.arcmin,
programme_id=None, database=None,
verbose=False, get_query_payload=False, system='J2000',
Expand Down