I have the following code, written in Python:
if id: fields = r.table(cls._tablename) .get(id) .run(cls.connection()) else: try: fields = list(r.table(cls._tablename) .filter(**kwargs) .limit(1) .run(cls.connection())) except IndexError: fields = None
The code acts as a wrapper for getting a document from a RethinkDB datastore. I find all those indents unaesthetic, and I cannot seem to find a way to wrap the lines to look nicer.
So, is there a way I can rewrite (or maybe just rewrap) this code to look better and provide the same functionality?