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

Python warnings.warnpy3k函数代码示例

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

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



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

示例1: parse

def parse(str, flags=0, pattern=None):
    # parse 're' pattern into list of (opcode, argument) tuples

    source = Tokenizer(str)

    if pattern is None:
        pattern = Pattern()
    pattern.flags = flags
    pattern.str = str

    p = _parse_sub(source, pattern, 0)
    if (sys.py3kwarning and
        (p.pattern.flags & SRE_FLAG_LOCALE) and
        (p.pattern.flags & SRE_FLAG_UNICODE)):
        import warnings
        warnings.warnpy3k("LOCALE and UNICODE flags are incompatible",
                          DeprecationWarning, stacklevel=5)

    tail = source.get()
    if tail == ")":
        raise error, "unbalanced parenthesis"
    elif tail:
        raise error, "bogus characters at end of regular expression"

    if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE:
        # the VERBOSE flag was switched on inside the pattern.  to be
        # on the safe side, we'll parse the whole thing again...
        return parse(str, p.pattern.flags)

    if flags & SRE_FLAG_DEBUG:
        p.dump()

    return p
开发者ID:kubaszostak,项目名称:gdal-dragndrop,代码行数:33,代码来源:sre_parse.py


示例2: walk

def walk(top, func, arg):
    """Directory tree walk with callback function.

    For each directory in the directory tree rooted at top (including top
    itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
    dirname is the name of the directory, and fnames a list of the names of
    the files and subdirectories in dirname (excluding '.' and '..').  func
    may modify the fnames list in-place (e.g. via del or slice assignment),
    and walk will only recurse into the subdirectories whose names remain in
    fnames; this can be used to implement a filter, or to impose a specific
    order of visiting.  No semantics are defined for, or required of, arg,
    beyond that arg is always passed to func.  It can be used, e.g., to pass
    a filename pattern, or a mutable object designed to accumulate
    statistics.  Passing None for arg is common."""
    warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
                      stacklevel=2)
    try:
        names = os.listdir(top)
    except os.error:
        return
    func(arg, top, names)
    for name in names:
        name = join(top, name)
        if isdir(name):
            walk(name, func, arg)
开发者ID:AdrianPotter,项目名称:Pydev,代码行数:25,代码来源:ntpath.py


示例3: _escape

def _escape(source, escape, state, nested):
    # handle escape code in expression
    code = CATEGORIES.get(escape)
    if code:
        return code
    code = ESCAPES.get(escape)
    if code:
        return code
    try:
        c = escape[1:2]
        if c == "x":
            # hexadecimal escape
            while source.next in HEXDIGITS and len(escape) < 4:
                escape = escape + source.get()
            if len(escape) != 4:
                raise ValueError
            return LITERAL, int(escape[2:], 16) & 0xff
        elif c == "0":
            # octal escape
            while source.next in OCTDIGITS and len(escape) < 4:
                escape = escape + source.get()
            return LITERAL, int(escape[1:], 8) & 0xff
        elif c in DIGITS:
            # octal escape *or* decimal group reference (sigh)
            if source.next in DIGITS:
                escape = escape + source.get()
                if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and
                    source.next in OCTDIGITS):
                    # got three octal digits; this is an octal escape
                    escape = escape + source.get()
                    return LITERAL, int(escape[1:], 8) & 0xff
            # not an octal escape, so this is a group reference
            group = int(escape[1:])
            if group < state.groups:
                if not state.checkgroup(group):
                    raise error, "cannot refer to open group"
                if state.lookbehind:
                    import warnings
                    warnings.warn('group references in lookbehind '
                                  'assertions are not supported',
                                  RuntimeWarning, stacklevel=nested + 6)
                return GROUPREF, group
            raise ValueError
        if len(escape) == 2:
            if sys.py3kwarning and c in ASCIILETTERS:
                import warnings
                if c in 'Uu':
                    warnings.warn('bad escape %s; Unicode escapes are '
                                  'supported only since Python 3.3' % escape,
                                  FutureWarning, stacklevel=nested + 6)
                else:
                    warnings.warnpy3k('bad escape %s' % escape,
                                      DeprecationWarning, stacklevel=nested + 6)
            return LITERAL, ord(escape[1])
    except ValueError:
        pass
    raise error, "bogus escape: %s" % repr(escape)
开发者ID:kubaszostak,项目名称:gdal-dragndrop,代码行数:57,代码来源:sre_parse.py


示例4: readPlistFromResource

