pad_digits

passengersim.transforms.booking_classes.pad_digits(strings)[source]

Transform strings so that numeric suffixes are padded with zeros.

If every string in the list matches a pattern where it begins with one or more letters, then has one or more digits, then rewrite all the strings in the list so that there are the same number of digits at the end of every string, padding with zeros as needed.

Parameters:
strings : list of str

The list of strings to transform.

Returns:

dict – Mapping the original values to the new values.

Example

>>> pad_digits(['A1', 'B2', 'C33'])
{'A1': 'A01', 'B2': 'B02', 'C33': 'C33'}