|
21 | 21 | import astropy.utils.data
|
22 | 22 | from astropy.utils import deprecated
|
23 | 23 |
|
| 24 | +import pyvo |
| 25 | + |
24 | 26 | from astroquery import version, log, cache_conf
|
25 | 27 | from astroquery.utils import system_tools
|
26 | 28 |
|
@@ -175,18 +177,35 @@ def login(*args, **kwargs):
|
175 | 177 | return newcls
|
176 | 178 |
|
177 | 179 |
|
| 180 | +class BaseVOQuery: |
| 181 | + """ |
| 182 | + Bare minimum base query that sets the Session header to include both astroquery and pyvo. |
| 183 | + Use in modules that rely on PyVO, either on its own or in combination with ``BaseQuery`` (be mindful |
| 184 | + about resolution order of base classes!). |
| 185 | + """ |
| 186 | + def __init__(self): |
| 187 | + super().__init__() |
| 188 | + self._session = requests.Session() |
| 189 | + self._session.headers['User-Agent'] = ( |
| 190 | + f"astroquery/{version.version} pyVO/{pyvo.__version__} Python/{platform.python_version()} " |
| 191 | + f"({platform.system()}) " |
| 192 | + f"{self._session.headers['User-Agent']}") |
| 193 | + |
| 194 | + self.name = self.__class__.__name__.split("Class")[0] |
| 195 | + |
| 196 | + |
178 | 197 | class BaseQuery(metaclass=LoginABCMeta):
|
179 | 198 | """
|
180 | 199 | This is the base class for all the query classes in astroquery. It
|
181 | 200 | is implemented as an abstract class and must not be directly instantiated.
|
182 | 201 | """
|
183 | 202 |
|
184 | 203 | def __init__(self):
|
185 |
| - S = self._session = requests.Session() |
| 204 | + self._session = requests.Session() |
186 | 205 | self._session.hooks['response'].append(self._response_hook)
|
187 |
| - S.headers['User-Agent'] = ( |
| 206 | + self._session.headers['User-Agent'] = ( |
188 | 207 | f"astroquery/{version.version} Python/{platform.python_version()} ({platform.system()}) "
|
189 |
| - f"{S.headers['User-Agent']}") |
| 208 | + f"{self._session.headers['User-Agent']}") |
190 | 209 |
|
191 | 210 | self.name = self.__class__.__name__.split("Class")[0]
|
192 | 211 | self._cache_location = None
|
|
0 commit comments