当前位置: 首页>>代码示例>>Python>>正文


Python deprecate.deprecated函数代码示例

本文整理汇总了Python中twisted.python.deprecate.deprecated函数的典型用法代码示例。如果您正苦于以下问题:Python deprecated函数的具体用法?Python deprecated怎么用?Python deprecated使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了deprecated函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deprecatedPreservesName

 def test_deprecatedPreservesName(self):
     """
     The decorated function has the same name as the original.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version)(dummyCallable)
     self.assertEqual(dummyCallable.__name__, dummy.__name__)
     self.assertEqual(qual(dummyCallable), qual(dummy))
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:8,代码来源:test_deprecate.py

示例2: test_versionMetadata

 def test_versionMetadata(self):
     """
     Deprecating a function adds version information to the decorated
     version of that function.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version)(dummyCallable)
     self.assertEqual(version, dummy.deprecatedVersion)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:8,代码来源:test_deprecate.py

示例3: deprecated

 def deprecated(a):
     # the stacklevel is important here, because as the function is
     # recursive, the warnings produced have a different stack, but we
     # want to be sure that only the first warning is tested against
     warnings.warn("Woo deprecated",
         category=PendingDeprecationWarning,
         stacklevel=2)
     i[0] += 1
     if i[0] < 3:
         return deprecated(a)
     else:
         return a
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:12,代码来源:test_assertions.py

示例4: test_deprecateEmitsWarning

 def test_deprecateEmitsWarning(self):
     """
     Decorating a callable with L{deprecated} emits a warning.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version)(dummyCallable)
     def addStackLevel():
         dummy()
     self.assertWarns(
         DeprecationWarning,
         getDeprecationWarningString(dummyCallable, version),
         __file__,
         addStackLevel)
开发者ID:Almad,项目名称:twisted,代码行数:13,代码来源:test_deprecate.py

示例5: test_deprecatedUpdatesDocstring

    def test_deprecatedUpdatesDocstring(self):
        """
        The docstring of the deprecated function is appended with information
        about the deprecation.
        """

        version = Version('Twisted', 8, 0, 0)
        dummy = deprecated(version)(dummyCallable)

        _appendToDocstring(
            dummyCallable,
            _getDeprecationDocstring(version))

        self.assertEqual(dummyCallable.__doc__, dummy.__doc__)
开发者ID:Almad,项目名称:twisted,代码行数:14,代码来源:test_deprecate.py

示例6: test_deprecateEmitsWarning

 def test_deprecateEmitsWarning(self):
     """
     Decorating a callable with L{deprecated} emits a warning.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version)(dummyCallable)
     def addStackLevel():
         dummy()
     with catch_warnings(record=True) as caught:
         simplefilter("always")
         addStackLevel()
         self.assertEqual(caught[0].category, DeprecationWarning)
         self.assertEqual(str(caught[0].message), getDeprecationWarningString(dummyCallable, version))
         # rstrip in case .pyc/.pyo
         self.assertEqual(caught[0].filename.rstrip('co'), __file__.rstrip('co'))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:15,代码来源:test_deprecate.py

示例7: test_nestedDeprecation

    def test_nestedDeprecation(self):
        """
        L{callDeprecated} ignores all deprecations apart from the first.

        Multiple warnings are generated when a deprecated function calls
        another deprecated function. The first warning is the one generated by
        the explicitly called function. That's the warning that we care about.
        """
        differentVersion = Version('Foo', 1, 2, 3)

        def nestedDeprecation(*args):
            return self.oldMethod(*args)
        nestedDeprecation = deprecated(differentVersion)(nestedDeprecation)

        self.callDeprecated(differentVersion, nestedDeprecation, 24)
开发者ID:radical-software,项目名称:radicalspam,代码行数:15,代码来源:test_assertions.py

示例8: test_deprecatedReplacementWithCallable

 def test_deprecatedReplacementWithCallable(self):
     """
     L{deprecated} takes an additional replacement parameter that can be used
     to indicate the new, non-deprecated method developers should use.  If
     the replacement parameter is a callable, its fully qualified name will
     be interpolated into the warning message.
     """
     version = Version('Twisted', 8, 0, 0)
     decorator = deprecated(version, replacement=dummyReplacementMethod)
     dummy = decorator(dummyCallable)
     self.assertEqual(dummy.__doc__,
         "\n"
         "    Do nothing.\n\n"
         "    This is used to test the deprecation decorators.\n\n"
         "    Deprecated in Twisted 8.0.0; please use "
         "%s.dummyReplacementMethod instead.\n"
         "    " % (__name__,))
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:17,代码来源:test_deprecate.py

示例9: test_deprecatedReplacement

 def test_deprecatedReplacement(self):
     """
     L{deprecated} takes an additional replacement parameter that can be used
     to indicate the new, non-deprecated method developers should use.  If
     the replacement parameter is a string, it will be interpolated directly
     into the warning message.
     """
     version = Version('Twisted', 8, 0, 0)
     dummy = deprecated(version, "something.foobar")(dummyCallable)
     self.assertEqual(dummy.__doc__,
         "\n"
         "    Do nothing.\n\n"
         "    This is used to test the deprecation decorators.\n\n"
         "    Deprecated in Twisted 8.0.0; please use "
         "something.foobar"
         " instead.\n"
         "    ")
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:17,代码来源:test_deprecate.py

