home · contact · privacy
Refactor and extend new library.
[plomrogue2-experiments] / new / plomrogue / misc.py
1 def quote(string):
2     """Quote & escape string so client interprets it as single token."""
3     quoted = []
4     quoted += ['"']
5     for c in string:
6         if c in {'"', '\\'}:
7             quoted += ['\\']
8         quoted += [c]
9     quoted += ['"']
10     return ''.join(quoted)
11
12
13 def stringify_yx(tuple_):
14     """Transform tuple (y,x) into string 'Y:'+str(y)+',X:'+str(x)."""
15     return 'Y:' + str(tuple_[0]) + ',X:' + str(tuple_[1])