# Determine compression-method
# =============================

# HUFFMAN-ENCODING
if (args['compression'] == 'h' or args['uncompression'] == 'h'):
	if (args['verbose']):
		print('Encoding-mode is set to HUFFMAN.')
	from huffman import Huffman
	coder = Huffman()

	# Choose built-in omega or generate own?
	if (args['dictionary'] == 'b'):
		if (args['verbose']):
			print('Using build-in dictionary!')
		coder.buildOwn = False
	else:
		if (args['verbose']):
			print('We need to generate / use our own dictionary!')
		if (args['uncompression'] != None):
			try:
				f = open('./'+args['source']+'.huff', 'rb')
				coder.setOmega(pickle.load(f))
			except Exception:
				print('Unable to read huffman-dictionary!')
				print('Please recover it with filename: '+args['source']+'.huff')
				quit()

# RUN-LENGHT-ENCODING
elif (args['compression'] == 'r' or args['uncompression'] == 'r'):
	if (args['verbose']):
#!/usr/bin/env python3


print('Testground EPR_05')
print('Welchen Aufgabenteil moechten Sie testen?');
print('[1|2|3]');
which = input(">> ")

######### AUFGABE 5.2 TESTS #########
if (which == "3"):
	from huffman import Huffman
	Huff = Huffman()
	Huff.buildOwn = True
	print('Geben Sie einen Text zum codieren ein!');
	text = input('>> ');
	encoded = Huff.encode(text)
	print(encoded)
	print('Dekodiert:')
	print(Huff.decode(encoded))
	Huff.verbose()


######### AUFGABE 5.2 TESTS #########
if (which == "2"):
	from rle import RunLenghtEncoding
	rle = RunLenghtEncoding();

	print('Geben Sie einen Text zum codieren ein!');
	text = input('>> ');
	res = rle.encode(text)