def RELEASE_URLS(cls): """ ``dict`` of available Boost release versions and release page URLs. All (old) releases without download link are excluded """ history_url = URL(str(BOOST_URL) + '/users/history') response = requests.get(history_url) html = BeautifulSoup(response.text, 'html5lib') ilinks = iter(html.find_all('a')) for link in ilinks: if re.match(r'^Version\s+[0-9.]+$', link.text.strip()): release_link = link break else: raise RuntimeError( "no Boost release links found in {}".format(history_url)) result = {} while release_link: next_release_link = download_link = None for link in ilinks: if re.match(r'^Version\s+[0-9.]+$', link.text.strip()): next_release_link = link break if re.match(r'^Download$', link.text.strip()): download_link = link if download_link: version = Version(release_link.text.split()[1]) if version >= MIN_BOOST_VERSION: url = URL(str(BOOST_URL) + release_link.get('href')) result[Version(release_link.text.split()[1])] = url release_link = next_release_link return result
def download_url(self): """ Full URL to ``.tar.bz2`` archive. """ response = requests.get(type(self).RELEASE_URLS[self.version]) html = BeautifulSoup(response.text, 'html5lib') for link in html.find_all('a'): if link.text.strip().endswith('.tar.bz2'): return URL(link.get('href'))
def get_supported_currencies(self): """ Get Coindesk valid currencies list. """ scheme, host, path = self._get_api_url_components() resource = settings.API_ENDPOINTS.get('supported-currencies') path = f'{path}/{self._clean_api_component(resource)}' url = URL(scheme=scheme, host=host, path=path) currencies = None try: utils.validate_url(url.url) currencies = super(CoindeskAPIClient, self).get(url.url, False) except Exception as err: msg = err.args[0] logger.warning(f'[CoindeskAPICient] Get currencies error. {msg}.') if currencies: utils.validate_currencies_settings(currencies) return currencies if currencies else utils.get_currencies_settings()
def _construct_api_endpoint(self, data_type: str, params: dict): """ Get Coindesk api endpoint. :param str data_type: type of data to fetch (currentprice, historical). :param dict params: optional query parameters. :return str: Coindesk api endpoint for correspondig data resource. """ scheme, host, path = self._get_api_url_components() resource = settings.API_ENDPOINTS.get(data_type) if data_type == settings.API_CURRENTPRICE_DATA_TYPE: currency_param = params.pop(settings.CURRENCY_PARAM, '') currency = f'/{currency_param}' if currency_param else currency_param resource = resource.format(currency=currency) path = f'{path}/{self._clean_api_component(resource)}' api_endpoint = URL(scheme=scheme, host=host, path=path, args=params) utils.validate_url(api_endpoint.url) return api_endpoint
compiler = platform.python_compiler() for key, name in supported.items(): if compiler.startswith(key): return name raise RuntimeError( "Could not determine compiler toolset for Boost from " "platform.python_compiler() {!r}. Supported: {!r}".format( compiler, supported)) TOOLSET = _toolset() MSVC = TOOLSET == 'msvc' BOOST_URL = URL('http://www.boost.org') MIN_BOOST_VERSION = Version('1.42.0') class Meta(zetup.meta): """ Metaclass for :class:`Boost.Source`. Provides class properties for retrieving info about available Boost releases """ @property @cached def RELEASE_URLS(cls): """