Delete a chunk of text from a file.
		See insert_text.
12554
def delete_text(self,
	                text,
	                fname,
	                pattern=None,
	                expect=None,
	                shutit_pexpect_child=None,
	                note=None,
	                before=False,
	                force=False,
	                line_oriented=True,
	                loglevel=logging.DEBUG):
		
		shutit_global.shutit_global_object.yield_to_draw()
		return self.change_text(text,
		                        fname,
		                        pattern,
		                        expect,
		                        shutit_pexpect_child,
		                        before,
		                        force,
		                        note=note,
		                        delete=True,
		                        line_oriented=line_oriented,
		                        loglevel=loglevel)
610646
def textslice(self, start, end):
        
        return self._select(self._pointer.textslice(start, end))
595359
def insert_after(self, text):
        
        return Document(
                text=self.text + text,
                cursor_position=self.cursor_position,
                selection=self.selection)
757037
def strip(self, data, strip_newlines=False):
        
        text = []
        for token_type, tag_name, tag_opts, token_text in self.tokenize(data):
            if token_type == self.TOKEN_DATA:
                text.append(token_text)
            elif token_type == self.TOKEN_NEWLINE and not strip_newlines:
                text.append(token_text)
        return ''.join(text)
431531
def shrink_text_file(filename, max_size, removal_marker=None):
    
    file_size = os.path.getsize(filename)
    assert file_size > max_size

    # We partition the file into 3 parts:
    # A) start: maxSize/2 bytes we want to keep
    # B) middle: part we want to remove
    # C) end: maxSize/2 bytes we want to keep

    # Trick taken from StackOverflow:
    # https://stackoverflow.com/questions/2329417/fastest-way-to-delete-a-line-from-large-file-in-python
    # We open the file twice at the same time, once for reading (input_file) and once for writing (output_file).
    # We position output_file at the beginning of part B
    # and input_file at the beginning of part C.
    # Then we copy the content of C into B, overwriting what is there.
    # Afterwards we truncate the file after A+C.

    with open(filename, 'r+b') as output_file:
        with open(filename, 'rb') as input_file:
            # Position outputFile between A and B
            output_file.seek(max_size // 2)
            output_file.readline() # jump to end of current line so that we truncate at line boundaries
            if output_file.tell() == file_size:
                # readline jumped to end of file because of a long line
                return

            if removal_marker:
                output_file.write(removal_marker.encode())

            # Position inputFile between B and C
            input_file.seek(-max_size // 2, os.SEEK_END) # jump to beginning of second part we want to keep from end of file
            input_file.readline() # jump to end of current line so that we truncate at line boundaries

            # Copy C over B
            copy_all_lines_from_to(input_file, output_file)

            output_file.truncate()
926271
def insert_text(self, s, from_undo=False):
        """"""
        return super().insert_text(
            ''.join(c for c in s if c in '0123456789'),
            from_undo
        )
671659
def remove(self, line):
        """"""
        nb = 0
        for block in self.blocks:
            nb += block.remove(line)

        return nb
492651
def remove(self, statement_text):
        
        Statement = self.get_model('statement')
        session = self.Session()

        query = session.query(Statement).filter_by(text=statement_text)
        record = query.first()

        session.delete(record)

        self._session_finish(session)
5868
def insert_string(self, data):
        

        # First split string into lines
        lines = data.split('\n')

        while lines:
            line = lines[0]
            del lines[0]

            # Skip empty line
            if not line:
                continue

            # Skip comments
            if comment_re.match(line):
                continue

            # Handle continued lines
            while line[-1] == '\\':
                if lines:
                    line = line[:-1] + lines[0]
                    del lines[0]
                else:
                    line = line[:-1]
                    break

            # Split line into resource and value
            m = resource_spec_re.match(line)

            # Bad line, just ignore it silently
            if not m:
                continue

            res, value = m.group(1, 2)

            # Convert all escape sequences in value
            splits = value_escape_re.split(value)

            for i in range(1, len(splits), 2):
                s = splits[i]
                if len(s) == 3:
                    splits[i] = chr(int(s, 8))
                elif s == 'n':
                    splits[i] = '\n'

            # strip the last value part to get rid of any
            # unescaped blanks
            splits[-1] = splits[-1].rstrip()

            value = ''.join(splits)

            self.insert(res, value)
738747
def text_cleanup(data, key, last_type):
    
    if key in data and last_type == STRING_TYPE:
        data[key] = data[key].strip()
    return data
224559
def cut(self):
        
        cursorPos = self._qpart.cursorPosition
        topLeft = (min(self._start[0], cursorPos[0]),
                   min(self._start[1], cursorPos[1]))
        self.copy()
        self.delete()

        """Move cursor to top-left corner of the selection,
        so that if text gets pasted again, original text will be restored"""
        self._qpart.cursorPosition = topLeft
973621
def clear_text(self, *args, **selectors):
        
        while True:
            target = self.device(**selectors)
            text = target.info['text']
            target.clear_text()
            remain_text = target.info['text']
            if text == ''  or remain_text == text:
                break
734623
def clean(self, text, **kwargs):
        """"""
        text = stringify(text)
        if text is not None:
            return self.clean_text(text, **kwargs)
334596
def _strip_text(text):
        """"""
        text = re.sub(r'[ ,?:]|%s', "", text.lower())
        for chr in "-%":
            new_text = text.replace(chr, "")
            if new_text:
                text = new_text
        return text.lower()
1001650
def _strip(text):
        """"""
        text = text.strip()
        text = text.replace('  ', ' ')  # remove duplicate spaces
        text = text.lower()
        for joiner in TextTitle.JOINERS:
            text = text.replace(joiner, 'and')
        for article in TextTitle.ARTICLES:
            if text.startswith(article + ' '):
                text = text[len(article) + 1:]
                break
        return text
91720
def clean_text(text):
    
    if text:
        text = html2text.html2text(clean_markdown(text))
        return re.sub(r'\s+', ' ', text).strip()
90795
def insert(self, iter, text, length=-1):
        

        Gtk.TextBuffer.insert(self, iter, text, length)