-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathutil.py
More file actions
39 lines (31 loc) · 870 Bytes
/
util.py
File metadata and controls
39 lines (31 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import logging
# http://code.google.com/p/python-nameparser/issues/detail?id=10
log = logging.getLogger('HumanName')
try:
log.addHandler(logging.NullHandler())
except AttributeError:
class NullHandler(logging.Handler):
def emit(self, record):
pass
log.addHandler(NullHandler())
log.setLevel(logging.ERROR)
import sys
if sys.version_info[0] < 3:
text_type = unicode
binary_type = str
def u(x, encoding=None):
if encoding:
return unicode(x, encoding)
else:
return unicode(x)
else:
text_type = str
binary_type = bytes
def u(x, encoding=None):
return text_type(x)
text_types = (text_type, binary_type)
def lc(value):
"""Lower case and remove any periods to normalize for comparison."""
if not value:
return ''
return value.lower().strip('.')