def get_credentials(output: str, count=0):
    number = re.findall(r'400000\d{10}', output, re.MULTILINE)
    if not number:
        raise WrongAnswerException('You are printing the card number incorrectly. '
                                   'The card number should look like in the example: 400000DDDDDDDDDD, where D is a digit.')

    PIN = re.findall(r'^\d{4}$', output, re.MULTILINE)
    if not PIN:
        raise WrongAnswerException('You are printing the card PIN incorrectly. '
                                   'The PIN should look like in the example: DDDD, where D is a digit.')
    if count == 2:
        return (number[0], PIN[0]), (number[1], PIN[1])
    else:
        return number[0], PIN[0]
示例#2
0
def get_credentials(output: str, count=0):
    number = re.findall(r'400000\d{10}', output, re.MULTILINE)
    if not number:
        raise WrongAnswerException('You are printing the card number incorrectly. '
                                   'The card number should look like in the example: 400000DDDDDDDDDD,'
                                   ' where D is a digit.\nMake sure the card number is 16-digit length and '
                                   'you don\'t print any extra spaces at the end of the line!')

    PIN = re.findall(r'^\d{4}$', output, re.MULTILINE)
    if not PIN:
        raise WrongAnswerException('You are printing the card PIN incorrectly. '
                                   'The PIN should look like in the example: DDDD, where D is a digit.\n'
                                   'Make sure the PIN is 4-digit length and you don\'t print any extra spaces at the'
                                   ' end of the line!')
    if count == 2:
        return (number[0], PIN[0]), (number[1], PIN[1])
    else:
        return number[0], PIN[0]