Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pass
class PaymentRequired(WeatherApiException):
pass
class Forbidden(WeatherApiException):
pass
class NotFound(WeatherApiException):
pass
class RequestTimeout(WeatherApiException):
pass
class PayloadTooLarge(WeatherApiException):
pass
class UriTooLong(WeatherApiException):
pass
class TooManyRequests(WeatherApiException):
pass
class InternalServerError(WeatherApiException):
pass
class RequestTimeout(WeatherApiException):
pass
class PayloadTooLarge(WeatherApiException):
pass
class UriTooLong(WeatherApiException):
pass
class TooManyRequests(WeatherApiException):
pass
class InternalServerError(WeatherApiException):
pass
_exceptions = {400: BadRequest,
401: Unauthorized,
403: Forbidden,
404: NotFound,
408: RequestTimeout,
413: PayloadTooLarge,
414: UriTooLong,
429: TooManyRequests,
500: InternalServerError}
version = binary_reader.get_int()
precision = binary_reader.get_int()
num_payloads_per_forecast = binary_reader.get_int()
payload_meta = binary_reader.get_int()
num_forecasts = binary_reader.get_int()
forecast_dates_ux = [binary_reader.get_unsigned_long() for _ in range(num_forecasts)]
# precision in bytes
DOUBLE = 8
FLOAT = 4
if version != 2:
raise WeatherApiException("Only MBG version 2 supported, this is version {}".format(version))
if precision not in [FLOAT, DOUBLE]:
raise WeatherApiException("Received wrong precision {}".format(precision))
if num_payloads_per_forecast > 100000:
raise WeatherApiException("numForecasts too big (possibly big-endian): {}".format(num_payloads_per_forecast))
if num_payloads_per_forecast != 1:
raise WeatherApiException(
"Wrong number of payloads per forecast date received: {}".format(num_payloads_per_forecast))
if payload_meta != 0:
raise WeatherApiException("Wrong payload type received: {}".format(payload_meta))
lons = []
lats = []
value_data_type = "float" if precision == FLOAT else "double"
num_lat = binary_reader.get_int()
# -*- coding: utf-8 -*-
from collections import defaultdict
class WeatherApiException(Exception):
def __init__(self, message):
super(WeatherApiException, self).__init__(message)
class BadRequest(WeatherApiException):
pass
class Unauthorized(WeatherApiException):
pass
class PaymentRequired(WeatherApiException):
pass
class Forbidden(WeatherApiException):
pass
class NotFound(WeatherApiException):
pass
class RequestTimeout(WeatherApiException):
pass
class Forbidden(WeatherApiException):
pass
class NotFound(WeatherApiException):
pass
class RequestTimeout(WeatherApiException):
pass
class PayloadTooLarge(WeatherApiException):
pass
class UriTooLong(WeatherApiException):
pass
class TooManyRequests(WeatherApiException):
pass
class InternalServerError(WeatherApiException):
pass
_exceptions = {400: BadRequest,
401: Unauthorized,
API_EXCEPTIONS = defaultdict(lambda: WeatherApiException, _exceptions)
# -*- coding: utf-8 -*-
from collections import defaultdict
class WeatherApiException(Exception):
def __init__(self, message):
super(WeatherApiException, self).__init__(message)
class BadRequest(WeatherApiException):
pass
class Unauthorized(WeatherApiException):
pass
class PaymentRequired(WeatherApiException):
pass
class Forbidden(WeatherApiException):
pass
class NotFound(WeatherApiException):
# precision in bytes
DOUBLE = 8
FLOAT = 4
if version != 2:
raise WeatherApiException("Only MBG version 2 supported, this is version {}".format(version))
if precision not in [FLOAT, DOUBLE]:
raise WeatherApiException("Received wrong precision {}".format(precision))
if num_payloads_per_forecast > 100000:
raise WeatherApiException("numForecasts too big (possibly big-endian): {}".format(num_payloads_per_forecast))
if num_payloads_per_forecast != 1:
raise WeatherApiException(
"Wrong number of payloads per forecast date received: {}".format(num_payloads_per_forecast))
if payload_meta != 0:
raise WeatherApiException("Wrong payload type received: {}".format(payload_meta))
lons = []
lats = []
value_data_type = "float" if precision == FLOAT else "double"
num_lat = binary_reader.get_int()
for _ in range(num_lat):
lats.append(binary_reader.get_double())
num_lon = binary_reader.get_int()
for _ in range(num_lon):
pass
class NotFound(WeatherApiException):
pass
class RequestTimeout(WeatherApiException):
pass
class PayloadTooLarge(WeatherApiException):
pass
class UriTooLong(WeatherApiException):
pass
class TooManyRequests(WeatherApiException):
pass
class InternalServerError(WeatherApiException):
pass
_exceptions = {400: BadRequest,
401: Unauthorized,
403: Forbidden,
404: NotFound,
408: RequestTimeout,
413: PayloadTooLarge,
def get(self, data_type, n=1):
try:
data_type = data_type.lower()
except AttributeError:
raise BinaryReaderException("Argument data_type has to be string")
data = self._read_data(data_type, n)
if n == 1:
return data[0]
else:
return data