# Path: lib/fpos/core.py
# def money(value):
# def lcs(a, b):


import argparse
import csv
from datetime import datetime as dt
from collections import defaultdict, deque
from .core import date_fmt, month_fmt
    o_true = lambda x: True
    oracle = defaultdict(lambda : o_true)
    if None is start and None is end:
        return o_true
    if None is not start:
        oracle["start"] = lambda x: x >= dt.strptime(start, month_fmt)
    if None is not end:
        oracle["end"] = lambda x: x < dt.strptime(end, month_fmt)
    return lambda x: oracle["start"](x) and oracle["end"](x)

def day2month(datestr):
    return dt.strftime(dt.strptime(datestr, date_fmt), month_fmt)

def window(source, start=None, end=None, relspan=None):
    if relspan and not (start or end):
        def _gen_span():
            months = defaultdict(lambda : [])
            for row in source:
                months[day2month(row[0])].append(row)
            dq = deque([], relspan)
            for k in sorted(dt.strptime(dstr, month_fmt)
                    for dstr in months.keys()):
                dq.append(months[dt.strftime(k, month_fmt)])
            for m in dq:
                for e in m:
                    yield e
        return _gen_span()
    in_span = gen_span_oracle(start, end)
    def _gen_se():
        for e in source:

# Path: lib/fpos/core.py
# def money(value):
# def lcs(a, b):


# Path: lib/fpos/window.py
import argparse
import csv
from datetime import datetime as dt
from collections import defaultdict, deque
from .core import date_fmt, month_fmt

    o_true = lambda x: True
    oracle = defaultdict(lambda : o_true)
    if None is start and None is end:
        return o_true
    if None is not start:
        oracle["start"] = lambda x: x >= dt.strptime(start, month_fmt)
    if None is not end:
        oracle["end"] = lambda x: x < dt.strptime(end, month_fmt)
    return lambda x: oracle["start"](x) and oracle["end"](x)

def day2month(datestr):
    return dt.strftime(dt.strptime(datestr, date_fmt), month_fmt)

def window(source, start=None, end=None, relspan=None):
    if relspan and not (start or end):
        def _gen_span():
            months = defaultdict(lambda : [])
            for row in source:
                months[day2month(row[0])].append(row)
            dq = deque([], relspan)
            for k in sorted(dt.strptime(dstr, month_fmt)
                    for dstr in months.keys()):
                dq.append(months[dt.strftime(k, month_fmt)])
            for m in dq:
                for e in m:
                    yield e
        return _gen_span()
    in_span = gen_span_oracle(start, end)
    def _gen_se():
        for e in source:

            if in_span(dt.strptime(e[0], date_fmt)):