@@ -605,17 +605,34 @@ def remove_dots(txt):
605
605
if '..' not in txt :
606
606
return txt
607
607
else :
608
- txt = re .sub (r'\.\. ' , '. ' , txt )
608
+ txt = re .sub (r'\.+ ' , ' ' , txt )
609
609
return remove_dots (txt )
610
610
611
+
612
+ def remove_spaces (x ):
613
+ if ' ' in x :
614
+ x = x .replace (' ' , ' ' )
615
+ return remove_spaces (x )
616
+ else :
617
+ return x
618
+
619
+
611
620
def chomp_desc (txt ):
612
621
out = txt
613
622
#print "original:", out
623
+ p = re .compile (r'(?<=[\.\?!]\s)(\w+)' )
624
+
614
625
def upper_repl (match ):
615
626
return match .group (1 ).upper ()
627
+
628
+ def cap (match ):
629
+ return match .group ().capitalize ()
630
+
616
631
out = re .sub ('([Tt])hunder(storm|shower)' , r'\1\2' , out )
617
632
out = re .sub ('with' , 'w/' , out )
618
633
out = re .sub ('and' , '&' , out )
634
+ out = re .sub ('during' , 'in' , out )
635
+ out = re .sub ('becoming' , '' , out )
619
636
out = re .sub ('occasionally' , 'occ' , out )
620
637
out = re .sub ('occasional' , 'occ' , out )
621
638
out = re .sub ('especially' , 'esp.' , out )
@@ -627,8 +644,16 @@ def upper_repl(match):
627
644
out = re .sub ('afternoon' , 'PM' , out )
628
645
out = re .sub ('in the' , 'in' , out )
629
646
#out = re.sub(r'\.\.', ' ', out)
630
- out = remove_dots (out )
631
647
out = re .sub ('Then the (\S)' , upper_repl , out )
648
+ out = re .sub (r'(?i)(\b)(?:the|a)(\b)' , r'\1\2' , out )
649
+ #out = re.sub(cap, '', out)
650
+
651
+ out = remove_dots (out )
652
+ out = remove_spaces (out )
653
+
654
+ out = p .sub (cap , out )
655
+
656
+ out = out .strip ()
632
657
return out
633
658
634
659
@@ -703,7 +728,12 @@ def forecast(jenni, input):
703
728
windspeedC = form % (float (day ['windSpeed' ]) * 1.609344 )
704
729
windspeed = form % (day ['windSpeed' ])
705
730
summary = day ['summary' ]
706
- dotw_day = datetime .datetime .fromtimestamp (int (day ['sunriseTime' ])).weekday ()
731
+ #print("day:", str(day))
732
+ day_ts = day ['time' ]
733
+ if "sunriseTime" in day :
734
+ day_ts = int (day ['sunriseTime' ])
735
+
736
+ dotw_day = datetime .datetime .fromtimestamp (day_ts ).weekday ()
707
737
dotw_day_pretty = u'\x03 10\x02 \x1F %s\x1F \x02 \x03 ' % (dotw [dotw_day ])
708
738
709
739
line = u'%s: \x02 \x03 04%sF (%sC)\x03 \x02 / \x02 \x03 12%sF (%sC)\x03 \x02 , \x1F Dew\x1F : %sF (%sC), \x1F Wind\x1F : %smph (%skmh), %s | '
@@ -760,6 +790,7 @@ def forecast(jenni, input):
760
790
jenni .say (second_output )
761
791
forecast .commands = ['forecast' , 'fct' , 'fc' ]
762
792
forecast .rate = 5
793
+ forecast .priority = 'low'
763
794
764
795
765
796
def forecastio_current_weather (jenni , input ):
@@ -871,6 +902,7 @@ def forecastio_current_weather(jenni, input):
871
902
jenni .say (output )
872
903
forecastio_current_weather .commands = ['wxi-ft' , 'wx-ft' , 'weather-ft' , 'weather' , 'wx' ]
873
904
forecastio_current_weather .rate = 5
905
+ forecastio_current_weather .priority = 'high'
874
906
875
907
876
908
def make_rh_C (temp , dewpoint ):
@@ -988,6 +1020,7 @@ def weather_wunderground(jenni, input):
988
1020
989
1021
weather_wunderground .commands = ['wx-wg' , 'weather-wg' ]
990
1022
weather_wunderground .rate = 10
1023
+ weather_wunderground .priority = 'high'
991
1024
992
1025
993
1026
def preface_location (ci , reg = '' , cty = '' ):
@@ -1075,7 +1108,7 @@ def forecast_wg(jenni, input):
1075
1108
if not days_text [k + 1 ].endswith ('.' ):
1076
1109
days_text1_temp += '.'
1077
1110
1078
- temp = '\x02 \x03 10%s\x03 \x02 : %s / %s, \x1F Cond \x1F : %s Eve : %s | ' % (day_of_week , highs , lows , days_text_temp , days_text1_temp )
1111
+ temp = '\x02 \x03 10%s\x03 \x02 : %s / %s, AM : %s PM : %s | ' % (day_of_week , highs , lows , days_text_temp , days_text1_temp )
1079
1112
1080
1113
k += 2
1081
1114
if (k / 2. ) <= 2 :
@@ -1090,9 +1123,16 @@ def forecast_wg(jenni, input):
1090
1123
jenni .say (output_second )
1091
1124
1092
1125
forecast_wg .commands = ['forecast-wg' ]
1126
+ forecast_wg .priority = 'low'
1093
1127
forecast_wg .rate = 5
1094
1128
1095
1129
1130
+ def radar_us (jenni , input ):
1131
+ return jenni .say ('https://radar.weather.gov/Conus/Loop/NatLoop.gif' )
1132
+ radar_us .commands = ['radar_us' ,]
1133
+ radar_us .priority = 'low'
1134
+
1135
+
1096
1136
1097
1137
if __name__ == '__main__' :
1098
1138
print __doc__ .strip ()
0 commit comments