Take a url or some xml response from JottaCloud and wrap it up with the corresponding JFS* class

def getObject(self, url_or_requests_response, params=None):
        'Take a url or some xml response from JottaCloud and wrap it up with the corresponding JFS* class'
        if isinstance(url_or_requests_response, requests.models.Response):
            # this is a raw xml response that we need to parse
            url = url_or_requests_response.url
            o = lxml.objectify.fromstring(url_or_requests_response.content)
        else:
            # this is an url that we need to fetch
            url = url_or_requests_response
            o = self.get(url, params=params) # (.get() will parse this for us)

        parent = os.path.dirname(url).replace('up.jottacloud.com', 'www.jottacloud.com')
        if o.tag == 'error':
            JFSError.raiseError(o, url)
        elif o.tag == 'device': return JFSDevice(o, jfs=self, parentpath=parent)
        elif o.tag == 'folder': return JFSFolder(o, jfs=self, parentpath=parent)
        elif o.tag == 'mountPoint': return JFSMountPoint(o, jfs=self, parentpath=parent)
        elif o.tag == 'restoredFiles': return JFSFile(o, jfs=self, parentpath=parent)
        elif o.tag == 'deleteFiles': return JFSFile(o, jfs=self, parentpath=parent)
        elif o.tag == 'file':
            return ProtoFile.factory(o, jfs=self, parentpath=parent)
#             try:
#                 if o.latestRevision.state == 'INCOMPLETE':
#                     return JFSIncompleteFile(o, jfs=self, parentpath=parent)
#                 elif o.latestRevision.state == 'CORRUPT':
#                     return JFSCorruptFile(o, jfs=self, parentpath=parent)
#             except AttributeError:
#                 return JFSFile(o, jfs=self, parentpath=parent)
        elif o.tag == 'enableSharing': return JFSenableSharing(o, jfs=self)
        elif o.tag == 'user':
            self.fs = o
            return self.fs
        elif o.tag == 'filedirlist': return JFSFileDirList(o, jfs=self, parentpath=parent)
        elif o.tag == 'searchresult': return JFSsearchresult(o, jfs=self)
        raise JFSError("invalid object: %s <- %s" % (repr(o), url_or_requests_response))