/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/symbol_versioning.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    """Generate an automatic deprecation string for a_callable.
72
72
 
73
73
    :param a_callable: The callable to substitute into deprecation_version.
74
 
    :param deprecation_version: A deprecation format warning string. This should
75
 
        have a single %s operator in it. a_callable will be turned into a nice
76
 
        python symbol and then substituted into deprecation_version.
 
74
    :param deprecation_version: A deprecation format warning string. This
 
75
        should have a single %s operator in it. a_callable will be turned into
 
76
        a nice python symbol and then substituted into deprecation_version.
77
77
    """
78
78
    if getattr(a_callable, '__self__', None) is not None:
79
79
        symbol = "%s.%s.%s" % (a_callable.__self__.__class__.__module__,
99
99
            from . import trace
100
100
            trace.mutter_callsite(4, "Deprecated function called")
101
101
            warn(deprecation_string(callable, deprecation_version),
102
 
                DeprecationWarning, stacklevel=2)
 
102
                 DeprecationWarning, stacklevel=2)
103
103
            return callable(*args, **kwargs)
104
104
        _populate_decorated(callable, deprecation_version, "function",
105
105
                            decorated_function)
135
135
                                       callable.__name__
136
136
                                       )
137
137
            trace.mutter_callsite(4, "Deprecated method called")
138
 
            warn(deprecation_version % symbol, DeprecationWarning, stacklevel=2)
 
138
            warn(deprecation_version %
 
139
                 symbol, DeprecationWarning, stacklevel=2)
139
140
            return callable(self, *args, **kwargs)
140
141
        _populate_decorated(callable, deprecation_version, "method",
141
142
                            decorated_method)
159
160
    # def __init__(self, bad, other)
160
161
    # def __init__(self, **kwargs)
161
162
    # RBC 20060116
162
 
    return not parameter_value is DEPRECATED_PARAMETER
 
163
    return parameter_value is not DEPRECATED_PARAMETER
163
164
 
164
165
 
165
166
def _decorate_docstring(callable, deprecation_version, label,
171
172
    if len(docstring_lines) == 0:
172
173
        decorated_callable.__doc__ = deprecation_version % ("This " + label)
173
174
    elif len(docstring_lines) == 1:
174
 
        decorated_callable.__doc__ = (callable.__doc__
175
 
                                    + "\n"
176
 
                                    + "\n"
177
 
                                    + deprecation_version % ("This " + label)
178
 
                                    + "\n")
 
175
        decorated_callable.__doc__ = (
 
176
            callable.__doc__ + "\n" + "\n" +
 
177
            deprecation_version % ("This " + label) + "\n")
179
178
    else:
180
179
        spaces = len(docstring_lines[-1])
181
180
        new_doc = callable.__doc__
214
213
    is_deprecated = True
215
214
 
216
215
    def __init__(self,
217
 
        deprecation_version,
218
 
        variable_name,
219
 
        initial_value,
220
 
        advice,
221
 
        ):
 
216
                 deprecation_version,
 
217
                 variable_name,
 
218
                 initial_value,
 
219
                 advice,
 
220
                 ):
222
221
        """Create a dict that warns when read or modified.
223
222
 
224
223
        :param deprecation_version: string for the warning format to raise,