forked from aio-libs-abandoned/aioes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmp.py
38 lines (31 loc) · 1.25 KB
/
cmp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Compare tool.
Calculate difference between public API from `elasticsearch` and `aioes`.
"""
import elasticsearch
from elasticsearch.client.utils import NamespacedClient
import aioes
endpoint = 'localhost:9200'
es_client = elasticsearch.Elasticsearch([endpoint])
aioes_client = aioes.Elasticsearch([endpoint])
version = es_client.info()['version']
print('-'*70)
print('ElasticSearch (server): {}'.format(version['number']))
print('elasticsearch-py: {}'.format(elasticsearch.__version__))
es_set = {i for i in dir(es_client) if not i.startswith('_')}
aioes_set = {i for i in dir(aioes_client) if not i.startswith('_')}
print('-'*70)
print('Missing: ', ' '.join(sorted(es_set - aioes_set)))
print('Extra: ', ' '.join(sorted(aioes_set - es_set)))
for sub in dir(es_client):
if sub.startswith('_'):
continue
val = getattr(es_client, sub)
if isinstance(val, NamespacedClient):
left = {i for i in dir(val) if not i.startswith('_')}
val2 = getattr(aioes_client, sub, None)
if val2 is None:
continue
right = {i for i in dir(val2) if not i.startswith('_')}
print(' '*6, sub)
print(' '*10, 'Missing: ', ' '.join(sorted(left - right)))
print(' '*10, 'Extra: ', ' '.join(sorted(right - left)))