<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def puts(*args, **kwargs):
 	""" 	Full feature printing function featuring 	trimming and padding for both files and ttys 	"""


	# parse kwargs
	trim    = kwargs.pop('trim', False)
	padding = kwargs.pop('padding', None)
	stream  = kwargs.pop('stream', sys.stdout)

	# HACK: check if stream is IndentedFile
	indent = getattr(stream, 'indent', 0)

	# stringify args
	args = [str(i) for i in args]

	# helpers
	def trimstr(ansi, width):
		string = ''; size = 0; i = 0

		while i < len(ansi):
			mobj = re.match(ANSI_PATTERN, ansi[i:])
			if mobj:
				# append ansi code
				string = string + mobj.group(0)
				i += len(mobj.group(0))
			else:
				# loop for more ansi codes even at max width
				size += 1
				if size > width: break

				# append normal char
				string = string + ansi[i]
				i += 1
		return (string, size)

	# process strings
	if not stream.isatty():
		# remove ansi codes and print
		for string in args:
			stream.write(re.sub(ANSI_PATTERN, '', string) + '\n')
	else:
		# get terminal width
		try: curses.setupterm()
		except:
			trim = False
			padding = None
		else:
			width = curses.tigetnum('cols') - indent

		for string in args:
			if trim or padding:
				trimmed, size = trimstr(string, width)

			# trim string
			if trim:
				if len(trimmed) < len(string):
					trimmed = trimstr(string, width - 3)[0] + colorama.Style.RESET_ALL + '...'
				string = trimmed

			# add padding
			if padding:
				string += padding * (width - size)

			# print final string
			stream.write(string + '\n')