Ejemplo n.º 1
0
def print_csv(connections):
    import sys, csv
    from  mcm.common.connections import fields
    register_mcm_csv_dialect()
    writer = csv.DictWriter(sys.stdout, fieldnames=fields, dialect='mcm')
    for cx in connections.get_all():
        writer.writerow(cx.to_dict())
Ejemplo n.º 2
0
def print_csv(connections):
    import sys, csv
    from mcm.common.connections import fields
    register_mcm_csv_dialect()
    writer = csv.DictWriter(sys.stdout, fieldnames=fields, dialect='mcm')
    for cx in connections.get_all():
        writer.writerow(cx.to_dict())
Ejemplo n.º 3
0
def export_csv(connections, out_file_path=None):
    import csv, tempfile
    from  mcm.common.connections import fields
    
    if not out_file_path:
        out_file_path = tempfile.mkstemp()[1]
    
    register_mcm_csv_dialect()
    with open(out_file_path, 'wb') as ofile:
        writer = csv.DictWriter(ofile, fieldnames=fields, dialect='mcm')
        for cx in connections.get_all():
            writer.writerow(cx.to_dict())
    return out_file_path
Ejemplo n.º 4
0
def export_csv(connections, out_file_path=None):
    import csv, tempfile
    from mcm.common.connections import fields

    if not out_file_path:
        out_file_path = tempfile.mkstemp()[1]

    register_mcm_csv_dialect()
    with open(out_file_path, 'wb') as ofile:
        writer = csv.DictWriter(ofile, fieldnames=fields, dialect='mcm')
        for cx in connections.get_all():
            writer.writerow(cx.to_dict())
    return out_file_path