Ejemplo n.º 1
0
 def __init__(self):
     self.scales = [(_("Hour"),hours(1),MinuteLocator(interval=10)),
                    (_("Half-hour"),minutes(30),MinuteLocator(interval=5)),
                    (_("10-Minute"),minutes(10),MinuteLocator(interval=2)),
                    (_("5-Minute"),minutes(5),MinuteLocator(interval=1)),
                    (_("2-Minute"),minutes(2),SecondLocator(interval=20)),
                    (_("Minute"),minutes(1),SecondLocator(interval=10)),
                    (_("30-Seconds"),minutes(0.5),SecondLocator(interval=5)),
                    (_("12-Seconds"),minutes(0.2),SecondLocator(interval=2))
                    ]
     self.cur = 0
     self.pos = None
Ejemplo n.º 2
0
def time_truncate(dictionary, start_time, end_time):
    """ take a dictionary and reduce it to the desired interval.
    We do this rather than integrate it into time_to_tweets to keep
    time_to_tweets from becoming more complicated; this doesn't add
    any extra time, and requires only slightly more memory. It could be
    abstracted even more and called in time_to_tweets, but this lets us keep
    the logic separate and easier to debug.
    """

    # We need to preprocess times into our desired mdates format.

    zero_time = list(dictionary.keys())[0]
    start_time = start_time.split(':')
    start_time = mdate.hours(float(start_time[0])) + \
        mdate.minutes(float(start_time[1]))
    start_time = start_time + zero_time

    end_time = end_time.split(':')
    end_time = mdate.hours(float(end_time[0])) + \
        mdate.minutes(float(end_time[1]))
    end_time = zero_time + end_time

    # we need a new dictionary. It costs a bit of memory.
    new_dict = OrderedDict({})

    for time in dictionary:
        if time < start_time:
            continue
        elif time > start_time and time < end_time:
            new_dict[time] = dictionary[time]
        elif time > end_time:
            break
        else:
            break

    return new_dict
Ejemplo n.º 3
0
    def test_hours(self):

        self.assertEqual(dates.hours(int(self.hours)),
                         float(self.expectedDays))