classifiedString.py 642 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
class ClassifiedString:

	def __init__(self, rawClassifiedString):

		self.__string = ""
		self.__classifiedAsString = ""
		
		parsedLine = rawClassifiedString.split(" - ")
		
		if (len(parsedLine) > 1):
			
			self.__classifiedAsString = parsedLine.pop().rstrip()
			self.__string = " ".join(parsedLine)
			
		else:
			
			exceptionText = "ClassifiedString: Incorrect rawClassifiedString format (%s), must be something like this \"Metallica - metal\"" % (rawClassifiedString.rstrip())
			
			raise Exception(exceptionText)
		
	def string(self):
		
		return self.__string
	
	def classifiedAsString(self):
		
		return self.__classifiedAsString