Now term_weather uses emojiParser to translate the output of yr to emoji icons

This commit is contained in:
2017-07-29 18:38:47 +02:00
parent e0e7787f71
commit 870f00d65f
2 changed files with 8 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe
# @Date: 2017-07-29 11:56:24
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-07-29 18:26:06
# @Last Modified time: 2017-07-29 18:36:55
from fuzzywuzzy import process
@@ -114,18 +114,18 @@ class EmojiParser(object):
self.findWeatherTokens()
noun_list = self.nouns
print(noun_list)
primary_forcast = noun_list.pop(0)
primary_severity = severity[primary_forcast][self.severity]
secondary_forcast = self.emojifyList(noun_list)
print('%s %s %s' % (self.emojify(primary_forcast), primary_severity, secondary_forcast))
return ('%s %s %s' % (self.emojify(primary_forcast), primary_severity, secondary_forcast))
def convertSematicsToEmoji(self):
self.severityValue()
self.emojifyWeatherForecast()
emojiForcast = self.emojifyWeatherForecast()
return emojiForcast
def main():

View File

@@ -3,7 +3,7 @@
# @Author: KevinMidboe
# @Date: 2017-07-27 21:26:53
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-07-29 12:29:34
# @Last Modified time: 2017-07-29 18:36:36
# TODO LIST
# Get coordinates from IP ✔
@@ -18,6 +18,7 @@ import fire, json, geoip2.database, ssl
from yr.libyr import Yr
from requests import get
from pprint import pprint
from emojiParser import EmojiParser
class Location(object):
@@ -143,6 +144,8 @@ class WeatherForcast(object):
self.symbolVariables(now['symbol'])
emojiParser = EmojiParser(now['symbol']['@name'])
print(emojiParser.convertSematicsToEmoji())
temp = now['temperature']
print(temp['@value'] + ' ' + temp['@unit'] + ' ' + self.symbol_table[self.name])