mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-04-30 09:54:43 +00:00
Unicode fix in setup.py
This commit is contained in:
parent
de18c95a61
commit
710284eac4
1 changed files with 9 additions and 7 deletions
16
setup.py
16
setup.py
|
|
@ -120,20 +120,23 @@ def minify(files, outfile, ftype):
|
|||
for filename in files:
|
||||
with open(getPkgPath() + filename) as f:
|
||||
for line in f.xreadlines():
|
||||
if isinstance(line, str):
|
||||
line = line.decode('utf-8')
|
||||
content = content + line
|
||||
|
||||
data = urllib.urlencode([
|
||||
('code', content),
|
||||
('code', content.encode('utf-8')),
|
||||
('type', ftype),
|
||||
])
|
||||
data.encode('utf-8')
|
||||
|
||||
f = urllib.urlopen('http://api.applegrew.com/minify', data)
|
||||
data = u''
|
||||
while 1:
|
||||
line = f.readline()
|
||||
if line:
|
||||
data = data + unicode(line)
|
||||
if isinstance(line, str):
|
||||
line = line.decode('utf-8')
|
||||
data = data + line
|
||||
else:
|
||||
break
|
||||
f.close()
|
||||
|
|
@ -141,18 +144,17 @@ def minify(files, outfile, ftype):
|
|||
data = json.loads(data)
|
||||
for key in data:
|
||||
value = data[key]
|
||||
if isinstance(value, str) or isinstance(value, unicode):
|
||||
data[key] = unicode(value).replace(r'\/', '/') #.decode("unicode_escape").replace(r'\/', '/')
|
||||
if isinstance(value, str):
|
||||
value = value.decode('utf-8')
|
||||
|
||||
if data['success']:
|
||||
with open(getPkgPath() + outfile, 'w') as f:
|
||||
f.write(data['compiled_code'])
|
||||
f.write(data['compiled_code'].encode('utf8'))
|
||||
else:
|
||||
print data['error_code']
|
||||
print data['error']
|
||||
raise Exception('Could not minify.')
|
||||
|
||||
|
||||
if len(sys.argv) > 1 and 'sdist' == sys.argv[1]:
|
||||
minify(['static/js/select2.js'], 'static/js/select2.min.js', 'js')
|
||||
minify(['static/js/heavy_data.js'], 'static/js/heavy_data.min.js', 'js')
|
||||
|
|
|
|||
Loading…
Reference in a new issue