Show More
@@ -247,6 +247,7 def trim(s, width, ellipsis='', leftside | |||||
247 | If 'leftside' is True, left side of string 's' is trimmed. |
|
247 | If 'leftside' is True, left side of string 's' is trimmed. | |
248 | 'ellipsis' is always placed at trimmed side. |
|
248 | 'ellipsis' is always placed at trimmed side. | |
249 |
|
249 | |||
|
250 | >>> from .node import bin | |||
250 | >>> ellipsis = b'+++' |
|
251 | >>> ellipsis = b'+++' | |
251 | >>> from . import encoding |
|
252 | >>> from . import encoding | |
252 | >>> encoding.encoding = b'utf-8' |
|
253 | >>> encoding.encoding = b'utf-8' | |
@@ -285,7 +286,7 def trim(s, width, ellipsis='', leftside | |||||
285 | +++ |
|
286 | +++ | |
286 | >>> print trim(t, 4, ellipsis=ellipsis, leftside=True) |
|
287 | >>> print trim(t, 4, ellipsis=ellipsis, leftside=True) | |
287 | +++ |
|
288 | +++ | |
288 |
>>> t = b' |
|
289 | >>> t = bin(b'112233445566778899aa') # invalid byte sequence | |
289 | >>> print trim(t, 12, ellipsis=ellipsis) |
|
290 | >>> print trim(t, 12, ellipsis=ellipsis) | |
290 | \x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa |
|
291 | \x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa | |
291 | >>> print trim(t, 10, ellipsis=ellipsis) |
|
292 | >>> print trim(t, 10, ellipsis=ellipsis) |
@@ -95,7 +95,7 def _buildencodefun(): | |||||
95 | >>> dec(b'hello~3aworld~3f') |
|
95 | >>> dec(b'hello~3aworld~3f') | |
96 | 'hello:world?' |
|
96 | 'hello:world?' | |
97 |
|
97 | |||
98 | >>> enc(b'the\x07quick\xADshot') |
|
98 | >>> enc(b'the\\x07quick\\xADshot') | |
99 | 'the~07quick~adshot' |
|
99 | 'the~07quick~adshot' | |
100 | >>> dec(b'the~07quick~adshot') |
|
100 | >>> dec(b'the~07quick~adshot') | |
101 | 'the\\x07quick\\xadshot' |
|
101 | 'the\\x07quick\\xadshot' | |
@@ -154,7 +154,7 def _buildlowerencodefun(): | |||||
154 | 'hello' |
|
154 | 'hello' | |
155 | >>> f(b'hello:world?') |
|
155 | >>> f(b'hello:world?') | |
156 | 'hello~3aworld~3f' |
|
156 | 'hello~3aworld~3f' | |
157 | >>> f(b'the\x07quick\xADshot') |
|
157 | >>> f(b'the\\x07quick\\xADshot') | |
158 | 'the~07quick~adshot' |
|
158 | 'the~07quick~adshot' | |
159 | ''' |
|
159 | ''' | |
160 | cmap = dict([(chr(x), chr(x)) for x in xrange(127)]) |
|
160 | cmap = dict([(chr(x), chr(x)) for x in xrange(127)]) |
General Comments 0
You need to be logged in to leave comments.
Login now