• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python deprecate.deprecated函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: md5

    m.update(pszRealm)
    m.update(":")
    m.update(pszPassword)
    HA1 = m.digest()
    if pszAlg == "md5-sess":
        m = md5()
        m.update(HA1)
        m.update(":")
        m.update(pszNonce)
        m.update(":")
        m.update(pszCNonce)
        HA1 = m.digest()
    return HA1.encode('hex')


DigestCalcHA1 = deprecated(Version("Twisted", 9, 0, 0))(DigestCalcHA1)

def DigestCalcResponse(
    HA1,
    pszNonce,
    pszNonceCount,
    pszCNonce,
    pszQop,
    pszMethod,
    pszDigestUri,
    pszHEntity,
):
    m = md5()
    m.update(pszMethod)
    m.update(":")
    m.update(pszDigestUri)
开发者ID:vit1251,项目名称:twirl,代码行数:31,代码来源:sip.py


示例17: f

 def f():
     deprecated()
     deprecated()
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:3,代码来源:test_assertions.py


示例18: setattr

    tprmm = tprm + '.' + macroname
    mymod = types.ModuleType(tprmm)
    sys.modules[tprmm] = mymod
    setattr(macros, macroname, mymod)
    dict = mymod.__dict__

    # Before we go on, I guess I should explain why I just did that.  Basically
    # it's a gross hack to get epydoc to work right, but the general idea is
    # that it will be a useful aid in debugging in _any_ app which expects
    # sys.modules to have the same globals as some function.  For example, it
    # would be useful if you were foolishly trying to pickle a wrapped function
    # directly from a class that had been hooked.

    exec code in dict, dict
    return dict[name]
macro = deprecated(Version("Twisted", 8, 2, 0))(macro)



def _determineClass(x):
    try:
        return x.__class__
    except:
        return type(x)



def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
开发者ID:GunioRobot,项目名称:twisted,代码行数:31,代码来源:reflect.py


示例19: intToBytes

            default = 80
        if port == default:
            hostHeader = host
        else:
            hostHeader = host + b":" + intToBytes(port)
        self.requestHeaders.addRawHeader(b"host", hostHeader)


    def getClient(self):
        """
        Get the client's IP address, if it has one.

        @return: The same value as C{getClientIP}.
        @rtype: L{bytes}
        """
        return self.getClientIP()


    def redirect(self, url):
        """
        Utility function that does a redirect.

        The request should have finish() called after this.
        """
        self.setResponseCode(FOUND)
        self.setHeader(b"location", url)

DummyRequest.getClient = deprecated(
    Version("Twisted", 15, 0, 0),
    "Twisted Names to resolve hostnames")(DummyRequest.getClient)
开发者ID:Lovelykira,项目名称:frameworks_try,代码行数:30,代码来源:requesthelper.py


示例20: logPrefix

        """
        log.msg('(Tuntap %s Closed)' % self.interface)
        abstract.FileDescriptor.connectionLost(self, reason)
        self.protocol.doStop()
        self.connected = 0
        self._system.close(self._fileno)
        self._fileno = -1


    def logPrefix(self):
        """
        Returns the name of my class, to prefix log entries with.
        """
        return self.logstr


    def getHost(self):
        """
        Get the local address of this L{TuntapPort}.

        @return: A L{TunnelAddress} which describes the tunnel device to which
            this object is bound.
        @rtype: L{TunnelAddress}
        """
        return TunnelAddress(self._mode, self.interface)

TuntapPort.loseConnection = deprecated(
    Version("Twisted", 14, 0, 0),
    TuntapPort.stopListening)(TuntapPort.loseConnection)

开发者ID:0004c,项目名称:VTK,代码行数:29,代码来源:tuntap.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python deprecate.deprecatedModuleAttribute函数代码示例发布时间:2022-05-27
下一篇:
Python context.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap