<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def strptime(cls, value, format):
 """ Parse a datetime string using the provided format. This also emulates `%z` support on Python 2. :param value: Datetime string :type value: str :param format: Format to use for parsing :type format: str :rtype: datetime :raises ValueError: Invalid format :raises TypeError: Invalid input type """

        # Simplest case: direct parsing
        if cls.python_supports_z or '%z' not in format:
            return datetime.strptime(value, format)
        else:
            # %z emulation case
            assert format[-2:] == '%z', 'For performance, %z is only supported at the end of the string'

            # Parse
            dt = datetime.strptime(value[:-5], format[:-2])  # cutoff '%z' and '+0000'
            tz = FixedOffset(value[-5:])  # parse %z into tzinfo

            # Localize
            return dt.replace(tzinfo=tz)