Update from master

gregdan3/master
Igor Chubin 4 years ago
commit 3ae30af48d

@ -301,8 +301,7 @@ def parse_request(location, request, query, fast_mode=False):
location, override_location_name, full_address, country, query_source_location, hemisphere = \ location, override_location_name, full_address, country, query_source_location, hemisphere = \
location_processing(parsed_query["location"], parsed_query["ip_addr"]) location_processing(parsed_query["location"], parsed_query["ip_addr"])
us_ip = (query_source_location[2] == 'United States' or \ us_ip = query_source_location[2] in ["United States", "United States of America"] \
query_source_location[2] == 'Unites States of America') \
and 'slack' not in parsed_query['user_agent'] and 'slack' not in parsed_query['user_agent']
query = parse_query.metric_or_imperial(query, lang, us_ip=us_ip) query = parse_query.metric_or_imperial(query, lang, us_ip=us_ip)

@ -49,3 +49,4 @@ Braga : Braga, Portugal
Kashan : ~Kashan,Iran Kashan : ~Kashan,Iran
Baku : Baku,Az Baku : Baku,Az
Rome : Rome, Italia Rome : Rome, Italia
YYZ : Toronto Pearson Airport

@ -1,54 +1,54 @@
Instrucciones: Instrucciones:
$ curl wttr.in # el clima en su ubicación actual $ curl wttr.in # El clima en su ubicación actual
$ curl wttr.in/muc # el clima en el aeropuerto de Múnich $ curl wttr.in/muc # El clima en el aeropuerto de Múnich
Tipos de ubicación soportados: Tipos de ubicación soportados:
/paris # el nombre de una ciudad /paris # El nombre de una ciudad
/~Eiffel+tower # el nombre de cualquier sitio famoso /~Eiffel+tower # El nombre de cualquier sitio famoso
/Москва # el nombre Unicode de cualquier sitio en cualquier idioma /Москва # El nombre en Unicode de cualquier sitio en cualquier idioma
/muc # el código de un aeropuerto (3 letras) /muc # El código de un aeropuerto (3 letras)
/@stackoverflow.com # el nombre de un dominio web /@stackoverflow.com # El nombre de un dominio web
/94107 # un código de área /94107 # Un código de area
/-78.46,106.79 # coordenadas de GPS /-78.46,106.79 # Coordenadas de GPS
Sitios especiales: Sitios especiales:
/moon # la fase de la luna (añade ,+US o ,+France para estos países) /moon # La fase de la luna (añade ,+US o ,+France para estos paises)
/moon@2016-10-25 # la fase de la luna en una fecha específica (@2016-10-25) /moon@2016-10-25 # La fase de la luna en una fecha específica (@2016-10-25)
Unidades: Unidades:
?m # métricas (SI) (el estándar en todos los sitios excepto en EEUU) ?m # Métricas (SI) (el estándar en todos los sitios excepto en EEUU)
?u # Sistema Unificado de Clasificación del Suelo o USCS (el estándar en EEUU) ?u # Sistema Unificado de Clasificación del Suelo o USCS (el estándar en EEUU)
?M # mostrar la velocidad del viento en m/s ?M # Mostrar la velocidad del viento en m/s
Opciones de visualización: Opciones de visualización:
?0 # solamente el clima actual ?0 # Solamente el clima actual
?1 # el clima actual + la previsión de 1 día ?1 # El clima actual + la previsión del día siguiente
?2 # el clima actual + la previsión de 2 días ?2 # El clima actual + la previsión de los dos días siguientes
?A # ignora al agente del usuario y fuerza el formato de salida ANSI (terminal) ?A # ignora al agente del usuario y fuerza el formato de salida ANSI (terminal)
?F # no muestra la linea de "Seguir" ?F # No muestra la linea de "Seguir"
?n # versión corta (solo el día y la noche) ?n # Versión corta (solo día y noche)
?q # versión silenciosa (sin el texto de "El tiempo en") ?q # Versión silenciosa (sin el texto de "El tiempo en")
?Q # versión super silenciosa (sin "El tiempo en" ni el nombre de la ciudad) ?Q # Versión supersilenciosa (ni "El tiempo en" ni el nombre de la ciudad)
?T # desactiva las secuencias de terminal (sin colores) ?T # Desactiva las secuencias de terminal (sin colores)
Opciones de PNG: Opciones de PNG:
/paris.png # genera una imagen PNG /paris.png # Genera una imagen PNG
?p # añade un borde alrededor de la imagen ?p # Añade un borde alrededor de la imagen
?t # transparencia 150 ?t # Transparencia = 150
transparency=... # transparencia de 0 a 255 (255 = sin transparencia) transparency=... # Transparencia de 0 a 255 (255 = sin transparencia)
Las opciones se pueden utilizar conjuntamente: Las opciones se pueden utilizar conjuntamente:
/Paris?0pq /Paris?0pq
/Paris?0pq&lang=fr /Paris?0pq&lang=fr
/Paris_0pq.png # en PNG las opciones se especifican después del carácter _ /Paris_0pq.png # En modo PNG las opciones se especifican después del carácter _ (guión bajo)
/Rome_0pq_lang=it.png # una larga secuencia de opciones se puede separar por el carácter _ /Rome_0pq_lang=it.png # Una larga secuencia de opciones se puede separar por el carácter _ (guión bajo)
Ubicación: Ubicación:
@ -63,6 +63,6 @@ Idiomas soportados:
URLs especiales: URLs especiales:
/:help # muestra la página de ayuda /:help # Muestra esta página
/:bash.function # sugiere una función wttr() en bash /:bash.function # Muestra una función wttr() sugerida en bash
/:translation # muestra información acerca de los traductores /:translation # Muestra información acerca de los traductores

