def repl(match):
        '''
        lookup format command and return corresponding replacement.
        '''
        if match.group(0) in STRF_D_MAP:
            return STRF_D_MAP[match.group(0)](tdt, yeardigits)
        elif match.group(0) == '%P':
            ret = []
            if isinstance(tdt, Duration):
                if tdt.years:
                    ret.append('%sY' % abs(tdt.years))
                if tdt.months:
                    ret.append('%sM' % abs(tdt.months))
            usecs = abs((tdt.days * 24 * 60 * 60 + tdt.seconds) * 1000000 +
                        tdt.microseconds)
            seconds, usecs = divmod(usecs, 1000000)
            minutes, seconds = divmod(seconds, 60)
            hours, minutes = divmod(minutes, 60)
            days, hours = divmod(hours, 24)
            if days:
                ret.append('%sD' % days)
            if hours or minutes or seconds or usecs:
                ret.append('T')
                if hours:
                    ret.append('%sH' % hours)
                if minutes:
                    ret.append('%sM' % minutes)
                if seconds or usecs:
                    if usecs:
                        ret.append(("%d.%06d" % (seconds, usecs)).rstrip('0'))
                    else:
                        ret.append("%d" % seconds)
                    ret.append('S')
            # at least one component has to be there.
            return ret and ''.join(ret) or '0D'
        elif match.group(0) == '%p':
            return str(abs(tdt.days // 7)) + 'W'
        return match.group(0)

        lookup format command and return corresponding replacement.
        
Solutions/CyberArkAudit/Data Connectors/.python_packages/lib/site-packages/isodate/isostrf.py