sublime-cypher
sublime-cypher copied to clipboard
cypher query with path produces item_to_str error
A cypher query of the form: start a=node(*) match p=(a) - [:ACTED_IN] -> (movie) <- [:DIRECTED] - (director) return p;
Produces this result in the ST console:
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./Cypher.py", line 130, in run
File "./Cypher.py", line 118, in cypher
File "./Cypher.py", line 31, in print_table
File "./Cypher.py", line 31, in
I am not familiar with python at all, so I did not create pull request. Problem is in unicode strings processing. Here's the fix that works for me. Code converts unicode to ascii, replacing missing chars with question mark:
def item_to_str(item):
if isinstance(item, dict):
data = json.dumps(item['data'])
id_ = item['self'].rsplit('/', 1)[1]
if 'type' in item:
return "[%s:%s %s]" % (
id_, item['type'], data)
else:
return "(%s %s)" % (id_, data)
elif isinstance(item, unicode):
return item.encode('ascii', 'replace')
else:
return str(item)