/+junk/pygooglechart-py3k

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/pygooglechart-py3k

« back to all changes in this revision

Viewing changes to pygooglechart.py

  • Committer: Gerald Kaszuba
  • Date: 2010-12-24 05:58:10 UTC
  • Revision ID: git-v1:f05d4ae7e0dc2851ee6893405e303fcc8d7c7a2b
Link to examples in README

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
    of the chart. legend requires a list that corresponds to datasets.
285
285
    """
286
286
 
287
 
    BASE_URL = 'http://chart.apis.google.com/chart?'
 
287
    BASE_URL = 'http://chart.apis.google.com/chart'
288
288
    BACKGROUND = 'bg'
289
289
    CHART = 'c'
290
290
    ALPHA = 'a'
337
337
 
338
338
    # URL generation
339
339
    # -------------------------------------------------------------------------
340
 
 
 
340
        
341
341
    def get_url(self, data_class=None):
 
342
        return self.BASE_URL + '?' + self.get_url_extension(data_class)
 
343
    
 
344
    def get_url_extension(self, data_class=None):
342
345
        url_bits = self.get_url_bits(data_class=data_class)
343
 
        return self.BASE_URL + '&'.join(url_bits)
 
346
        return '&'.join(url_bits)
344
347
 
345
348
    def get_url_bits(self, data_class=None):
346
349
        url_bits = []
386
389
    # Downloading
387
390
    # -------------------------------------------------------------------------
388
391
 
389
 
    def download(self, file_name):
390
 
        opener = urllib2.urlopen(self.get_url())
 
392
    def download(self, file_name, use_post=True):
 
393
        if use_post:
 
394
            opener = urllib2.urlopen(self.BASE_URL, self.get_url_extension())
 
395
        else:
 
396
            opener = urllib2.urlopen(self.get_url())
391
397
 
392
398
        if opener.headers['content-type'] != 'image/png':
393
399
            raise BadContentTypeException('Server responded with a ' \