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


Python PosixModule.open方法代码示例

本文整理汇总了Python中org.python.modules.posix.PosixModule.open方法的典型用法代码示例。如果您正苦于以下问题:Python PosixModule.open方法的具体用法?Python PosixModule.open怎么用?Python PosixModule.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.modules.posix.PosixModule的用法示例。


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

示例1: _execfile

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def _execfile(filename, globals, locals=None):
    """
    Python 3 implementation of execfile.
    """
    mode = 'rb'
    with open(filename, mode) as stream:
        script = stream.read()
    # compile() function in Python 2.6 and 3.1 requires LF line endings.
    if sys.version_info[:2] < (2, 7) or sys.version_info[:2] >= (3, 0) and sys.version_info[:2] < (3, 2):
        script = script.replace(b'\r\n', b'\n')
        script = script.replace(b'\r', b'\n')
    if locals is None:
        locals = globals
    code = compile(script, filename, 'exec')
    exec(code, globals, locals) 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:sandbox.py

示例2: run

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def run(self, func):
        """Run 'func' under os sandboxing"""
        try:
            self._copy(self)
            if _file:
                builtins.file = self._file
            builtins.open = self._open
            self._active = True
            return func()
        finally:
            self._active = False
            if _file:
                builtins.file = _file
            builtins.open = _open
            self._copy(_os) 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:sandbox.py

示例3: _open

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def _open(self, path, mode='r', *args, **kw):
        if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
            self._violation("open", path, mode, *args, **kw)
        return _open(path,mode,*args,**kw) 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:sandbox.py

示例4: open

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def open(self, file, flags, mode=0o777, *args, **kw):
        """Called for low-level os.open()"""
        if flags & WRITE_FLAGS and not self._ok(file):
            self._violation("os.open", file, flags, mode, *args, **kw)
        return _os.open(file,flags,mode, *args, **kw) 
开发者ID:jpush,项目名称:jbox,代码行数:7,代码来源:sandbox.py

示例5: _open

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def _open(self, path, mode='r', *args, **kw):
        if mode not in ('r', 'rt', 'rb', 'rU', 'U') and not self._ok(path):
            self._violation("open", path, mode, *args, **kw)
        return _open(path, mode, *args, **kw) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:6,代码来源:sandbox.py

示例6: open

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def open(self, file, flags, mode=0o777, *args, **kw):
        """Called for low-level os.open()"""
        if flags & WRITE_FLAGS and not self._ok(file):
            self._violation("os.open", file, flags, mode, *args, **kw)
        return _os.open(file, flags, mode, *args, **kw) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:7,代码来源:sandbox.py

示例7: _execfile

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def _execfile(filename, globals, locals=None):
    """
    Python 3 implementation of execfile.
    """
    mode = 'rb'
    with open(filename, mode) as stream:
        script = stream.read()
    if locals is None:
        locals = globals
    code = compile(script, filename, 'exec')
    exec(code, globals, locals) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:13,代码来源:sandbox.py

示例8: __enter__

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def __enter__(self):
        self._copy(self)
        if _file:
            builtins.file = self._file
        builtins.open = self._open
        self._active = True 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,代码来源:sandbox.py

示例9: __exit__

# 需要导入模块: from org.python.modules.posix import PosixModule [as 别名]
# 或者: from org.python.modules.posix.PosixModule import open [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
        self._active = False
        if _file:
            builtins.file = _file
        builtins.open = _open
        self._copy(_os) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,代码来源:sandbox.py


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