-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCommon.py
More file actions
44 lines (41 loc) · 900 Bytes
/
Common.py
File metadata and controls
44 lines (41 loc) · 900 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
40
41
42
43
44
import os
def returnResourcePath(resource):
MEIPASS2 = '_MEIPASS2'
if MEIPASS2 in os.environ:
return os.environ[MEIPASS2] + resource
else:
return resource
# WindPower's magical unicode method
def u(s):
if type(s) is type(u''):
return s
if type(s) is type(''):
try:
return unicode(s)
except:
try:
return unicode(s.decode('utf8'))
except:
try:
return unicode(s.decode('windows-1252'))
except:
return unicode(s, errors='ignore')
try:
return unicode(s)
except:
try:
return u(str(s))
except:
return s
class curry(object):
def __init__(self, func, *args, **kwargs):
self._func = func
self._pending = args[:]
self._kwargs = kwargs
def __call__(self, *args, **kwargs):
if kwargs and self._kwargs:
kw = self._kwargs.copy()
kw.update(kwargs)
else:
kw = kwargs or self._kwargs
return self._func(*(self._pending + args), **kw)