示例#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)))
示例#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)))
示例#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)
示例#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)