# Path: lib/xmlrpc.py
# class RTorrentXMLRPC(object):
# 
#     def __init__(self, target):
#         self.info = target
# 
#         if self.info['type'] == CONNECTION_HTTP:
#             self.c = xmlrpc.client.ServerProxy('http://%s:%i%s' % \
#                 (self.info['host'], self.info['port'], \
#                 self.info['url']))
#         else:
#             self.c = xmlrpc2scgi.RTorrentXMLRPCClient(self.info['fd'])
# 
# 
#     def __getattr__(self, attr, **args):
#         return getattr(self.c, attr)


import xmlrpc.client
import socket
from lib.xmlrpc import RTorrentXMLRPC
.. _multibase-class:

MultiBase
=========

MultiBase is a class that can be inherited to easily create a class that can
send multiple XMLRPC commands in one request, using the xmlrpclib.MultiCall
class. RTorrentQuery and TorrentQuery implement this class.

It also overrides several functions like __getattr__ and __call__ to
make usage simple:

.. code-block:: python

    t = Torrent.query() # Returns a TorrentQuery object which inherits from
                        # MultiBase
    t.get_name().get_hash()
    t.get_upload_rate()

    print t.all()
"""



class MultiBase(object):
    """
    """
    def __init__(self, target, *args):
        """
        """

# Path: lib/xmlrpc.py
# class RTorrentXMLRPC(object):
# 
#     def __init__(self, target):
#         self.info = target
# 
#         if self.info['type'] == CONNECTION_HTTP:
#             self.c = xmlrpc.client.ServerProxy('http://%s:%i%s' % \
#                 (self.info['host'], self.info['port'], \
#                 self.info['url']))
#         else:
#             self.c = xmlrpc2scgi.RTorrentXMLRPCClient(self.info['fd'])
# 
# 
#     def __getattr__(self, attr, **args):
#         return getattr(self.c, attr)


# Path: lib/multibase.py
import xmlrpc.client
import socket
from lib.xmlrpc import RTorrentXMLRPC

.. _multibase-class:

MultiBase
=========

MultiBase is a class that can be inherited to easily create a class that can
send multiple XMLRPC commands in one request, using the xmlrpclib.MultiCall
class. RTorrentQuery and TorrentQuery implement this class.

It also overrides several functions like __getattr__ and __call__ to
make usage simple:

.. code-block:: python

    t = Torrent.query() # Returns a TorrentQuery object which inherits from
                        # MultiBase
    t.get_name().get_hash()
    t.get_upload_rate()

    print t.all()
"""



class MultiBase(object):
    """
    """
    def __init__(self, target, *args):
        """
        """

        self.s = RTorrentXMLRPC(target)