def readPlistFromResource(path, restype = 'plst', resid = 0):
    warnings.warnpy3k('In 3.x, readPlistFromResource is removed.', stacklevel=2)
    from Carbon.File import FSRef, FSGetResourceForkName
    from Carbon.Files import fsRdPerm
    from Carbon import Res
    fsRef = FSRef(path)
    resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdPerm)
    Res.UseResFile(resNum)
    plistData = Res.Get1Resource(restype, resid).data
    Res.CloseResFile(resNum)
    return readPlistFromString(plistData)
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:11,代码来源:plistlib.py


示例5: mkarg

def mkarg(x):
    from warnings import warnpy3k
    warnpy3k("in 3.x, mkarg has been removed.")
    if '\'' not in x:
        return ' \'' + x + '\''
    s = ' "'
    for c in x:
        if c in '\\$"`':
            s = s + '\\'
        s = s + c
    s = s + '"'
    return s
开发者ID:1833183060,项目名称:wke,代码行数:12,代码来源:commands.py


示例6: walk

def walk(top, func, arg):
    warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel=2)
    try:
        names = os.listdir(top)
    except os.error:
        return

    func(arg, top, names)
    for name in names:
        name = join(top, name)
        if isdir(name):
            walk(name, func, arg)
开发者ID:Pluckyduck,项目名称:eve,代码行数:12,代码来源:ntpath.py


示例7: __init__

    def __init__(self, attr, parent=None, imagetype=None):
        # replace standard MutableString init to not overwrite self.data
        from warnings import warnpy3k
        warnpy3k('the class UserString.MutableString has been removed in '
                    'Python 3.0', stacklevel=2)

        self.attr = attr
        if imagetype is None:
            imagetype = self._types[attr]
        self.imagetype = imagetype
        self.parent = parent

        if parent:
            self.hostname = parent.get('hostname', parent.get('host', None))
开发者ID:matt-schrader,项目名称:mythtv,代码行数:14,代码来源:dataheap.py


示例8: urlopen

def urlopen(url, data = None, proxies = None):
    global _urlopener
    from warnings import warnpy3k
    warnpy3k('urllib.urlopen() has been removed in Python 3.0 in favor of urllib2.urlopen()', stacklevel=2)
    if proxies is not None:
        opener = FancyURLopener(proxies=proxies)
    elif not _urlopener:
        opener = FancyURLopener()
        _urlopener = opener
    else:
        opener = _urlopener
    if data is None:
        return opener.open(url)
    else:
        return opener.open(url, data)
开发者ID:Pluckyduck,项目名称:eve,代码行数:15,代码来源:urllib.py


示例9: walk

def walk(top, func, arg):
    warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel=2)
    try:
        names = os.listdir(top)
    except os.error:
        return

    func(arg, top, names)
    for name in names:
        name = join(top, name)
        try:
            st = os.lstat(name)
        except os.error:
            continue

        if stat.S_ISDIR(st.st_mode):
            walk(name, func, arg)
开发者ID:Pluckyduck,项目名称:eve,代码行数:17,代码来源:posixpath.py


示例10: writePlistToResource

def writePlistToResource(rootObject, path, restype = 'plst', resid = 0):
    warnings.warnpy3k('In 3.x, writePlistToResource is removed.', stacklevel=2)
    from Carbon.File import FSRef, FSGetResourceForkName
    from Carbon.Files import fsRdWrPerm
    from Carbon import Res
    plistData = writePlistToString(rootObject)
    fsRef = FSRef(path)
    resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdWrPerm)
    Res.UseResFile(resNum)
    try:
        Res.Get1Resource(restype, resid).RemoveResource()
    except Res.Error:
        pass

    res = Res.Resource(plistData)
    res.AddResource(restype, resid, '')
    res.WriteResource()
    Res.CloseResFile(resNum)
开发者ID:bizonix,项目名称:DropBoxLibrarySRC,代码行数:18,代码来源:plistlib.py


示例11: myurlopen

    def myurlopen(self,url,data = None, proxies = None):
        #/////////////
        # Shortcut for basic usage
        _urlopener = None
        """Create a file-like object for the specified URL to read from."""
        from warnings import warnpy3k
        warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in "
                            "favor of urllib2.urlopen()", stacklevel=2)

        
        if proxies is not None:
            opener = myURLopener(proxies=proxies)
        elif not _urlopener:
            opener = myURLopener()
            _urlopener = opener
        else:
            opener = _urlopener
        if data is None:
            return opener.open(url)
        else:
            return opener.open(url, data)
开发者ID:xiaoxisun,项目名称:Python-Project,代码行数:21,代码来源:SimpleCrawler.py


示例12: _class_escape

