@@ -399,10 +399,11 @@ def download(
399
399
return False
400
400
corpus_versions = corpus ["versions" ][version ]
401
401
file_name = corpus_versions ["filename" ]
402
- found = ''
402
+ found = ""
403
403
for i , item in local_db ["_default" ].items ():
404
- if item ["name" ] == name and item ["version" ] == version :
405
- # Record corpus no. if found
404
+ # Do not check version here
405
+ if item ["name" ] == name :
406
+ # Record corpus no. if found in local database
406
407
found = i
407
408
break
408
409
@@ -445,7 +446,9 @@ def download(
445
446
# This awkward behavior is for backward-compatibility with
446
447
# database files generated previously using TinyDB
447
448
if local_db ["_default" ]:
448
- corpus_no = max ((int (no ) for no in local_db ["_default" ])) + 1
449
+ corpus_no = max ((
450
+ int (no ) for no in local_db ["_default" ]
451
+ )) + 1
449
452
else :
450
453
corpus_no = 1
451
454
local_db ["_default" ][str (corpus_no )] = {
@@ -458,8 +461,10 @@ def download(
458
461
459
462
with open (corpus_db_path (), "w" , encoding = "utf-8" ) as f :
460
463
json .dump (local_db , f , ensure_ascii = False )
464
+ # Check if versions match if the corpus is found in local database
465
+ # but a re-download is not forced
461
466
else :
462
- current_ver = local_db [' _default' ][found ]["version" ]
467
+ current_ver = local_db [" _default" ][found ]["version" ]
463
468
464
469
if current_ver == version :
465
470
# Already has the same version
@@ -519,8 +524,8 @@ def remove(name: str) -> bool:
519
524
os .remove (path )
520
525
for i , corpus in db ["_default" ].copy ().items ():
521
526
if corpus ["name" ] == name :
522
- del db [' _default' ][i ]
523
- with open (corpus_db_path (), 'w' , encoding = ' utf-8' ) as f :
527
+ del db [" _default" ][i ]
528
+ with open (corpus_db_path (), "w" , encoding = " utf-8" ) as f :
524
529
json .dump (db , f , ensure_ascii = False )
525
530
return True
526
531
0 commit comments