Code Duplication    Length = 33-33 lines in 2 locations

tabpy/tabpy_server/app/arrow_server.py 1 location

@@ 28-60 (lines=33) @@
25
import pyarrow.csv as csv
26
27
28
def list_flights(args, client, connection_args={}):
29
    print('Flights\n=======')
30
    for flight in client.list_flights():
31
        descriptor = flight.descriptor
32
        if descriptor.descriptor_type == pyarrow.flight.DescriptorType.PATH:
33
            print("Path:", descriptor.path)
34
        elif descriptor.descriptor_type == pyarrow.flight.DescriptorType.CMD:
35
            print("Command:", descriptor.command)
36
        else:
37
            print("Unknown descriptor type")
38
39
        print("Total records:", end=" ")
40
        if flight.total_records >= 0:
41
            print(flight.total_records)
42
        else:
43
            print("Unknown")
44
45
        print("Total bytes:", end=" ")
46
        if flight.total_bytes >= 0:
47
            print(flight.total_bytes)
48
        else:
49
            print("Unknown")
50
51
        print("Number of endpoints:", len(flight.endpoints))
52
        print("Schema:")
53
        print(flight.schema)
54
        print('---')
55
56
    print('\nActions\n=======')
57
    for action in client.list_actions():
58
        print("Type:", action.type)
59
        print("Description:", action.description)
60
        print('---')
61
62
63
def do_action(args, client, connection_args={}):

tabpy/tabpy_server/handlers/arrow_client.py 1 location

@@ 28-60 (lines=33) @@
25
import pyarrow.csv as csv
26
27
28
def list_flights(args, client, connection_args={}):
29
    print('Flights\n=======')
30
    for flight in client.list_flights():
31
        descriptor = flight.descriptor
32
        if descriptor.descriptor_type == pyarrow.flight.DescriptorType.PATH:
33
            print("Path:", descriptor.path)
34
        elif descriptor.descriptor_type == pyarrow.flight.DescriptorType.CMD:
35
            print("Command:", descriptor.command)
36
        else:
37
            print("Unknown descriptor type")
38
39
        print("Total records:", end=" ")
40
        if flight.total_records >= 0:
41
            print(flight.total_records)
42
        else:
43
            print("Unknown")
44
45
        print("Total bytes:", end=" ")
46
        if flight.total_bytes >= 0:
47
            print(flight.total_bytes)
48
        else:
49
            print("Unknown")
50
51
        print("Number of endpoints:", len(flight.endpoints))
52
        print("Schema:")
53
        print(flight.schema)
54
        print('---')
55
56
    print('\nActions\n=======')
57
    for action in client.list_actions():
58
        print("Type:", action.type)
59
        print("Description:", action.description)
60
        print('---')
61
62
63
def do_action(args, client, connection_args={}):