def _class_escape(source, escape, nested):
    # handle escape code inside character class
    code = ESCAPES.get(escape)
    if code:
        return code
    code = CATEGORIES.get(escape)
    if code and code[0] == IN:
        return code
    try:
        c = escape[1:2]
        if c == "x":
            # hexadecimal escape (exactly two digits)
            while source.next in HEXDIGITS and len(escape) < 4:
                escape = escape + source.get()
            escape = escape[2:]
            if len(escape) != 2:
                raise error, "bogus escape: %s" % repr("\\" + escape)
            return LITERAL, int(escape, 16) & 0xff
        elif c in OCTDIGITS:
            # octal escape (up to three digits)
            while source.next in OCTDIGITS and len(escape) < 4:
                escape = escape + source.get()
            escape = escape[1:]
            return LITERAL, int(escape, 8) & 0xff
        elif c in DIGITS:
            raise error, "bogus escape: %s" % repr(escape)
        if len(escape) == 2:
            if sys.py3kwarning and c in ASCIILETTERS:
                import warnings
                if c in 'Uu':
                    warnings.warn('bad escape %s; Unicode escapes are '
                                  'supported only since Python 3.3' % escape,
                                  FutureWarning, stacklevel=nested + 6)
                else:
                    warnings.warnpy3k('bad escape %s' % escape,
                                      DeprecationWarning, stacklevel=nested + 6)
            return LITERAL, ord(escape[1])
    except ValueError:
        pass
    raise error, "bogus escape: %s" % repr(escape)
开发者ID:kubaszostak,项目名称:gdal-dragndrop,代码行数:40,代码来源:sre_parse.py


示例13: warnpy3k

# Embedded file name: scripts/common/Lib/plat-mac/gensuitemodule.py
"""
gensuitemodule - Generate an AE suite module from an aete/aeut resource

Based on aete.py.

Reading and understanding this code is left as an exercise to the reader.
"""
from warnings import warnpy3k
warnpy3k('In 3.x, the gensuitemodule module is removed.', stacklevel=2)
import MacOS
import EasyDialogs
import os
import string
import sys
import types
import StringIO
import keyword
import macresource
import aetools
import distutils.sysconfig
import OSATerminology
from Carbon.Res import *
import Carbon.Folder
import MacOS
import getopt
import plistlib
_MAC_LIB_FOLDER = os.path.dirname(aetools.__file__)
DEFAULT_STANDARD_PACKAGEFOLDER = os.path.join(_MAC_LIB_FOLDER, 'lib-scriptpackages')
DEFAULT_USER_PACKAGEFOLDER = distutils.sysconfig.get_python_lib()
开发者ID:aevitas,项目名称:wotsdk,代码行数:30,代码来源:plat-macgensuitemodule.py


示例14: and


"""Support for Berkeley DB 4.3 through 5.3 with a simple interface.

For the full featured object oriented interface use the bsddb.db module
instead.  It mirrors the Oracle Berkeley DB C API.
"""

import sys
absolute_import = (sys.version_info[0] >= 3)

if (sys.version_info >= (2, 6)) and (sys.version_info < (3, 0)) :
    import warnings
    if sys.py3kwarning and (__name__ != 'bsddb3') :
        warnings.warnpy3k("in 3.x, the bsddb module has been removed; "
                          "please use the pybsddb project instead",
                          DeprecationWarning, 2)
    warnings.filterwarnings("ignore", ".*CObject.*", DeprecationWarning,
                            "bsddb.__init__")

try:
    if __name__ == 'bsddb3':
        # import _pybsddb binary as it should be the more recent version from
        # a standalone pybsddb addon package than the version included with
        # python as bsddb._bsddb.
        if absolute_import :
            # Because this syntaxis is not valid before Python 2.5
            exec("from . import _pybsddb")
        else :
            import _pybsddb
        _bsddb = _pybsddb
开发者ID:0xcc,项目名称:pyston,代码行数:29,代码来源:__init__.py


示例15: Evropa

# 2015.11.10 21:33:24 Støední Evropa (bìžný èas)
# Embedded file name: scripts/common/Lib/new.py
"""Create new objects of various types.  Deprecated.

This module is no longer required except for backward compatibility.
Objects of most types can now be created by calling the type object.
"""
from warnings import warnpy3k
warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' module instead.", stacklevel=2)
del warnpy3k
from types import ClassType as classobj
from types import FunctionType as function
from types import InstanceType as instance
from types import MethodType as instancemethod
from types import ModuleType as module
from types import CodeType as code
# okay decompyling c:\Users\PC\wotsources\files\originals\res_bw\scripts\common\lib\new.pyc 
# decompiled 1 files: 1 okay, 0 failed, 0 verify failed
# 2015.11.10 21:33:24 Støední Evropa (bìžný èas)
开发者ID:webiumsk,项目名称:WOT-0.9.12-CT,代码行数:19,代码来源:new.py


