U  W[! @stdZddlmZmZddlZddlmZddlmZm Z ddZ dd Z d d Z e e e e e e d d Z dS)zD Utilities to assist in the "flag day" new-style object transition. )absolute_importdivisionN)wraps)_shouldEnableNewStyle_PY3csfdd}|S)a2 If C{condition}, replace this function with C{alternative}. @param condition: A L{bool} which says whether this should be replaced. @param alternative: An alternative function that will be swapped in instead of the original, if C{condition} is truthy. @return: A decorator. csFdkrn dkr|ntdtt|fdd}|S)NTFz8condition argument to _replaceIf requires a bool, not {}cs ||S)N)argskwargscallr:/usr/lib/python3/dist-packages/twisted/python/_oldstyle.pywrapped'sz._replaceIf..decorator..wrapped) ValueErrorformatreprr)funcr  alternative conditionr r decoratorsz_replaceIf..decoratorr)rrrrrr _replaceIfs rcCs|S)z] Return C{arg}. Do nothing. @param arg: The arg to return. @return: C{arg} r)argrrr passthru1srcCs2t|tjk r.ddlm}tdj||d|S)z Ensure that C{cls} is an old-style class. @param cls: The class to check. @return: The class, if it is an old-style class. @raises: L{ValueError} if it is a new-style class. r)fullyQualifiedNameztwisted.python._oldstyle._oldStyle is being used to decorate a new-style class ({cls}). This should only be used to decorate old-style classes.)cls)typetypesZ ClassTypeZtwisted.python.reflectrrr)rrrrr _ensureOldClass=s  rcCs$t||jtf}t|j||jS)a A decorator which conditionally converts old-style classes to new-style classes. If it is Python 3, or if the C{TWISTED_NEWSTYLE} environment variable has a falsey (C{no}, C{false}, C{False}, or C{0}) value in the environment, this decorator is a no-op. @param cls: An old-style class to convert to new-style. @type cls: L{types.ClassType} @return: A new-style version of C{cls}. )r __bases__objectr__name____dict__)rZ_basesrrr _oldStyleSs r")__doc__Z __future__rrr functoolsrZtwisted.python.compatrrrrrr"rrrr s