def assignCurrentlyTraining(self, cObject):
     '''
         Adjusts the currently training skill to 
     '''
     response = self.apiSelect("skillintraining")
     
     response = response.read()
     
     skillintraining = None
     
     for line in response.split("\r\n"):
         if compile(""".*<skillInTraining>(.*)</skillInTraining>.*""").match(line):
             skillintraining = int(compile(""".*<skillInTraining>(.*)</skillInTraining>.*""").match(line).groups()[0])
         
         if compile(""".*<trainingEndTime>(.*)</trainingEndTime>.*""").match(line):
             endtime = compile(""".*<trainingEndTime>(.*)</trainingEndTime>.*""").match(line).groups()[0]
         
         if compile(""".*<trainingStartTime>(.*)</trainingStartTime>.*""").match(line):
             starttime = compile(""".*<trainingStartTime>(.*)</trainingStartTime>.*""").match(line).groups()[0]
         
         if compile(""".*<trainingTypeID>(.*)</trainingTypeID>.*""").match(line):
             skillid = int(compile(""".*<trainingTypeID>(.*)</trainingTypeID>.*""").match(line).groups()[0])
         
         if skillintraining == 1:
             while not cObject.ready:
                 continue # Wait on all the skills to finish parsing
             skill = self.getSkillInDatabase(columns="*", id=skillid)[1]
             cSkill = Skill(id=skill[0], skillpoints=cObject.getSkill(skill[0]).skillpoints, level=cObject.getSkill(skill[0]).level, name=skill[1], rank=skill[2], primary=skill[3], secondary=skill[4], groupname=skill[5], description=skill[6])
             # Special attributes for the currently trainning skill
             cSkill.__setattr__("trainingLevel", (cSkill.level + 1))
             cSkill.__setattr__("EndTime", endtime)
             cSkill.__setattr__("StartTime", starttime)
             cObject.setCurrentlyTraining(cSkill)
    def extract(self, filename=None, **kws):
        '''
            Provide a filename to extract from a file that is located on the hard disk
            Do not provide a filename and the API will be called by default
            
            DEBUG = (.*) allows to build blankslate character for testing
            
            returns a cObject
        '''
        
        cObject = None
        slot = 1
        
        if not kws.has_key("DEBUG"):
            if filename:
                try:
                    charactersheet = open(filename, "r")
                    info = charactersheet.readlines()
                except:
                    print "File does not exist in location %s" % filename
                    charactersheet.close()
                    return None
            else:
                charactersheet = self.apiSelect("charactersheet")
                info = charactersheet.read()

        # Prebuild the cObject
        cObject = Character("Starting Up", characterID=-1, timeUpdated="Sometime Back")
        
        buildingSkills = self.Threading(self.gatherAllBaseSkills, cObject)
        buildingSkills.start()
        
        # default training skill
        cSkill = Skill(id=-1, skillpoints=0, level=0, name="Nothing Training")
        cSkill.__setattr__("trainingLevel", 0)
        cSkill.__setattr__("EndTime", "Finished")
        cSkill.__setattr__("StartTime", "Sometime Ago")
        cObject.setCurrentlyTraining(cSkill)
        
        if not kws.has_key("DEBUG"):
            for line in info.split("\r\n"):
                attribute = compile(""".*<(.*)>(.*)</.*>.*""").match(line)
                if attribute:
                    attribute = list(attribute.groups())
                    
                    # Convert to an integer
                    if attribute[1].isdigit():
                        attribute[1] = int(attribute[1]) 
                    
                    # Added the slot number to the name
                    if attribute[0].startswith("augmentator"):
                        attribute[0] += '%s' % slot
                        if attribute[0] == "augmentatorValue":
                            slot += 1
                    
                    cObject.__setattr__(attribute[0], attribute[1])
                
                if compile(""".*<row typeID="(.*)" skillpoints="(.*)" level="(.*)" />.*""").match(line):
                    while not cObject.ready:
                        continue
                    
                    skillInfo = compile(""".*<row typeID="(.*)" skillpoints="(.*)" level="(.*)" />.*""").match(line).groups()
                    
                    id = int(skillInfo[0])
                    skillpoints = int(skillInfo[1])
                    level = int(skillInfo[2])
                    
                    if id in cObject.skillset:
                        cObject.editSkill(id, skillpoints=skillpoints, level=level) # If the skill exists, update it
                    else:
                        cObject.addSkill(Skill(id, skillpoints, level)) # if not, build it out
                
                if compile(""".*<row certificateID="(.*)" />.*""").match(line):
                    cObject.editCertificate(compile(""".*<row certificateID="(.*)" />.*""").match(line).groups()[0])
                
                # if the rowset name is in a certain area, change the function being used.match(line)
                if compile(""".*<rowset name="(.*)" key=".*" columns=".*">.*""").match(line):
                    row = compile(""".*<rowset name="(.*)" key=".*" columns=".*">.*""").match(line)
                
                if compile(""".*<row roleID="(.*)" roleName="(.*)" />.*""").match(line):
                    roleInfo = compile(""".*<row roleID="(.*)" roleName="(.*)" />.*""").match(line).groups()
                    
                    if row == "corporationRoles":
                        cObject.corporationRoles(roleInfo[0], roleInfo[1])
                    elif row == "corporationRolesAtHQ":
                        cObject.corporationRolesAtHQ(roleInfo[0], roleInfo[1])
                    elif row == "corporationRolesAtBase":
                        cObject.corporationRolesAtBase(roleInfo[0], roleInfo[1])
                    elif row == "corporationRolesAtOther":
                        cObject.corporationRolesAtOther(roleInfo[0], roleInfo[1])
                
                if compile(""".*<row titleID="(.*)" titleName="(.*)" />.*""").match(line):
                    titleInfo = compile(""".*<row titleID="(.*)" titleName="(.*)" />.*""").match(line).groups()
                    cObject.corporationRoles(titleInfo[0], titleInfo[1])
                
            if filename:
                charactersheet.close()
            else:
                print "extracting"
                buildingSkills = self.Threading(self.assignCurrentlyTraining, cObject)
                buildingSkills.start()
        
        return cObject