@@ -73,29 +73,29 @@ def __init__(self, root, split='train', download=None, **kwargs):
73
73
for cls in clss }
74
74
75
75
def extract_archives (self ):
76
- def check_archive (archive_dict ):
77
- file = archive_dict ["file" ]
78
- md5 = archive_dict ["md5" ]
79
- archive = os .path .join (self .root , file )
80
- if not check_integrity (archive , md5 ):
81
- msg = ("The file {} is not present in the root directory. You need to "
82
- "download it externally and place it in {}." )
83
- raise RuntimeError (msg .format (file , self .root ))
84
-
85
- return archive
86
-
87
76
if not check_integrity (self .meta_file ):
88
- archive = check_archive (ARCHIVE_DICT ['devkit' ])
77
+ archive_dict = ARCHIVE_DICT ['devkit' ]
78
+ archive = os .path .join (self .root , archive_dict ["file" ])
79
+ self ._verify_archive (archive , archive_dict ["md5" ])
80
+
89
81
parse_devkit_archive (archive )
90
82
91
83
if not os .path .isdir (self .split_folder ):
92
- archive = check_archive (ARCHIVE_DICT [self .split ])
84
+ archive_dict = ARCHIVE_DICT [self .split ]
85
+ archive = os .path .join (self .root , archive_dict ["file" ])
86
+ self ._verify_archive (archive , archive_dict ["md5" ])
93
87
94
88
if self .split == 'train' :
95
89
parse_train_archive (archive )
96
90
elif self .split == 'val' :
97
91
parse_val_archive (archive )
98
92
93
+ def _verify_archive (self , archive , md5 ):
94
+ if not check_integrity (archive , md5 ):
95
+ msg = ("The file {} is not present in the root directory or corrupted. "
96
+ "You need to download it externally and place it in {}." )
97
+ raise RuntimeError (msg .format (os .path .basename (archive ), self .root ))
98
+
99
99
@property
100
100
def meta_file (self ):
101
101
return os .path .join (self .root , META_FILE_NAME )
0 commit comments