# Path: ricloud/compat.py
# PY3 = sys.version_info[0] >= 3
#     def want_bytes(data):
#     def want_text(data):
#     def to_str(data):
#     def want_bytes(data):
#     def want_text(data):
#     def to_str(data):
# 
# Path: ricloud/requests.py
# class RequestHandler(object):
#     def __init__(self):
#         self.session = requests.Session()
# 
#         self.max_retries = conf.getint("api", "max_retries")
#         self.await_for = conf.get("api", "await_for")
# 
#     def set_headers(self, headers):
#         headers = headers or {}
# 
#         headers.setdefault("User-Agent", get_user_agent_header())
#         headers.setdefault("Authorization", get_auth_header())
# 
#         if self.await_for:
#             headers.setdefault("Ricloud-Await", self.await_for)
# 
#         return headers
# 
#     def get(self, url, headers=None, params=None):
#         if params:
#             for param, value in params.items():
#                 encoded_value = encode(value)
#                 params[param] = encoded_value if encoded_value is not None else value
# 
#         return self.send("GET", url, headers=headers, params=params)
# 
#     def post(self, url, headers=None, data=None):
#         json_data = encode_json(data)
# 
#         return self.send("POST", url, headers=headers, data=json_data)
# 
#     def delete(self, url, headers=None):
#         return self.send("DELETE", url, headers=headers)
# 
#     def send(self, method, url, headers=None, data=None, params=None):
#         headers = self.set_headers(headers)
# 
#         response = self._send(
#             method=method,
#             url=url,
#             headers=headers,
#             data=data,
#             params=params,
#             retries_remaining=self.max_retries,
#         )
# 
#         if response.status_code >= 500:
#             raise ServerError(response.status_code, response.content)
#         elif response.status_code >= 400:
#             raise RequestError(response.status_code, response.content)
# 
#         return decode_json(response.content), response.status_code
# 
#     def _send(self, method, url, headers, data, params, retries_remaining=None):
#         try:
#             response = self.session.request(
#                 method=method, url=url, headers=headers, data=data, params=params
#             )
#         except (ConnectionError, Timeout):
#             if not retries_remaining:
#                 raise
# 
#             response = None
# 
#         # Explicit None comparison as bad responses are falsey.
#         if response is None or (response.status_code >= 500):
#             if retries_remaining:
#                 return self._send(
#                     method=method,
#                     url=url,
#                     headers=headers,
#                     data=data,
#                     params=params,
#                     retries_remaining=retries_remaining - 1,
#                 )
# 
#         return response
# 
# Path: ricloud/utils.py
# def pretty_print(data):
#     return json.dumps(data, indent=2, cls=ExpandedDataEncoder, ensure_ascii=False)
# 
# def join_url(base, url, allow_fragments=True):
#     return compat.urljoin(base, url, allow_fragments=allow_fragments)


from collections import OrderedDict
from ricloud.compat import Mapping, MutableMapping, MutableSequence
from ricloud.requests import RequestHandler
from ricloud.utils import pretty_print, join_url
import ricloud
    def __iter__(self):
        return iter(self.attrs)

    def __len__(self):
        return len(self.attrs)

    def __getattr__(self, name):
        try:
            return self.__dict__["attrs"][name]
        except KeyError:
            raise AttributeError("Unknown attribute: %s" % name)

    def __setattr__(self, name, value):
        if name in self.__dict__:
            if name == "attrs" and value:
                value = self.parse_attrs(value)

            return super(ABResource, self).__setattr__(name, value)

        self.attrs[name] = self.parse_value(value)

    def __delattr__(self, name):
        if name in self.__dict__:
            return super(ABResource, self).__delattr__(name)

        del self.attrs[name]

    def __eq__(self, other):
        ignore = ["resource"]
        attrs_self = {key: value for key, value in self.items() if key not in ignore}

