Exemplo n.º 1
0
def drop_before_date(source_name, last_date):
    """
    Loads the msgpack file for the given @source_name and drops values
    up to @last_date.

    Used so that we can test logic that updates the msgpack's to download
    current data if the data isn't current enough.
    """
    filename = DATA_SOURCES[source_name]['filename']
    data = loader.get_saved_data(filename)

    filtered_data = itertools.takewhile(
        lambda x: tuple_to_date(x[0]).date() <= last_date.date(), data)

    with loader.get_datafile(filename, mode='wb') as fp:
        fp.write(msgpack.dumps(list(filtered_data)))
Exemplo n.º 2
0
def drop_before_date(source_name, last_date):
    """
    Loads the msgpack file for the given @source_name and drops values
    up to @last_date.

    Used so that we can test logic that updates the msgpack's to download
    current data if the data isn't current enough.
    """
    filename = DATA_SOURCES[source_name]['filename']
    data = loader.get_saved_data(filename)

    filtered_data = itertools.takewhile(
        lambda x: tuple_to_date(x[0]).date() <= last_date.date(), data)

    with loader.get_datafile(filename, mode='wb') as fp:
        fp.write(msgpack.dumps(list(filtered_data)))
Exemplo n.º 3
0
def last_date(source_name, args):
    data = loader.get_saved_data(DATA_SOURCES[source_name]['filename'])
    date = tuple_to_date(data[-1][0])
    print "Last saved {source_name} date is {date}".format(
        source_name=source_name, date=date)
Exemplo n.º 4
0
def last_date(source_name, args):
    data = loader.get_saved_data(DATA_SOURCES[source_name]['filename'])
    date = tuple_to_date(data[-1][0])
    print "Last saved {source_name} date is {date}".format(
        source_name=source_name, date=date)