@ -16,7 +16,7 @@
263: Llovizna ligera irregular: Patchy light drizzle 263: Llovizna ligera irregular: Patchy light drizzle
266: Llovizna ligera: Light drizzle 266: Llovizna ligera: Light drizzle
281: Llovizna helada: Freezing drizzle 281: Llovizna helada: Freezing drizzle
284: Llovizna fuertemente helada: Heavy freezing drizzle 284: Llovizna muy helada: Heavy freezing drizzle
293: Lluvia ligera irregular: Patchy light rain 293: Lluvia ligera irregular: Patchy light rain
296: Lluvia ligera: Light rain 296: Lluvia ligera: Light rain
299: Lluvia moderada ocasional: Moderate rain at times 299: Lluvia moderada ocasional: Moderate rain at times
@ -27,15 +27,15 @@
314: Lluvia helada moderada o fuerte: Moderate or heavy freezing rain 314: Lluvia helada moderada o fuerte: Moderate or heavy freezing rain
317: Aguanieve ligero: Light sleet 317: Aguanieve ligero: Light sleet
320: Aguanieve moderado o fuerte: Moderate or heavy sleet 320: Aguanieve moderado o fuerte: Moderate or heavy sleet
323: Nevada ligera irregular: Patchy light snow 323: Nieve ligera irregular: Patchy light snow
326: Nevada ligera: Light snow 326: Nieve ligera: Light snow
329: Nevada moderada irregular: Patchy moderate snow 329: Nieve moderada irregular: Patchy moderate snow
332: Nevada moderada: Moderate snow 332: Nieve moderada: Moderate snow
335: Nevada pesada irregular: Patchy heavy snow 335: Nieve pesada irregular: Patchy heavy snow
338: Nevada intensa: Heavy snow 338: Nieve pesada: Heavy snow
350: Granizo: Ice pellets 350: Perdigones de hielo: Ice pellets
353: Aguacero ligero: Light rain shower 353: Aguacero ligero: Light rain shower
356: Aguacero moderada o fuerte: Moderate or heavy rain shower 356: Aguacero moderado o fuerte: Moderate or heavy rain shower
359: Aguacero torrencial: Torrential rain shower 359: Aguacero torrencial: Torrential rain shower
362: Aguacero ligero con aguanieve: Light sleet showers 362: Aguacero ligero con aguanieve: Light sleet showers
365: Aguacero con aguanieve moderado o fuerte: Moderate or heavy sleet showers 365: Aguacero con aguanieve moderado o fuerte: Moderate or heavy sleet showers

