""" Mini-Challenge """ from twisted.internet import defer class Adapter(): """ Adapter class Aufgabe: Asynchron XML-Daten lesen, konvertieren und zurückliefern. """ def __init__(self, path): self.path = path def retrieve_token(self, name): """ Retrieve the content from file name.xml in adapters path directory in a synchronous way, extract the DataReceived/Token and return it as a JSON-Object (stringified) '{"token": value}'. """ # return '{"token": 42}' - don't do this, just a test raise NotImplementedError def retrieve_token_async(self, name): """ Retrieve the content from file name.xml in adapters path directory in an asynchronous way, extract the DataReceived/Token and return it as a Deferred which ends up in a JSON-Object (as above). see: https://twistedmatrix.com/documents/8.0.0/api/twisted.internet.defer.Deferred.html Hint: The simple way is to use defer.succeed(), bonus points for doing it with a callback chain read->parse->convert. """ #return defer.succeed('{"token": 42}') - don't do this, just a test raise NotImplementedError