Created
January 17, 2018 13:59
-
-
Save canassa/1132704f85dbaf55a8c21e546f7ec72d to your computer and use it in GitHub Desktop.
A XMLRPC client that leverages the requests library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from xmlrpc.client import dumps, loads | |
from requests import session | |
class XMLRPC: | |
def __init__(self, url): | |
self.session = session(url) | |
def __getattr__(self, name): | |
return functools.partial(self._call, name) | |
def _call(self, name, *params): | |
response = self.session.post('', data=dumps(params, name)) | |
return loads(response.text)[0][0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment