admin commited on
Commit
9d28e90
·
1 Parent(s): d24adcc

translate notes into english

Browse files
Files changed (1) hide show
  1. vi_backbones.py +11 -9
vi_backbones.py CHANGED
@@ -30,25 +30,27 @@ class vi_backbones(datasets.GeneratorBasedBuilder):
30
  homepage=_HOMEPAGE,
31
  license="mit"
32
  )
33
-
34
  def _get_file_md5(self, url):
35
  """
36
- 通过 URL 计算文件的 MD5
37
 
38
- :param url: 文件 URL 地址
39
- :return: 文件的 MD5
40
  """
41
  try:
42
  response = requests.get(url, stream=True)
43
  if response.status_code == 200:
44
  md5obj = hashlib.md5()
45
- for chunk in response.iter_content(chunk_size=1024*1024): # 分块读取文件流,每次读取1MB数据
46
- md5obj.update(chunk) # 更新哈希值
47
- return md5obj.hexdigest() # 返回MD5值
48
  else:
49
- raise ValueError(f"Error downloading file from {url}. Status code: {response.status_code}")
 
50
  except Exception as e:
51
- raise ValueError(f"Error calculating MD5 of file at {url}: {str(e)}")
 
52
 
53
  def _parse_url(self, url):
54
  response = requests.get(url)
 
30
  homepage=_HOMEPAGE,
31
  license="mit"
32
  )
33
+
34
  def _get_file_md5(self, url):
35
  """
36
+ Calculate the MD5 hash value of a file using its URL
37
 
38
+ :param url: the URL address of the file
39
+ :return: the MD5 hash value in string format
40
  """
41
  try:
42
  response = requests.get(url, stream=True)
43
  if response.status_code == 200:
44
  md5obj = hashlib.md5()
45
+ for chunk in response.iter_content(chunk_size=1024*1024):
46
+ md5obj.update(chunk)
47
+ return md5obj.hexdigest()
48
  else:
49
+ raise ValueError(
50
+ f"Error downloading file from {url}. Status code: {response.status_code}")
51
  except Exception as e:
52
+ raise ValueError(
53
+ f"Error calculating MD5 of file at {url}: {str(e)}")
54
 
55
  def _parse_url(self, url):
56
  response = requests.get(url)