Skip to content

Commit dccd24c

Browse files
committed
remove utf-8 dependency and other unnecessary imports
1 parent 3720ee8 commit dccd24c

3 files changed

Lines changed: 20 additions & 794 deletions

File tree

‎v3/GChartWrapper/GChart.py‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# -*- coding: utf-8 -*-
1+
# (modified by Philip Guo to remove utf-8 dependencies and unnecessary imports)
2+
23
################################################################################
34
# GChartWrapper - v0.8
45
# Copyright (C) 2009 Justin Quick <justquick@gmail.com>
@@ -552,6 +553,8 @@ def url(self):
552553
return self._apiurl + '&'.join(self._parts()).replace(' ','+')
553554

554555

556+
# pgbovine - disable this function
557+
'''
555558
def show(self, *args, **kwargs):
556559
"""
557560
Shows the chart URL in a webbrowser
@@ -560,6 +563,7 @@ def show(self, *args, **kwargs):
560563
"""
561564
from webbrowser import open as webopen
562565
return webopen(str(self), *args, **kwargs)
566+
'''
563567

564568
def save(self, fname=None):
565569
"""
@@ -637,6 +641,8 @@ def write(self, fp):
637641
except StopIteration:
638642
return
639643

644+
# pgbovine - unnecessary
645+
'''
640646
def checksum(self):
641647
"""
642648
Returns the unique SHA1 hexdigest of the chart URL param parts
@@ -645,6 +651,7 @@ def checksum(self):
645651
"""
646652
self.render()
647653
return new_sha(''.join(sorted(self._parts()))).hexdigest()
654+
'''
648655

649656
# Now a whole mess of convenience classes
650657
# *for those of us who dont speak API*
@@ -763,4 +770,4 @@ def __init__(self, btype, *args):
763770
def shadow(self):
764771
image = copy(self)
765772
image.data['chst'] = '%s_shadow'%self['chst']
766-
return image
773+
return image

‎v3/GChartWrapper/constants.py‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# (modified by Philip Guo to remove utf-8 dependencies and unnecessary imports)
12
import sys
23

34
def _print(*args):
@@ -9,17 +10,17 @@ def _print(*args):
910
PY_VER = '3.x'
1011
from urllib.parse import quote_plus,parse_qsl
1112
from urllib.request import Request, urlopen, urlretrieve
12-
from hashlib import sha1
13-
new_sha = lambda s: sha1(bytes(s,'utf-8'))
13+
#from hashlib import sha1
14+
#new_sha = lambda s: sha1(bytes(s,'utf-8'))
1415
else:
1516
PY_VER = '2.x'
1617
from urllib import quote_plus,urlretrieve
1718
from urllib2 import urlopen, Request, URLError, HTTPError
1819
from cgi import parse_qsl
19-
try: # >= 2.5
20-
from hashlib import sha1 as new_sha
21-
except ImportError: # < 2.5
22-
from sha import new as new_sha
20+
#try: # >= 2.5
21+
# from hashlib import sha1 as new_sha
22+
#except ImportError: # < 2.5
23+
# from sha import new as new_sha
2324

2425
def quote(s):
2526
try:
@@ -32,8 +33,9 @@ def smart_str(s):
3233
s = quote(s)
3334
except:
3435
pass
35-
if PY_VER == '2.x':
36-
return unicode(s).encode('utf-8') # Py2K
36+
# pgbovine - never use utf-8
37+
#if PY_VER == '2.x':
38+
# return unicode(s).encode('utf-8') # Py2K
3739
return str(s)#.encode('utf-8') # Py3K
3840

3941
APIPARAMS = ('chxtc', 'chxt', 'chxp', 'chxs', 'chxr', 'chco', 'chtm', 'chld',
@@ -224,4 +226,4 @@ def smart_str(s):
224226
'shoppingcart', 'ski', 'snack', 'snow', 'sport', 'swim', 'taxi', 'train',
225227
'truck', 'wheelchair', 'yen')
226228
BUBBLE_LICONS = ('beer', 'bike', 'car', 'house', 'petrol', 'ski', 'snack')
227-
LEGEND_POSITIONS = ('b','t','r','l','bv','tv')
229+
LEGEND_POSITIONS = ('b','t','r','l','bv','tv')

0 commit comments

Comments
 (0)