# Path: ricloud/compat.py
# PY3 = sys.version_info[0] >= 3
#     def want_bytes(data):
#     def want_text(data):
#     def to_str(data):
#     def want_bytes(data):
#     def want_text(data):
#     def to_str(data):
# 
# Path: ricloud/requests.py
# class RequestHandler(object):
#     def __init__(self):
#         self.session = requests.Session()
# 
#         self.max_retries = conf.getint("api", "max_retries")
#         self.await_for = conf.get("api", "await_for")
# 
#     def set_headers(self, headers):
#         headers = headers or {}
# 
#         headers.setdefault("User-Agent", get_user_agent_header())
#         headers.setdefault("Authorization", get_auth_header())
# 
#         if self.await_for:
#             headers.setdefault("Ricloud-Await", self.await_for)
# 
#         return headers
# 
#     def get(self, url, headers=None, params=None):
#         if params:
#             for param, value in params.items():
#                 encoded_value = encode(value)
#                 params[param] = encoded_value if encoded_value is not None else value
# 
#         return self.send("GET", url, headers=headers, params=params)
# 
#     def post(self, url, headers=None, data=None):
#         json_data = encode_json(data)
# 
#         return self.send("POST", url, headers=headers, data=json_data)
# 
#     def delete(self, url, headers=None):
#         return self.send("DELETE", url, headers=headers)
# 
#     def send(self, method, url, headers=None, data=None, params=None):
#         headers = self.set_headers(headers)
# 
#         response = self._send(
#             method=method,
#             url=url,
#             headers=headers,
#             data=data,
#             params=params,
#             retries_remaining=self.max_retries,
#         )
# 
#         if response.status_code >= 500:
#             raise ServerError(response.status_code, response.content)
#         elif response.status_code >= 400:
#             raise RequestError(response.status_code, response.content)
# 
#         return decode_json(response.content), response.status_code
# 
#     def _send(self, method, url, headers, data, params, retries_remaining=None):
#         try:
#             response = self.session.request(
#                 method=method, url=url, headers=headers, data=data, params=params
#             )
#         except (ConnectionError, Timeout):
#             if not retries_remaining:
#                 raise
# 
#             response = None
# 
#         # Explicit None comparison as bad responses are falsey.
#         if response is None or (response.status_code >= 500):
#             if retries_remaining:
#                 return self._send(
#                     method=method,
#                     url=url,
#                     headers=headers,
#                     data=data,
#                     params=params,
#                     retries_remaining=retries_remaining - 1,
#                 )
# 
#         return response
# 
# Path: ricloud/utils.py
# def pretty_print(data):
#     return json.dumps(data, indent=2, cls=ExpandedDataEncoder, ensure_ascii=False)
# 
# def join_url(base, url, allow_fragments=True):
#     return compat.urljoin(base, url, allow_fragments=allow_fragments)


# Path: ricloud/resources/abase.py
from collections import OrderedDict
from ricloud.compat import Mapping, MutableMapping, MutableSequence
from ricloud.requests import RequestHandler
from ricloud.utils import pretty_print, join_url
import ricloud

    def __iter__(self):
        return iter(self.attrs)

    def __len__(self):
        return len(self.attrs)

    def __getattr__(self, name):
        try:
            return self.__dict__["attrs"][name]
        except KeyError:
            raise AttributeError("Unknown attribute: %s" % name)

    def __setattr__(self, name, value):
        if name in self.__dict__:
            if name == "attrs" and value:
                value = self.parse_attrs(value)

            return super(ABResource, self).__setattr__(name, value)

        self.attrs[name] = self.parse_value(value)

    def __delattr__(self, name):
        if name in self.__dict__:
            return super(ABResource, self).__delattr__(name)

        del self.attrs[name]

    def __eq__(self, other):
        ignore = ["resource"]
        attrs_self = {key: value for key, value in self.items() if key not in ignore}

        attrs_other = {key: value for key, value in other.items() if key not in ignore}