11"""A hermes harvest plugin that harvests the .toml file of the project"""
22
3- import os
4- import pathlib
5- import toml
6-
73from contextlib import chdir
84from email .utils import getaddresses
5+
6+ import pathlib
7+ import toml
98from pydantic import BaseModel
109
1110from hermes .commands .harvest .base import HermesHarvestCommand , HermesHarvestPlugin
@@ -180,8 +179,8 @@ def handle_person_in_unknown_format(cls, persons):
180179 try :
181180 [(name , email )] = getaddresses ([person ])
182181 return cls .remove_forbidden_keys ({"name" :name , "email" :email })
183- except ValueError :
184- raise ValueError ("Wrong string format for name (and email)." )
182+ except ValueError as exc :
183+ raise ValueError ("Wrong string format for name (and email)." ) from exc
185184
186185 else :
187186 #if the person isn't a dictionary raise an Error
@@ -197,13 +196,13 @@ def handle_person_in_unknown_format(cls, persons):
197196 #the 'person' may be an empty dictionary if all keys are incorrect
198197 return cls .remove_forbidden_keys (persons )
199198
200- elif isinstance (persons , str ):
199+ if isinstance (persons , str ):
201200 #try to parse the string
202201 try :
203202 [(name , email )] = getaddresses ([persons ])
204203 return cls .remove_forbidden_keys ({"name" :name , "email" :email })
205- except ValueError :
206- raise ValueError ("Wrong string format for name (and email)." )
204+ except ValueError as exc :
205+ raise ValueError ("Wrong string format for name (and email)." ) from exc
207206
208207 #raise an error if the persons data is not in the right format
209208 raise ValueError ("A person must be a dict or special string." )
0 commit comments