Exemplo n.º 1
0
def sunrise_line(hourly_wdb, sun_wdb, COLORS, col_width, head):
    import printers.colorfuncs as cf
    temp = "{:>{wid}}: ".format("Sunrise/set", wid=head)
    for hour in hourly_wdb:
        temp = ("{}{}{:>{wid}}{}".format(temp,
                cf.sunrise_sunset_color(hour['FCTTIME']['hour'],
                                        (sun_wdb['sunrise']['hour'],
                                        sun_wdb['sunrise']['minute']),
                                        (sun_wdb['sunset']['hour'],
                                        sun_wdb['sunset']['minute']),
                                        COLORS),
                sunrise_sunset_time(hour['FCTTIME']['hour'],
                                    (sun_wdb['sunrise']['hour'],
                                    sun_wdb['sunrise']['minute']),
                                    (sun_wdb['sunset']['hour'],
                                    sun_wdb['sunset']['minute'])),
                COLORS.clear, wid=col_width))
    return temp
Exemplo n.º 2
0
def format_bar_hour(weat_hour, COLOR, zero_hour, sunrise, sunset, sun_func,
                    time_func):
    """ return a vertical set of strings, one hour of info
    """
    res = []
    for r in [(('temp', 'english'), cf.bar_temp_color),
              (('sky', ), cf.bar_cloud_color),
              (('pop', ), cf.bar_precip_color),
              (('wspd', 'english'), cf.bar_wind_color)]:
        target = utils.utilities.eat_keys(weat_hour, r[0])
        currs = utils.utilities.eat_keys(zero_hour, r[0])
        res.append(format_bar(r[1], int(target), int(currs), COLOR, width=6))
    # TODO: if sunrise_sunset_color can get wrangled into the standard
    # color_func api, we can move this to a format_bar call:
    res.append("{}{:^6}{}".format(
        cf.sunrise_sunset_color(weat_hour['FCTTIME']['hour'],
                                sunrise, sunset, COLOR),
        sun_func(weat_hour['FCTTIME']['hour'], sunrise, sunset),
        COLOR.clear))
    #  res.append("{:^6}".format("{}:{}".format(weat_hour['FCTTIME']['hour'],
                                             #  weat_hour['FCTTIME']['min'])))
    res.append(next(time_func))
    return res