-
Notifications
You must be signed in to change notification settings - Fork 3
/
isin.py
executable file
·62 lines (50 loc) · 1.6 KB
/
isin.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
"""
ISIN
Copyright (c) 2020-2023 Nicolas Beguier
Licensed under the MIT License
Written by Nicolas BEGUIER ([email protected])
"""
# Standard library imports
from argparse import ArgumentParser
import sys
# Own library
from lib import common, display, reporting
# Debug
# from pdb import set_trace as st
VERSION = '3.0.0'
def main(parameters):
"""
Main function
"""
report = reporting.get_report(parameters)
display.print_report(
report,
header=parameters['header'])
if __name__ == '__main__':
PARSER = ArgumentParser()
PARSER.add_argument('--version', action='version', version=VERSION)
PARSER.add_argument('-i', '--isin', action='store',\
help="Code ISIN")
PARSER.add_argument('-n', '--nom', action='store',\
help="Nom de l'action")
PARSER.add_argument('-m', '--market-id-code', action='store',\
help="Code d'identification de marché (=XPAR)", default='XPAR')
PARSER.add_argument('--no-header', action='store_true',\
help="Cache les informations de bases (=False)", default=False)
ARGS = PARSER.parse_args()
PARAMS = {}
PARAMS['isin'] = ARGS.isin
PARAMS['mic'] = ARGS.market_id_code
PARAMS['header'] = not ARGS.no_header
if not ARGS.isin and not ARGS.nom:
PARSER.print_help()
sys.exit(1)
elif ARGS.nom is not None:
RESULT = common.autocomplete(ARGS.nom)
if not RESULT or 'ISIN' not in RESULT[0]:
print('No result for this name')
sys.exit(1)
else:
PARAMS['isin'] = RESULT[0]['ISIN']
main(PARAMS)