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


Python StringIO.write方法代码示例

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


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

示例1: __init__

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def __init__(self, out=True, err=True, in_=True, mixed=False, now=True):
        self._oldout = sys.stdout
        self._olderr = sys.stderr
        self._oldin  = sys.stdin
        if out and not hasattr(out, 'file'):
            out = TextIO()
        self.out = out
        if err:
            if mixed:
                err = out
            elif not hasattr(err, 'write'):
                err = TextIO()
        self.err = err
        self.in_ = in_
        if now:
            self.startall() 
开发者ID:pytest-dev,项目名称:py,代码行数:18,代码来源:capture.py

示例2: use_browser

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def use_browser(cls, browser):
        if browser not in ("chrome", "firefox", "safari"):
            _CommonTargets.exit("No valid webdriver specified! Choose between 'chrome', 'firefox' and 'safari'.", 1)

        # write the config file
        config_text = ("# This file is automatically generated by the Makefile.\n"
                       "# Do not manually edit it!\n"
                       "\n"
                       "WEBDRIVER = \"{webdriver}\"\n".format(webdriver=browser))
        with open(WEBDRIVER_CONF_FILE, 'w') as f:
            f.write(config_text)

        # install the selenium driver for chrome and firefox
        if browser == "chrome":
            cls.__install_chromedriver()
        elif browser == "firefox":
            cls.__install_geckodriver() 
开发者ID:iguana-project,项目名称:iguana,代码行数:19,代码来源:make.py

示例3: write

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def write(self, data):
            if not isinstance(data, unicode):
                data = unicode(data, getattr(self, '_encoding', 'UTF-8'), 'replace')
            return StringIO.write(self, data) 
开发者ID:pytest-dev,项目名称:py,代码行数:6,代码来源:capture.py

示例4: writeorg

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def writeorg(self, data):
        """ write a string to the original file descriptor
        """
        tempfp = tempfile.TemporaryFile()
        try:
            os.dup2(self._savefd, tempfp.fileno())
            tempfp.write(data)
        finally:
            tempfp.close() 
开发者ID:pytest-dev,项目名称:py,代码行数:11,代码来源:capture.py

示例5: writelines

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def writelines(self, linelist):
        data = ''.join(linelist)
        self.write(data) 
开发者ID:pytest-dev,项目名称:py,代码行数:5,代码来源:capture.py

示例6: write

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def write(self, data):
            if not isinstance(data, unicode):
                data = unicode(data, getattr(self, '_encoding', 'UTF-8'), 'replace')
            StringIO.write(self, data) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:6,代码来源:capture.py

示例7: _save

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def _save(self):
        in_ = self._options['in_']
        out = self._options['out']
        err = self._options['err']
        mixed = self._options['mixed']
        patchsys = self._options['patchsys']
        if in_:
            try:
                self.in_ = FDCapture(0, tmpfile=None, now=False,
                    patchsys=patchsys)
            except OSError:
                pass
        if out:
            tmpfile = None
            if hasattr(out, 'write'):
                tmpfile = out
            try:
                self.out = FDCapture(1, tmpfile=tmpfile,
                           now=False, patchsys=patchsys)
                self._options['out'] = self.out.tmpfile
            except OSError:
                pass
        if err:
            if out and mixed:
                tmpfile = self.out.tmpfile
            elif hasattr(err, 'write'):
                tmpfile = err
            else:
                tmpfile = None
            try:
                self.err = FDCapture(2, tmpfile=tmpfile,
                           now=False, patchsys=patchsys)
                self._options['err'] = self.err.tmpfile
            except OSError:
                pass 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:37,代码来源:capture.py

示例8: write

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def write(self, content, replace=0):
    self['state'] = tk.NORMAL
    if replace:
        self.delete(tk.END + f"-{replace}c", tk.END)
    self.insert(tk.END , content)
    self['state'] = tk.DISABLED
    self.see(tk.END)
    return StringIO.write(self.stream, content) 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:10,代码来源:stream.py

示例9: write

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def write(self, s):
            StringIO.write(self, s) 
开发者ID:SystemRage,项目名称:py-kms,代码行数:4,代码来源:pykms_Format.py

示例10: newlines_file

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def newlines_file(self, mode, *args):
            try:
                with open(self.path_nl, mode) as file:
                    if mode in ['w', 'a']:
                        file.write(args[0])
                    elif mode == 'r':
                        data = [int(i) for i in [line.rstrip('\n') for line in file.readlines()]]
                        self.newlines, ShellMessage.remain = data[0], sum(data[1:])
            except:
                with open(self.path_nl, 'w') as file:
                        pass 
开发者ID:SystemRage,项目名称:py-kms,代码行数:13,代码来源:pykms_Format.py

示例11: newlines_clean

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def newlines_clean(self, num):
            if num == 0:
                with open(self.path_clean_nl, 'w') as file:
                    file.write('clean newlines')
            try:
                with open(self.path_clean_nl, 'r') as file:
                    some = file.read()
                if num == 21:
                    ShellMessage.count, ShellMessage.remain, ShellMessage.numlist = (0, 0, [])
                    os.remove(self.path_nl)
                    os.remove(self.path_clean_nl)
            except:
                if num == 19:
                    ShellMessage.count, ShellMessage.remain, ShellMessage.numlist = (0, 0, [])
                    os.remove(self.path_nl) 
开发者ID:SystemRage,项目名称:py-kms,代码行数:17,代码来源:pykms_Format.py

示例12: write

# 需要导入模块: from io import StringIO [as 别名]
# 或者: from io.StringIO import write [as 别名]
def write(self, *args, **kwargs):
            # only write output, that does not contain 'virtualenv'
            write = False
            if isinstance(args, tuple):
                for arg in args:
                    if "virtualenv" not in arg:
                        write = True
            elif "virtualenv" not in args:
                write = True

            if write:
                self.__stdout.write(*args, **kwargs)
                StringIO.write(self, *args, **kwargs) 
开发者ID:iguana-project,项目名称:iguana,代码行数:15,代码来源:make.py


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