in disableDetective.py [0:0]
def read_accounts_csv(input_file: typing.IO) -> typing.Dict:
"""
Parses contents from the CSV file containing the accounts and email addreses.
Args:
input_file: A file object to read CSV data from.
Returns:
A dictionary where the key is account ID and value is email address.
"""
account_re = re.compile(r'[0-9]{12}')
aws_account_dict = {}
if not input_file:
return aws_account_dict
for acct in input_file.readlines():
split_line = acct.strip().split(',')
if len(split_line) != 2:
logging.exception(f'Unable to process line: {acct}.')
continue
account_number, email = split_line
if not account_re.match(account_number):
logging.error(
f'Invalid account number {account_number}, skipping.')
continue
aws_account_dict[account_number.strip()] = email.strip()
return aws_account_dict