remove generated file flinkspkg/readme.py from version control
[flinks.git] / flinkspkg / portability.py
blob136240c8ea725aa5dc54515478c45fe6f24dabad
1 import sys
2 from locale import getpreferredencoding
4 # addstrwrapped: wrapper for curses' addstr which gets around compatibility
5 # issues between python 2.x and python 3.x.
6 # s should be a unicode string in 2.x, or a string in 3.x
7 def addstrwrapped(scr, y, x, s, attr=0):
8 if sys.hexversion > 0x03000000:
9 if y is None:
10 return scr.addstr(s, attr)
11 return scr.addstr(y, x, s, attr)
12 else:
13 if y is None:
14 return scr.addstr(s.encode(getpreferredencoding(), "replace"), attr)
15 return scr.addstr(y, x, s.encode(getpreferredencoding(), "replace"), attr)
17 # I want cmp back.
18 def _cmp(x,y):
19 if sys.hexversion > 0x03000000:
20 return (x>y)-(y>x)
21 else:
22 return cmp(x,y)
24 if sys.hexversion > 0x03000000:
25 from curses import wrapper
26 curseswrapper = wrapper
27 else:
28 from curses.wrapper import wrapper
29 curseswrapper = wrapper