[MERGE] symbol_versioning.deprecation_string

John Arbash Meinel john at arbash-meinel.com
Tue Sep 5 13:16:52 BST 2006


Robert Collins wrote:
> This adds a helper to symbol_versioning to give you the deprecation
> string that will be emitted for a given symbol, deprecation_format pair.
> 
> This is primarily of use with callDeprecated.
> 
> -Rob
> 
> 
> ------------------------------------------------------------------------
> 
> === modified file 'bzrlib/symbol_versioning.py'
> --- bzrlib/symbol_versioning.py	2006-08-28 17:04:38 +0000
> +++ bzrlib/symbol_versioning.py	2006-09-05 10:34:51 +0000
> @@ -57,6 +57,25 @@
>  # add that on top of the primitives, once we have all three written
>  # - RBC 20050105

-- With an extra blank line here, you have my +1.
>  
> +def deprecation_string(a_callable, deprecation_version):
> +    """Generate an automatic deprecation string for a_callable.
> +
> +    :param a_callable: The callable to substitute into deprecation_version.
> +    :param deprecation_version: A deprecation format warning string. This should
> +        have a single %s operator in it. a_callable will be turned into a nice
> +        python symbol and then substituted into deprecation_version.
> +    """
> +    if getattr(a_callable, 'im_class', None) is None:
> +        symbol = "%s.%s" % (a_callable.__module__,
> +                            a_callable.__name__)
> +    else:
> +        symbol = "%s.%s.%s" % (a_callable.im_class.__module__,
> +                               a_callable.im_class.__name__,
> +                               a_callable.__name__
> +                               )
> +    return deprecation_version % symbol
> +
> +

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060905/c5fb481c/attachment.pgp 


More information about the bazaar mailing list