docs: def change_text(self,
  	                text,
  	                fname,
  	                pattern=None,
  	                before=False,
  	                force=False,
  	                delete=False,
  	                note=None,
  	                replace=False,
  	                line_oriented=True,
  	                create=True,
  	                loglevel=logging.DEBUG):
  
  		"""Change text in a file.
  
  		Returns None if there was no match for the regexp, True if it was matched
  		and replaced, and False if the file did not exist or there was some other
  		problem.
  
  		@param text:          Text to insert.
  		@param fname:         Filename to insert text to
  		@param pattern:       Regexp for a line to match and insert after/before/replace.
  		                      If none, put at end of file.
  		@param before:        Whether to place the text before or after the matched text.
  		@param force:         Force the insertion even if the text is in the file.
  		@param delete:        Delete text from file rather than insert
  		@param replace:       Replace matched text with passed-in text. If nothing matches, then append.
  		@param note:          See send()
  		@param line_oriented: Consider the pattern on a per-line basis (default True).
  		                      Can match any continuous section of the line, eg 'b.*d' will match the line: 'abcde'
  		                      If not line_oriented, the regexp is considered on with the flags re.DOTALL, re.MULTILINE
  		                      enabled
  		"""
  		shutit = self.shutit
  		shutit.handle_note(note)
  		fexists = self.file_exists(fname)
  		if not fexists:
  			if create:
  				self.send(ShutItSendSpec(self,
  				                         send=' command touch ' + fname,
  				                         echo=False,
  				                         loglevel=loglevel,
  				                         ignore_background=True))
  			else:
  				shutit.fail(fname + ' does not exist and create=False') # pragma: no cover
  		if replace:
  			# If replace and no pattern FAIL
  			if not pattern:
  				shutit.fail('replace=True requires a pattern to be passed in') # pragma: no cover
  			# If replace and delete FAIL
  			if delete:
  				shutit.fail('cannot pass replace=True and delete=True to insert_text') # pragma: no cover
  		# ftext is the original file's text. If base64 is available, use it to
  		# encode the text
  		if self.command_available('base64'):
  			if shutit_global.shutit_global_object.ispy3:
  				ftext = bytes(self.send_and_get_output(' command base64 ' + fname,
  				                                       echo=False,
  				                                       loglevel=loglevel),
  				                                       shutit_global.shutit_global_object.default_encoding)
  			else:
  				ftext = self.send_and_get_output(' command base64 ' + fname,
  				                                 echo=False,
  				                                 loglevel=loglevel)
  			ftext = base64.b64decode(ftext)
  		else:
  			# Replace the file text's ^M-newlines with simple newlines
  			if shutit_global.shutit_global_object.ispy3:
  				ftext = bytes(self.send_and_get_output(' command cat ' + fname,
  				                                       echo=False,
  				                                       loglevel=loglevel),
  				                                       shutit_global.shutit_global_object.default_encoding)
  				ftext = ftext.replace(bytes('\r\n', shutit_global.shutit_global_object.default_encoding),bytes('\n', shutit_global.shutit_global_object.default_encoding))
  			else:
  				ftext = self.send_and_get_output(' command cat ' + fname,
  				                                 echo=False,
  				                                 loglevel=loglevel)
  				ftext = ftext.replace('\r\n','\n')
  		# Delete the text
  		if delete:
  			if shutit_global.shutit_global_object.ispy3:
  				loc = ftext.find(bytes(text,shutit_global.shutit_global_object.default_encoding))
  			else:
  				loc = ftext.find(text)
  			if loc == -1:
  				# No output - no match
  				return None
  			else:
  				new_text = ftext[:loc] + ftext[loc+len(text)+1:]
  		else:
  			if pattern != None:
  				if not line_oriented:
  					if not shutit_util.check_regexp(pattern):
  						shutit.fail('Illegal regexp found in change_text call: ' + pattern) # pragma: no cover
  					# cf: http://stackoverflow.com/questions/9411041/matching-ranges-of-lines-in-python-like-sed-ranges
  					if shutit_global.shutit_global_object.ispy3:
  						sre_match = re.search(bytes(pattern,shutit_global.shutit_global_object.default_encoding),ftext,re.DOTALL|re.MULTILINE)
  					else:
  						sre_match = re.search(pattern,ftext,re.DOTALL|re.MULTILINE)
  					if replace:
  						if sre_match is None:
  							cut_point = len(ftext)
  							newtext1 = ftext[:cut_point]
  							newtext2 = ftext[cut_point:]
  						else:
  							cut_point = sre_match.start()
  							cut_point_after = sre_match.end()
  							newtext1 = ftext[:cut_point]
  							newtext2 = ftext[cut_point_after:]
  					else:
  						if sre_match is None:
  							# No output - no match
  							return None
  						elif before:
  							cut_point = sre_match.start()
  							# If the text is already there and we're not forcing it, return None.
  							if shutit_global.shutit_global_object.ispy3:
  								if not force and ftext[cut_point-len(text):].find(bytes(text,shutit_global.shutit_global_object.default_encoding)) > 0:
  									return None
  							else:
  								if not force and ftext[cut_point-len(text):].find(text) > 0:
  									return None
  						else:
  							cut_point = sre_match.end()
  							# If the text is already there and we're not forcing it, return None.
  							if shutit_global.shutit_global_object.ispy3:
  								if not force and ftext[cut_point:].find(bytes(text,shutit_global.shutit_global_object.default_encoding)) > 0:
  									return None
  							else:
  								if not force and ftext[cut_point:].find(text) > 0:
  									return None
  						newtext1 = ftext[:cut_point]
  						newtext2 = ftext[cut_point:]
  				else:
  					if shutit_global.shutit_global_object.ispy3:
  						lines = ftext.split(bytes('\n',shutit_global.shutit_global_object.default_encoding))
  					else:
  						lines = ftext.split('\n')
  					cut_point   = 0
  					line_length = 0
  					matched     = False
  					if not shutit_util.check_regexp(pattern):
  						shutit.fail('Illegal regexp found in change_text call: ' + pattern) # pragma: no cover
  					for line in lines:
  						#Help the user out to make this properly line-oriented
  						pattern_before=''
  						pattern_after=''
  						if not pattern or pattern[0] != '^':
  							pattern_before = '^.*'
  						if not pattern or pattern[-1] != '$':
  							pattern_after = '.*$'
  						new_pattern = pattern_before+pattern+pattern_after
  						if shutit_global.shutit_global_object.ispy3:
  							match = re.search(bytes(new_pattern,shutit_global.shutit_global_object.default_encoding), line)
  						else:
  							match = re.search(new_pattern, line)
  						line_length = len(line)
  						if match != None:
  							matched=True
  							break
  						# Update cut point to next line, including newline in original text
  						cut_point += line_length+1
  					if not replace and not matched:
  						# No match, return none
  						return None
  					if replace and not matched:
  						cut_point = len(ftext)
  					elif not replace and not before:
  						cut_point += line_length
  					# newtext1 is everything up to the cutpoint
  					newtext1 = ftext[:cut_point]
  					# newtext2 is everything after the cutpoint
  					newtext2 = ftext[cut_point:]
  					# if replacing and we matched the output in a line, then set newtext2 to be everything from cutpoint's line end
  					if replace and matched:
  						newtext2 = ftext[cut_point+line_length:]
  					elif not force:
  						# If the text is already there and we're not forcing it, return None.
  						if shutit_global.shutit_global_object.ispy3:
  							if before and ftext[cut_point-len(text):].find(bytes(text,shutit_global.shutit_global_object.default_encoding)) > 0:
  								return None
  							if not before and ftext[cut_point:].find(bytes(text,shutit_global.shutit_global_object.default_encoding)) > 0:
  								return None
  						else:
  							if before and ftext[cut_point-len(text):].find(text) > 0:
  								return None
  							if not before and ftext[cut_point:].find(text) > 0:
  								return None
  					# Add a newline to newtext1 if it is not already there
  					if shutit_global.shutit_global_object.ispy3:
  						if newtext1 and bytes(newtext1.decode(shutit_global.shutit_global_object.default_encoding)[-1],shutit_global.shutit_global_object.default_encoding) != bytes('\n',shutit_global.shutit_global_object.default_encoding):
  							newtext1 += bytes('\n',shutit_global.shutit_global_object.default_encoding)
  					else:
  						if newtext1 and newtext1[-1] != '\n':
  							newtext1 += '\n'
  					# Add a newline to newtext2 if it is not already there
  					if shutit_global.shutit_global_object.ispy3:
  						if newtext2 and bytes(newtext2.decode(shutit_global.shutit_global_object.default_encoding)[0],shutit_global.shutit_global_object.default_encoding) != bytes('\n',shutit_global.shutit_global_object.default_encoding):
  							newtext2 = bytes('\n',shutit_global.shutit_global_object.default_encoding) + newtext2
  					else:
  						if newtext2 and newtext2[0] != '\n':
  							newtext2 = '\n' + newtext2
  			else:
  				# Append to file absent a pattern.
  				cut_point = len(ftext)
  				newtext1 = ftext[:cut_point]
  				newtext2 = ftext[cut_point:]
  			# If adding or replacing at the end of the file, then ensure we have a newline at the end
  			if shutit_global.shutit_global_object.ispy3:
  				if newtext2 == b'' and text and bytes(text[-1],shutit_global.shutit_global_object.default_encoding) != bytes('\n',shutit_global.shutit_global_object.default_encoding):
  					newtext2 = bytes('\n',shutit_global.shutit_global_object.default_encoding)
  			else:
  				if newtext2 == '' and text and text[-1] != '\n':
  					newtext2 = '\n'
  			if shutit_global.shutit_global_object.ispy3:
  				new_text = newtext1 + bytes(text,shutit_global.shutit_global_object.default_encoding) + newtext2
  			else:
  				new_text = newtext1 + text + newtext2
  		self.send_file(fname,
  		               new_text,
  		               truncate=True,
  		               loglevel=loglevel)
  		shutit.handle_note_after(note=note)
  		return True