~davidc3/ubuntu-rest-scopes/testing-newyorktimes

« back to all changes in this revision

Viewing changes to src/scopes/weatherchannel.py

  • Committer: David Callé
  • Date: 2014-02-16 00:27:18 UTC
  • mfrom: (3.1.27 ubuntu-rest-scopes)
  • Revision ID: davidc@framli.eu-20140216002718-9j3bcst2k28bp1qq
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
343
343
        # fake a result, with same data than the first ('today') one, but
344
344
        # with no title and the TWC logo, and put it at the left end
345
345
        logo_result = results[0].copy()
346
 
        logo_result['icon'] = '%s/weatherchannel/logo.svg' % \
 
346
        logo_result['art'] = '%s/weatherchannel/logo.svg' % \
347
347
            (self.base_image_url,)
348
348
        logo_result['title'] = ''
349
349
        logo_result['uri'] = logo_result['uri'] + "#logo"
362
362
                (result['day'], result['conditions'], result['current_temp'])
363
363
 
364
364
        subtitle = "%s   %s" % (result['location'], result['date'])
365
 
        max_temp = "%s: %s" % ("max: ", result['max_temp'])
366
 
        min_temp = "%s: %s" % ("min: ", result['min_temp'])
 
365
 
 
366
        # yield an 'image' widget
 
367
        yield dict(widget={
 
368
            'id': 'art',
 
369
            'type': 'image',
 
370
            'source': result['art'],
 
371
        })
 
372
 
367
373
        # yield a 'header' widget
368
 
        yield {
 
374
        yield dict(widget={
369
375
            'id': 'header1',
370
376
            'type': 'header',
371
377
            'uri': result['uri'],
372
378
            'title': title,
373
 
            'mascot': result['art'],
374
379
            'subtitle': subtitle,
375
 
            'attribute-1': max_temp,
376
 
            'attribute-2': min_temp,
 
380
            'attribute-1': None,
 
381
            'attribute-2': None,
377
382
            'attribute-3': None,
378
 
            'emblem': None,
379
 
        }
 
383
            'emblem': result['preview_icon'],
 
384
        })
380
385
 
381
 
        # TODO: how to include these in the preview?
382
 
        #info1 = ("max_temp", "Maximum temperature", result['max_temp'])
383
 
        #info2 = ("min_temp", "Minimum temperature", result['min_temp'])
384
 
        #info3 = ("rain", "Chances of rain", result['pop'])
385
 
        #info4 = ("wind", "Wind", result['wind_sentence'])
386
 
        #info5 = ("humidity", "Humidity", result['humidity'])
387
 
        #info6 = ("uv", "UV index", result['uv'])
 
386
        max_temp = ("Maximum temperature", result['max_temp'])
 
387
        min_temp = ("Minimum temperature", result['min_temp'])
 
388
        rain = ("Chances of rain", result['pop'])
 
389
        wind = ("Wind", result['wind_sentence'])
 
390
        humm = ("Humidity", result['humidity'])
 
391
        uv = ("UV index", result['uv'])
 
392
        # send it as a 'text' widget
 
393
        infos = [min_temp, max_temp, rain, wind, humm, uv]
 
394
        text = '\n'.join('%s: %s' % (desc, value) for (desc, value) in infos)
 
395
        yield dict(widget={
 
396
            'id': 'text1',
 
397
            'type': 'text',
 
398
            'title': None,
 
399
            'text': text
 
400
        })
388
401
        loc_key = result['loc_key']
389
402
        locale = result['locale']
390
403
        formfactor = result['formfactor']
402
415
            actions.append({"id": "action2", "icon": logo_icon,
403
416
                            "label": "Hourly", 'uri': uri})
404
417
 
405
 
        yield {
 
418
        yield dict(widget={
406
419
            "id": "actions",
407
420
            "type": "actions",
408
421
            "actions": actions,
409
 
        }
 
422
        })