Skip to content

Commit a1a958a

Browse files
committed
update for --an
1 parent 5607082 commit a1a958a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.DS_Store

6 KB
Binary file not shown.

main.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import hashlib
77
import sys
88
from datetime import datetime
9+
import argparse
910

1011
from src.a_moins_b import a_moins_b
1112
from src.export_ind import export_ind
@@ -42,7 +43,7 @@
4243
"params": {
4344
**ensa_infos,
4445
"type": "etd",
45-
"id": "*",
46+
"id": "*"
4647
},
4748
},
4849
{
@@ -51,7 +52,7 @@
5152
"params": {
5253
**ensa_infos,
5354
"type": "adm",
54-
"id": "*",
55+
"id": "*"
5556
},
5657
},
5758
{
@@ -60,23 +61,28 @@
6061
"params": {
6162
**ensa_infos,
6263
"type": "esn",
63-
"id": "*",
64+
"id": "*"
6465
},
6566
},
6667
]
6768

6869

69-
async def main(args):
70-
run = ""
71-
if len(args) == 2:
72-
run = args[1]
73-
if run == 'taiga' or run == '':
70+
async def main():
71+
parser = argparse.ArgumentParser()
72+
parser.add_argument('--run', help='all | taiga | sesame',default='all')
73+
parser.add_argument('--an', help='Année universitaire à importer ',default="0")
74+
args = parser.parse_args()
75+
if args.an != 0 :
76+
for col in collections:
77+
col.get('params')['au']=int(args.an)
78+
79+
if args.run == 'taiga' or args.run == 'all':
7480
logger.info("Starting Taiga crawler...")
7581
await a_moins_b(url, 0, -1, headers)
7682
collection_tasks = [col.get('function')(url, col, headers) for col in collections]
7783
await asyncio.gather(*collection_tasks)
7884
print("Taiga crawler ended successful !!!")
79-
if run == 'sesame' or run == '':
85+
if args.run == 'sesame' or args.run == 'all':
8086
print("Starting import_ind...")
8187
start_time = datetime.now()
8288
await import_ind()
@@ -87,6 +93,6 @@ async def main(args):
8793
if __name__ == '__main__':
8894
loop = asyncio.get_event_loop()
8995
try:
90-
loop.run_until_complete(main(sys.argv))
96+
loop.run_until_complete(main())
9197
finally:
9298
loop.close()

0 commit comments

Comments
 (0)