comparison mercurial/encoding.py @ 27355:b479fc425a81

encoding: use absolute_import
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 12 Dec 2015 22:57:48 -0500
parents de5ae97ce9f4
children c2effd1ecebf
comparison
equal deleted inserted replaced
27354:bced7180db19 27355:b479fc425a81
3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others 3 # Copyright 2005-2009 Matt Mackall <mpm@selenic.com> and others
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 import error 8 from __future__ import absolute_import
9 import unicodedata, locale, os 9
10 import locale
11 import os
12 import unicodedata
13
14 from . import (
15 error,
16 )
10 17
11 # These unicode characters are ignored by HFS+ (Apple Technote 1150, 18 # These unicode characters are ignored by HFS+ (Apple Technote 1150,
12 # "Unicode Subtleties"), so we need to ignore them in some places for 19 # "Unicode Subtleties"), so we need to ignore them in some places for
13 # sanity. 20 # sanity.
14 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in 21 _ignore = [unichr(int(x, 16)).encode("utf-8") for x in
192 199
193 If 'leftside' is True, left side of string 's' is trimmed. 200 If 'leftside' is True, left side of string 's' is trimmed.
194 'ellipsis' is always placed at trimmed side. 201 'ellipsis' is always placed at trimmed side.
195 202
196 >>> ellipsis = '+++' 203 >>> ellipsis = '+++'
197 >>> from mercurial import encoding 204 >>> from . import encoding
198 >>> encoding.encoding = 'utf-8' 205 >>> encoding.encoding = 'utf-8'
199 >>> t= '1234567890' 206 >>> t= '1234567890'
200 >>> print trim(t, 12, ellipsis=ellipsis) 207 >>> print trim(t, 12, ellipsis=ellipsis)
201 1234567890 208 1234567890
202 >>> print trim(t, 10, ellipsis=ellipsis) 209 >>> print trim(t, 10, ellipsis=ellipsis)
288 return s.lower() 295 return s.lower()
289 296
290 def asciilower(s): 297 def asciilower(s):
291 # delay importing avoids cyclic dependency around "parsers" in 298 # delay importing avoids cyclic dependency around "parsers" in
292 # pure Python build (util => i18n => encoding => parsers => util) 299 # pure Python build (util => i18n => encoding => parsers => util)
293 import parsers 300 from . import parsers
294 impl = getattr(parsers, 'asciilower', _asciilower) 301 impl = getattr(parsers, 'asciilower', _asciilower)
295 global asciilower 302 global asciilower
296 asciilower = impl 303 asciilower = impl
297 return impl(s) 304 return impl(s)
298 305
304 return s.upper() 311 return s.upper()
305 312
306 def asciiupper(s): 313 def asciiupper(s):
307 # delay importing avoids cyclic dependency around "parsers" in 314 # delay importing avoids cyclic dependency around "parsers" in
308 # pure Python build (util => i18n => encoding => parsers => util) 315 # pure Python build (util => i18n => encoding => parsers => util)
309 import parsers 316 from . import parsers
310 impl = getattr(parsers, 'asciiupper', _asciiupper) 317 impl = getattr(parsers, 'asciiupper', _asciiupper)
311 global asciiupper 318 global asciiupper
312 asciiupper = impl 319 asciiupper = impl
313 return impl(s) 320 return impl(s)
314 321