Exemplo n.º 1
0
    def test_cypher_full(self):
        sio = io.StringIO()
        exporter = CypherGraphExporter(sio, edge_types=edge_types())
        for entity in ENTITIES:
            proxy = model.get_proxy(entity)
            exporter.write(proxy)

        value = sio.getvalue()
        assert 'entity:company' in value, value
        assert 'tel:+12025557612' in value, value
Exemplo n.º 2
0
 def test_csv_export(self):
     exporter = Neo4JCSVExporter(self.outdir,
                                 extra=['source'],
                                 edge_types=edge_types())
     for entity in ENTITIES:
         entity = model.get_proxy(entity)
         exporter.write(entity, extra=['test'])
         fh, writer = exporter.handles[entity.schema]
         outfile = fh.name
     exporter.finalize()
     fh = open(outfile, 'r')
     csv_reader = csv.reader(fh)
     rows = list(csv_reader)
     headers = rows[0]
     assert ':TYPE' in headers, headers
     assert ':START_ID' in headers, headers
     assert ':END_ID' in headers, headers
     assert 'id' in headers, headers
     assert 'date' in headers, headers
     data = rows[1]
     assert 'OWNERSHIP' in data, data
     assert '2003-04-01' in data, data
Exemplo n.º 3
0
 def test_csv_export(self):
     exporter = Neo4JCSVExporter(self.outdir,
                                 extra=["source"],
                                 edge_types=edge_types())
     for entity in ENTITIES:
         entity = model.get_proxy(entity)
         exporter.write(entity, extra=["test"])
         fh, writer = exporter.handles[entity.schema]
         outfile = fh.name
     exporter.finalize()
     fh = open(outfile, "r")
     csv_reader = csv.reader(fh)
     rows = list(csv_reader)
     headers = rows[0]
     assert ":TYPE" in headers, headers
     assert ":START_ID" in headers, headers
     assert ":END_ID" in headers, headers
     assert "id" in headers, headers
     assert "date" in headers, headers
     data = rows[1]
     assert "OWNERSHIP" in data, data
     assert "2003-04-01" in data, data
Exemplo n.º 4
0
@click.option('-o', '--outfile', type=click.File('w'), default='-')  # noqa
@click.option('--qualified/--unqualified',
              is_flag=True,
              default=True,
              help='Generate full predicates')  # noqa
def export_rdf(infile, outfile, qualified=True):
    exporter = RDFExporter(outfile, qualified=qualified)
    export_stream(exporter, infile)


@cli.command('export-gexf', help="Export to GEXF (Gephi) format")
@click.option('-i', '--infile', type=click.File('r'), default='-')  # noqa
@click.option('-o', '--outfile', type=click.File('w'), default='-')  # noqa
@click.option('-e',
              '--edge-types',
              type=click.Choice(edge_types()),
              multiple=True,
              default=DEFAULT_EDGE_TYPES,
              help="Property types to be reified into graph edges.")
def export_gexf(infile, outfile, edge_types):
    exporter = NXGraphExporter(outfile, edge_types=edge_types)
    export_stream(exporter, infile)


@cli.command('export-cypher', help="Export to Cypher script")
@click.option('-i', '--infile', type=click.File('r'), default='-')  # noqa
@click.option('-o', '--outfile', type=click.File('w'), default='-')  # noqa
@click.option('-e',
              '--edge-types',
              type=click.Choice(edge_types()),
              multiple=True,