def buildGraph( self, inDir ):
		'''Build the Markov graph for this generator's comic character.
			Args:
				inDir: The directory in which to find the 'transcripts' subdirectory. The 'transcripts' subdirectory is where we will actually look for everything.
		'''
		transcriptDir = os.path.join( inDir, "transcripts" )
		
		for inFileName in os.listdir( transcriptDir ):
			inFileName = os.path.join( transcriptDir, inFileName )
			inFile = open( inFileName, mode="rt" )
			
			idc = idChecker()
			if not idc.checkFile( inFile, inFileName, self.commentMark ):
				six.print_( "Error: File", inFileName, "is not a properly formatted transcript.", file=sys.stderr )
				break;
		
			for line in inFile:
				line = line.partition( self.commentMark )[ 0 ].strip()
				if( len( line ) > 0 ):
					line = line.split()
					speaker = line[ 0 ].rstrip(":").strip()
					if speaker.upper() == self.charLabel:
						dialog = line[1:]
						self.lines.append( dialog )
			
			inFile.close()
			
		self.nodes = dict()
		self.sentenceStarts = []
		previousWord = None
		for line in self.lines:
			if( len( line ) > 0 ):
				for word in line:
					isBold = "*" in word
					isItalic = "/" in word
					isUnderlined = "_" in word
					word = word.strip("*/_") #Remove emphasis
					
					if len( word ) > 0:
						self.numInputWords += 1
						isEnd = ( word.endswith( ( ".", "?", "!", '."', '?"', '!"', ".'", "?'", "!'" ) ) or word == line[ -1 ].strip("*/_") )
						
						if isEnd:
							self.numInputSentences += 1
						
						if word not in self.nodes.keys():
							wordRandomized = ""
							if self.randomizeCapitals:
								for letter in word:
									if self.randomBoolean():
										letter = letter.upper()
									else:
										letter = letter.lower()
									wordRandomized += letter
							else:
								wordRandomized = word
							self.nodes[ word ] = MarkovNode( wordRandomized, word, isEnd )
							
						if not previousWord == None:
							if self.nodes[ previousWord ].isEnd:
								self.sentenceStarts.append( word )
							else:
								self.nodes[ previousWord ].addLink( self.nodes[ word ] )
						else:
							if word not in self.sentenceStarts:
								self.sentenceStarts.append( word )
						
						if isBold:
							self.nodes[ word ].addBold()
						if isItalic:
							self.nodes[ word ].addItalic()
						if isUnderlined:
							self.nodes[ word ].addUnderlined()
						
						if not isBold and not isItalic and not isUnderlined:
							self.nodes[ word ].addNormal()
						
						previousWord = word
from PIL import Image, ImageDraw, ImageFont, ImageStat
from PIL.PngImagePlugin import PngInfo

import pygame
from generator import Generator
from idchecker import idChecker
from markovnode import MarkovNode
from uploader import DrupalUploader, WordPressUploader
import kivy
kivy.require("1.9.1") #my current version as of 2016-09-13. Beware of using older versions.
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics.texture import Texture
import string

idChecker = idChecker()

#Exit statuses
#These are copied from my /usr/include/sysexits.h. Only statuses possibly relevant to this program were copied.
EX_OK = 0 #No problems
EX_USAGE = 64 #Command line error
EX_DATAERR = 65 #Data format error
EX_NOINPUT = 66 #Input not openable
EX_CANTCREAT = 73 #Can't create output file
EX_NOPERM = 77 #Permission error

class MarkovApp( App ):
	
	class MarkovGUI( Widget ):
		def __init__( self,  **kwargs ):
			'''Initialize the generator object.