Package tdi :: Package tools :: Module _util
[frames] | no frames]

Source Code for Module tdi.tools._util

 1  # -*- coding: ascii -*- 
 2  # 
 3  # Copyright 2006 - 2012 
 4  # Andr\xe9 Malo or his licensors, as applicable 
 5  # 
 6  # Licensed under the Apache License, Version 2.0 (the "License"); 
 7  # you may not use this file except in compliance with the License. 
 8  # You may obtain a copy of the License at 
 9  # 
10  #     http://www.apache.org/licenses/LICENSE-2.0 
11  # 
12  # Unless required by applicable law or agreed to in writing, software 
13  # distributed under the License is distributed on an "AS IS" BASIS, 
14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15  # See the License for the specific language governing permissions and 
16  # limitations under the License. 
17  """ 
18  ================ 
19   Tool Utilities 
20  ================ 
21   
22  Tool Utilities. 
23  """ 
24  __author__ = u"Andr\xe9 Malo" 
25  __docformat__ = "restructuredtext en" 
26   
27  import encodings as _encodings 
28   
29   
30 -def _make_norm_enc():
31 """ Make encoding normalizer """ 32 isinstance_, unicode_, str_ = isinstance, unicode, str 33 normalize = _encodings.normalize_encoding 34 aliases = _encodings.aliases.aliases.get 35 get_alias = lambda x: aliases(x, x) 36 37 def norm_enc(encoding): # pylint: disable = W0621 38 """ Return normalized unaliased encoding name """ 39 if not isinstance_(encoding, unicode_): 40 encoding = str_(encoding).decode('latin-1') 41 return get_alias(normalize(encoding.lower()))
42 43 return norm_enc 44 45 norm_enc = _make_norm_enc() 46