Пример #1
0
def test_writer_zero_entries():
    out = io.StringIO()
    writer = Writer(out, fieldnames=[])
    writer.close()

    string = out.getvalue()
    assert string == "\n"
Пример #2
0
def test_writer_zero_entries_titles():
    out = io.StringIO()
    writer = Writer(out, fieldnames=['one', 'two', 'three'])
    writer.close()

    string = out.getvalue()
    assert string == 'one\ttwo\tthree\n'
Пример #3
0
def test_writer_one_entry():
    out = io.StringIO()
    writer = Writer(out, fieldnames=["name"])
    entry = Entry(name="one")
    writer.write(entry)
    writer.close()

    string = out.getvalue()
    assert string == 'name\none\n'
Пример #4
0
def test_writer_many_entries():
    out = io.StringIO()
    writer = Writer(out, fieldnames=["name", "text"])
    for name in ['one', 'two', 'three']:
        entry = Entry(name=name, text="hello world")
        writer.write(entry)
    writer.close()

    string = out.getvalue()
    assert string == (
        'name\ttext\n'
        'one\thello world\n'
        'two\thello world\n'
        'three\thello world\n')
Пример #5
0
def init_output():
    fieldnames = [
        'government-organisation',
        'name',
        'website',
        'government-organisation-type',
        'parent-bodies',
        'text',
        'crest',
        'official-colour',
        'abbreviation',
    ]
    writer = Writer(sys.stdout, fieldnames=fieldnames)

    return writer
Пример #6
0
#!/usr/bin/env python3

import sys
import json
from entry import Entry
from entry.representations.tsv import Writer

writer = Writer(sys.stdout, fieldnames=[
    'id',
    'name',
    'latitude',
    'longitude',
    'streetAddress',
    'addressLocality',
    'addressRegion',
    'postalCode',
    'AddressCountry',
    'facility',
    'type'])

# 'longitude',
# 'image_file',
# 'postalAddress_streetAddress',
# 'postalAddress_postTown',
# 'postalAddress_county',
# 'postalAddress_postalCode',
# 'postalAddress_country',
# 'visitingAddress_streetAddress',
# 'visitingAddress_',
# 'visitingAddress_county',
# 'visitingAddress_postalCode',