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

Source Code for Module tdi.tools._util

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