Exemple #1
0
def parse_transactions(data_source: Iterable[list]):
    return map(lambda record: Transaction(*record), dsv_reader(data_source))
Exemple #2
0
def hacker_reader(data_source: Iterable[str],
                  filter_method: [None, Callable[[Hacker], bool]] = None):
    return filter(filter_method,
                  map(lambda d: hacker_init(*d), dsv_reader(data_source)))
Exemple #3
0
from dsv import dsv_reader, dsv_generator
from sys import stdout, stderr, stdin
r = dsv_reader(stdin, delimiter=',')
c = list(r)[1:]
source_fields = 'name,last_name,nick,email,cad_id,has_hs_keys,has_gate_keys,groups,membership_declaration,entry_date'.split(
    ',')
pm = []
for h in c:
    ph = []
    group_vals = False
    for v in h:
        if group_vals:
            if v.endswith('"'):
                group_vals = False
            ph[-1].append(v[:-1])
        elif v.startswith('"'):
            group_vals = True
            ph.append([
                v[1:],
            ])
        else:
            ph.append(v)
    pm.append(ph)
from data_structures import Hacker
pm = filter(
    lambda m: m[source_fields.index('membership_declaration')].strip() !=
    'nie', pm)
hackers = []
for m in pm:
    kwargs = dict()
    for f in Hacker.fields:
Exemple #4
0
def classificator_main(input_file, output_file):
    transactions = map(lambda record: Transaction(*record),
                       dsv_reader(input_file))
    monthly_report = generate_monthly_report(transactions)

    output_file.writelines(monthly_report_as_dsv(monthly_report))
Exemple #5
0
def event_reader(event_source: Iterable[str]) -> Iterable[Event]:
    for event_data in filter(is_line_not_empty, dsv_reader(event_source)):
        try:
            yield Event(*event_data)
        except Exception as e:
            raise EventReaderException(f"failed to read event line: {event_data}:\n{e}")