@ -548,13 +548,15 @@ func pad(s string, mustLen int) (ret string) {
} }
func formatTemp(c cond) string { func formatTemp(c cond) string {
color := func(temp int, explicit_plus bool) string { color := func(temp int, explicitPlus bool) string {
var col = 0 var col = 0
if !config.Inverse { if !config.Inverse {
col = 21 // Extemely cold temperature must be shown with violet
// because dark blue is too dark
col = 165
switch temp { switch temp {
case -15, -14, -13: case -15, -14, -13:
col = 27 col = 171
case -12, -11, -10: case -12, -11, -10:
col = 33 col = 33
case -9, -8, -7: case -9, -8, -7:
@ -646,11 +648,10 @@ func formatTemp(c cond) string {
if config.Imperial { if config.Imperial {
temp = (temp*18 + 320) / 10 temp = (temp*18 + 320) / 10
} }
if explicit_plus { if explicitPlus {
return fmt.Sprintf("\033[38;5;%03dm+%d\033[0m", col, temp) return fmt.Sprintf("\033[38;5;%03dm+%d\033[0m", col, temp)
} else {
return fmt.Sprintf("\033[38;5;%03dm%d\033[0m", col, temp)
} }
return fmt.Sprintf("\033[38;5;%03dm%d\033[0m", col, temp)
} }
t := c.TempC t := c.TempC
if t == 0 { if t == 0 {
@ -663,17 +664,17 @@ func formatTemp(c cond) string {
// } // }
hyphen = ".." hyphen = ".."
explicit_plus := false explicitPlus := false
if c.FeelsLikeC < t { if c.FeelsLikeC < t {
if c.FeelsLikeC < 0 && t > 0 { if c.FeelsLikeC < 0 && t > 0 {
explicit_plus = true explicitPlus = true
} }
return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicit_plus), unitTemp[config.Imperial]), 15) return pad(fmt.Sprintf("%s%s%s °%s", color(c.FeelsLikeC, false), hyphen, color(t, explicitPlus), unitTemp[config.Imperial]), 15)
} else if c.FeelsLikeC > t { } else if c.FeelsLikeC > t {
if t < 0 && c.FeelsLikeC > 0 { if t < 0 && c.FeelsLikeC > 0 {
explicit_plus = true explicitPlus = true
} }
return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicit_plus), unitTemp[config.Imperial]), 15) return pad(fmt.Sprintf("%s%s%s °%s", color(t, false), hyphen, color(c.FeelsLikeC, explicitPlus), unitTemp[config.Imperial]), 15)
} }
return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15) return pad(fmt.Sprintf("%s °%s", color(c.FeelsLikeC, false), unitTemp[config.Imperial]), 15)
} }
@ -735,8 +736,8 @@ func formatWind(c cond) string {
// } // }
hyphen = "-" hyphen = "-"
cWindGustKmph := fmt.Sprintf("%s", color(c.WindGustKmph)) cWindGustKmph := color(c.WindGustKmph)
cWindspeedKmph := fmt.Sprintf("%s", color(c.WindspeedKmph)) cWindspeedKmph := color(c.WindspeedKmph)
if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) { if windInRightUnits(c.WindGustKmph) > windInRightUnits(c.WindspeedKmph) {
return pad(fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), 15) return pad(fmt.Sprintf("%s %s%s%s %s", windDir[c.Winddir16Point], cWindspeedKmph, hyphen, cWindGustKmph, unitWindString), 15)
} }
@ -770,7 +771,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) {
} }
if config.Inverse { if config.Inverse {
// inverting colors // inverting colors
for i, _ := range icon { for i := range icon {
icon[i] = strings.Replace(icon[i], "38;5;226", "38;5;94", -1) icon[i] = strings.Replace(icon[i], "38;5;226", "38;5;94", -1)
icon[i] = strings.Replace(icon[i], "38;5;250", "38;5;243", -1) icon[i] = strings.Replace(icon[i], "38;5;250", "38;5;243", -1)
icon[i] = strings.Replace(icon[i], "38;5;21", "38;5;18", -1) icon[i] = strings.Replace(icon[i], "38;5;21", "38;5;18", -1)
@ -787,7 +788,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) {
} }
for runewidth.StringWidth(desc) > 15 { for runewidth.StringWidth(desc) > 15 {
_, size := utf8.DecodeLastRuneInString(desc) _, size := utf8.DecodeLastRuneInString(desc)
desc = desc[size:len(desc)] desc = desc[size:]
} }
} else { } else {
for runewidth.StringWidth(desc) < 15 { for runewidth.StringWidth(desc) < 15 {
@ -810,7 +811,7 @@ func formatCond(cur []string, c cond, current bool) (ret []string) {
} else { } else {
if config.RightToLeft { if config.RightToLeft {
if frstRune, size := utf8.DecodeRuneInString(desc); frstRune != ' ' { if frstRune, size := utf8.DecodeRuneInString(desc); frstRune != ' ' {
desc = "…" + desc[size:len(desc)] desc = "…" + desc[size:]
for runewidth.StringWidth(desc) < 15 { for runewidth.StringWidth(desc) < 15 {
desc = " " + desc desc = " " + desc
} }
@ -955,28 +956,26 @@ func printDay(w weather) (ret []string) {
return append(ret, return append(ret,
"└──────────────────────────────┴──────────────────────────────┘") "└──────────────────────────────┴──────────────────────────────┘")
}
names := ""
if config.RightToLeft {
names = "│" + justifyCenter(trans[3], 29) + "│ " + justifyCenter(trans[2], 16) +
"└──────┬──────┘" + justifyCenter(trans[1], 16) + " │" + justifyCenter(trans[0], 29) + "│"
} else { } else {
names = "│" + justifyCenter(trans[0], 29) + "│ " + justifyCenter(trans[1], 16) +
"└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│"
}
names := "" ret = append([]string{
if config.RightToLeft { " ┌─────────────┐ ",
names = "│" + justifyCenter(trans[3], 29) + "│ " + justifyCenter(trans[2], 16) + "┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐",
"└──────┬──────┘" + justifyCenter(trans[1], 16) + " │" + justifyCenter(trans[0], 29) + "│" names,
} else { "├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤"},
names = "│" + justifyCenter(trans[0], 29) + "│ " + justifyCenter(trans[1], 16) + ret...)
"└──────┬──────┘" + justifyCenter(trans[2], 16) + " │" + justifyCenter(trans[3], 29) + "│"
}
ret = append([]string{ return append(ret,
" ┌─────────────┐ ", "└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘")
"┌──────────────────────────────┬───────────────────────" + dateFmt + "───────────────────────┬──────────────────────────────┐",
names,
"├──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤"},
ret...)
return append(ret,
"└──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘")
}
return
} }
func unmarshalLang(body []byte, r *resp) error { func unmarshalLang(body []byte, r *resp) error {
@ -1031,10 +1030,9 @@ func unmarshalLang(body []byte, r *resp) error {
var buf bytes.Buffer var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(rv); err != nil { if err := json.NewEncoder(&buf).Encode(rv); err != nil {
return err return err
} else { }
if err = json.NewDecoder(&buf).Decode(r); err != nil { if err := json.NewDecoder(&buf).Decode(r); err != nil {
return err return err
}
} }
return nil return nil
} }
@ -1084,7 +1082,7 @@ func getDataFromAPI() (ret resp) {
var out bytes.Buffer var out bytes.Buffer
json.Indent(&out, body, "", " ") json.Indent(&out, body, "", " ")
out.WriteTo(os.Stderr) out.WriteTo(os.Stderr)
fmt.Println("\n") fmt.Print("\n\n")
} }
if config.Lang == "" { if config.Lang == "" {

Loading…
Cancel
Save