Python StringIO.StringIO.truncate() Examples

The following are 22 code examples of StringIO.StringIO.truncate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module StringIO.StringIO , or try the search function .
Example #1
Source File: doctest_driver.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _check_output(self, example):
        want = example.want
        optionflags = self._get_optionflags(example)
        got = sys.stdout.getvalue()
        sys.stdout.truncate(0)
        if not self.checker.check_output(want, got, optionflags):
            self.runner.report_failure(self.save_stdout.write,
                                       self.test, example, got)
            return False
        else:
            return True 
Example #2
Source File: doctest.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #3
Source File: doctest.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #4
Source File: doctest.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #5
Source File: doctest.py    From unity-python with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #6
Source File: doctest.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #7
Source File: doctest.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #8
Source File: doctest.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #9
Source File: doctest.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #10
Source File: doctest.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

# Worst-case linear-time ellipsis matching. 
Example #11
Source File: doctest.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #12
Source File: doctest_driver.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

###########################################################################
# Update Runner
########################################################################### 
Example #13
Source File: doctest_driver.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

###########################################################################
# MyParser
########################################################################### 
Example #14
Source File: data.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _reset_buffer(self):
        # For some reason calling StringIO.truncate() here will lead to
        # inconsistent writes so just set _buffer to a new StringIO object.
        self._buffer = StringIO()
        self._len = 0 
Example #15
Source File: doctest.py    From oss-ftp with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #16
Source File: dtcompat.py    From Computable with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

# Worst-case linear-time ellipsis matching. 
Example #17
Source File: doctest.py    From BinderFilter with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #18
Source File: dtcompat.py    From locality-sensitive-hashing with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

# Worst-case linear-time ellipsis matching. 
Example #19
Source File: doctest.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #20
Source File: doctest.py    From meddle with MIT License 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace
        if not self.buf:
            # Reset it to an empty string, to make sure it's not unicode.
            self.buf = ''

# Worst-case linear-time ellipsis matching. 
Example #21
Source File: doctest24.py    From mishkal with GNU General Public License v3.0 5 votes vote down vote up
def truncate(self,   size=None):
        StringIO.truncate(self, size)
        if hasattr(self, "softspace"):
            del self.softspace

# Worst-case linear-time ellipsis matching. 
Example #22
Source File: doctest_driver.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def _check_output(self, example):
        want = example.want
        optionflags = self._get_optionflags(example)
        got = sys.stdout.getvalue()
        sys.stdout.truncate(0)
        if not self.checker.check_output(want, got, optionflags):
            self.runner.report_failure(self.save_stdout.write, 
                                       self.test, example, got)
            return False
        else:
            return True