當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。