示例16: Evropa

# 2016.02.14 12:50:02 Støední Evropa (bìžný èas)
# Embedded file name: scripts/common/Lib/plat-mac/macresource.py
"""macresource - Locate and open the resources needed for a script."""
from warnings import warnpy3k
warnpy3k('In 3.x, the macresource module is removed.', stacklevel=2)
from Carbon import Res
import os
import sys
import MacOS
import macostools

class ArgumentError(TypeError):
    pass


class ResourceFileNotFoundError(ImportError):
    pass


def need(restype, resid, filename = None, modname = None):
    """Open a resource file, if needed. restype and resid
    are required parameters, and identify the resource for which to test. If it
    is available we are done. If it is not available we look for a file filename
    (default: modname with .rsrc appended) either in the same folder as
    where modname was loaded from, or otherwise across sys.path.
    
    Returns the refno of the resource file opened (or None)"""
    if modname is None and filename is None:
        raise ArgumentError, 'Either filename or modname argument (or both) must be given'
    if type(resid) is type(1):
        try:
开发者ID:webiumsk,项目名称:WOT-0.9.14-CT,代码行数:31,代码来源:macresource.py


示例17: eval

exec, eval(), execfile() and import, but executing the code in an
environment that only exposes those built-in operations that are
deemed safe.  To this end, a modest collection of 'fake' modules is
created which mimics the standard modules by the same names.  It is a
policy decision which built-in modules and operations are made
available; this module provides a reasonable default, but derived
classes can change the policies e.g. by overriding or extending class
variables like ok_builtin_modules or methods like make_sys().

XXX To do:
- r_open should allow writing tmp dir
- r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?)

"""
from warnings import warnpy3k
warnpy3k("the rexec module has been removed in Python 3.0", stacklevel=2)
del warnpy3k


import sys
import __builtin__
import os
import ihooks
import imp

__all__ = ["RExec"]

class FileBase:

    ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline',
            'readlines', 'seek', 'tell', 'write', 'writelines', 'xreadlines',
开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:rexec.py


示例18: mkalias

# Embedded file name: scripts/common/Lib/plat-mac/macostools.py
"""macostools - Various utility functions for MacOS.

mkalias(src, dst) - Create a finder alias 'dst' pointing to 'src'
copy(src, dst) - Full copy of 'src' to 'dst'
"""
from warnings import warnpy3k
warnpy3k('In 3.x, the macostools module is removed.', stacklevel=2)
from Carbon import Res
from Carbon import File, Files
import os
import errno
import MacOS
try:
    openrf = MacOS.openrf
except AttributeError:
    openrf = open

Error = 'macostools.Error'
BUFSIZ = 524288
COPY_FLAGS = Files.kIsStationary | Files.kNameLocked | Files.kHasBundle | Files.kIsInvisible | Files.kIsAlias

def mkalias(src, dst, relative = None):
    """Create a finder alias"""
    srcfsr = File.FSRef(src)
    dstdir, dstname = os.path.split(dst)
    if not dstdir:
        dstdir = os.curdir
    dstdirfsr = File.FSRef(dstdir)
    if relative:
        relativefsr = File.FSRef(relative)
开发者ID:aevitas,项目名称:wotsdk,代码行数:31,代码来源:plat-macmacostools.py


示例19: Evropa

# 2016.05.01 15:31:32 Støední Evropa (letní èas)
# Embedded file name: scripts/common/Lib/plat-mac/applesingle.py
"""Routines to decode AppleSingle files
"""
from warnings import warnpy3k
warnpy3k('In 3.x, the applesingle module is removed.', stacklevel=2)
import struct
import sys
try:
    import MacOS
    import Carbon.File
except:

    class MacOS:

        def openrf(path, mode):
            return open(path + '.rsrc', mode)

        openrf = classmethod(openrf)


    class Carbon:

        class File:

            class FSSpec:
                pass

            class FSRef:
                pass
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:30,代码来源:applesingle.py


示例20: __init__

 def __init__(self, string=""):
     from warnings import warnpy3k
     warnpy3k('the class UserString.MutableString has been removed in '
                 'Python 3.0', stacklevel=2)
     self.data = string
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:5,代码来源:UserString.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python watchdog.cancellableSendMessage函数代码示例发布时间:2022-05-26
下一篇:
Python warnings.warn_explicit函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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