示例10: test_deprecatedUpdatesDocstring

    def test_deprecatedUpdatesDocstring(self):
        """
        The docstring of the deprecated function is appended with information
        about the deprecation.
        """

        def localDummyCallable():
            """
            Do nothing.

            This is used to test the deprecation decorators.
            """

        version = Version('Twisted', 8, 0, 0)
        dummy = deprecated(version)(localDummyCallable)

        _appendToDocstring(
            localDummyCallable,
            _getDeprecationDocstring(version, ''))

        self.assertEqual(localDummyCallable.__doc__, dummy.__doc__)
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:21,代码来源:test_deprecate.py

示例11: test_nestedDeprecation

    def test_nestedDeprecation(self):
        """
        L{callDeprecated} ignores all deprecations apart from the first.

        Multiple warnings are generated when a deprecated function calls
        another deprecated function. The first warning is the one generated by
        the explicitly called function. That's the warning that we care about.
        """
        differentVersion = Version('Foo', 1, 2, 3)

        def nestedDeprecation(*args):
            return oldMethod(*args)
        nestedDeprecation = deprecated(differentVersion)(nestedDeprecation)

        self.callDeprecated(differentVersion, nestedDeprecation, 24)

        # The oldMethod deprecation should have been emitted too, not captured
        # by callDeprecated.  Flush it now to make sure it did happen and to
        # prevent it from showing up on stdout.
        warningsShown = self.flushWarnings()
        self.assertEqual(len(warningsShown), 1)
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:21,代码来源:test_assertions.py

示例12: __call__

    def __call__(self, *args, **kw):
        """Asynchronously invoke a remote method.
        """
        return self.obj.broker._sendMessage('',self.obj.perspective, self.obj.luid,  self.name, args, kw)



def noOperation(*args, **kw):
    """
    Do nothing.

    Neque porro quisquam est qui dolorem ipsum quia dolor sit amet,
    consectetur, adipisci velit...
    """
noOperation = deprecated(Version("twisted", 8, 2, 0))(noOperation)



class PBConnectionLost(Exception):
    pass



def printTraceback(tb):
    """
    Print a traceback (string) to the standard log.
    """
    log.msg('Perspective Broker Traceback:' )
    log.msg(tb)
printTraceback = deprecated(Version("twisted", 8, 2, 0))(printTraceback)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:30,代码来源:pb.py

示例13: compareMarkPos

    notes = domhelpers.findElementsWithAttribute(document, "class", "note")
    notePrefix = dom.parseString('<strong>Note: </strong>').documentElement
    for note in notes:
        note.childNodes.insert(0, notePrefix)



def compareMarkPos(a, b):
    """
    Perform in every way identically to L{cmp} for valid inputs.
    """
    linecmp = cmp(a[0], b[0])
    if linecmp:
        return linecmp
    return cmp(a[1], b[1])
compareMarkPos = deprecated(Version('Twisted', 9, 0, 0))(compareMarkPos)



def comparePosition(firstElement, secondElement):
    """
    Compare the two elements given by their position in the document or
    documents they were parsed from.

    @type firstElement: C{dom.Element}
    @type secondElement: C{dom.Element}

    @return: C{-1}, C{0}, or C{1}, with the same meanings as the return value
    of L{cmp}.
    """
    return cmp(firstElement._markpos, secondElement._markpos)
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:31,代码来源:tree.py

示例14: str

            self.callDeprecated,
            differentVersion, self.oldMethod, 'foo')
        self.assertIn(getVersionString(self.version), str(exception))
        self.assertIn(getVersionString(differentVersion), str(exception))


    def test_nestedDeprecation(self):
        """
        L{callDeprecated} ignores all deprecations apart from the first.

        Multiple warnings are generated when a deprecated function calls
        another deprecated function. The first warning is the one generated by
        the explicitly called function. That's the warning that we care about.
        """
        differentVersion = Version('Foo', 1, 2, 3)

        def nestedDeprecation(*args):
            return self.oldMethod(*args)
        nestedDeprecation = deprecated(differentVersion)(nestedDeprecation)

        self.callDeprecated(differentVersion, nestedDeprecation, 24)

        # The oldMethod deprecation should have been emitted too, not captured
        # by callDeprecated.  Flush it now to make sure it did happen and to
        # prevent it from showing up on stdout.
        warningsShown = self.flushWarnings()
        self.assertEqual(len(warningsShown), 1)

TestCallDeprecated.oldMethod = deprecated(TestCallDeprecated.version)(
    TestCallDeprecated.oldMethod)
开发者ID:Almad,项目名称:twisted,代码行数:30,代码来源:test_assertions.py

示例15: _makeOptions

    def _makeOptions(self, pattern, enums):
        options = super(RadioGroupInput, self)._makeOptions(pattern, enums)
        for o in options:
            o.fillSlots('name', self.name)
            yield o



class ObjectRadioGroupInput(ObjectChoiceMixin, RadioGroupInput):
    """
    Variant of L{RadioGroupInput} for arbitrary Python objects.

    Deprecated. Use L{RadioGroupInput} with L{methanal.enums.ObjectEnum}.
    """
ObjectRadioGroupInput.__init__ = deprecated(Version('methanal', 0, 2, 1))(
    ObjectRadioGroupInput.__init__)



class MultiCheckboxInput(MultiChoiceInputMixin, ChoiceInput):
    """
    Multiple-checkboxes input.
    """
    fragmentName = 'methanal-multicheck-input'
    jsClass = u'Methanal.View.MultiCheckboxInput'



class ObjectMultiCheckboxInput(ObjectMultiChoiceMixin, MultiCheckboxInput):
    """
    Variant of L{MultiCheckboxInput} for arbitrary Python objects.
开发者ID:jonathanj,项目名称:methanal,代码行数:31,代码来源:view.py


注:本文中的twisted.python.deprecate.deprecated函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。