def getOrgs(self): self.appHandler.getEvent("GET", urlString=QUERY_STRING) root=parseString(self.appHandler.xml[0].encode('ascii','xmlcharrefreplace')) myNode=root.getElementsByTagName("domains")[0] orgs=XMLHelper.unpickle(XMLHelper._getElementChilds(myNode), 'org', type='list') self.orgs=[] for org in orgs: if org.initialized=='true': self.orgs.append(org)
def testRuleUpgrade(server, option): myHandler = configDataHandler.configDataHandler(server) if option.lower() == 'pre': data = myHandler.getData('rule', pickle=False) myFile = open(FILE_NAME, 'w') myFile.write(data) myFile.close() elif option.lower() == 'post': retData = myHandler.getData('rule') oriData = XMLHelper.unpickleFile(FILE_NAME, 'rules', objType='list') indexData = {} for ori in oriData: indexData[ori.attribute['naturalId']] = ori missKey, extraKey, commonKey = hashUtility.getHashKeys( indexData, retData) if len(missKey): print 'Missing rules: %s' % len(missKey) print '\nMissing rules detail:' for key in missKey: print '%s: %s' % (key, indexData[key].name) if len(extraKey): print 'Extra rules: %s' % len(extraKey) print '\nExtra rules detail:' for key in extraKey: print '%s: %s' % (key, retData[key].name) for key in commonKey: classUtility.compare(indexData[key], retData[key], None) else: print 'option %s is not supported. Exit.' % option
def getCollector(self): self.appHandler.getData(COLLECTOR_QUERY) collectors = XMLHelper.unpickleXml(self.appHandler.xml, EVENT_COLLECTOR, objType=LIST) return collectors
def uixml(scwin, uixslt): extidx = uixslt.rindex('.') xslt2 = uixslt[:extidx] + "Post" + uixslt[extidx:] sctemplate = XMLHelper.writexml(scwin.asXML(True), UnicodeStringIO(), '', '\t', '\n') try: source = DefaultFactory.fromString(sctemplate, "urn:pass1") xsltUri = OsPathToUri(uixslt) transform = DefaultFactory.fromUri(xsltUri) processor = Processor.Processor() processor.appendStylesheet(transform) uixmlstr = processor.run(source) if os.path.exists(xslt2): source = DefaultFactory.fromString(uixmlstr, "urn:pass2") xsltUri = OsPathToUri(xslt2) transform = DefaultFactory.fromUri(xsltUri) processor = Processor.Processor() processor.appendStylesheet(transform) uixmlstr = processor.run(source) except Exception, e: QMessageBox.critical(None, 'Error!', 'Error with XSLT transform!\n\n' + str(e), 'OK') return
def getTestCases(config): testSuiteList=[] for xmlFile in config['testSuiteFiles']: if '.xml' not in xmlFile: xmlFile+=".xml" logging.debug("Processing %s", xmlFile) testTask=config['testTask'] if testTask=="multiCollectors": testTask="eventParsing" fileName="../DataFiles/"+testTask+"/"+xmlFile myRawCase=XMLHelper.unpickleFile(fileName) if not myRawCase: print 'No Test cases presented.' exit() if hasattr(myRawCase, fileName): myRawCase.fileName=xmlFile else: setattr(myRawCase, 'fileName', xmlFile) if config['testTask'] not in ["multiCollectors", "RBAC", "report"]: myCase=changeVaribles(myRawCase, config) else: myCase=myRawCase testSuiteList.append(myCase) myTestCat=autoTestClass.TestCategory() myTestCat.suites=testSuiteList return myTestCat
def saveXML(self, finalData, type, fileName): myNode = XMLHelper.classListToXml(finalData, type) if not '.xml' in fileName: fileName += '.xml' myFile = open(fileName, 'w') myNode.writexml(myFile) myFile.close()
def start(self): ''' Starts the grading session. Checks if the assignment the user asks to grade actually exists. Loads the homeworkspec.xml from the database. Validates it. Uses it for grading. ''' t.p('Grading assignment %s' % self.assigname) t.v('With compile timeout = %d' % self.cto) t.v('With run timeout = %d' % self.rto) t.p("") db = dbm.DAL(connect=True) if Assignments.assigexists(self.assigname, db): sql = 'SELECT {0} FROM {1} WHERE {2}=?'.format(Assignments.f_xml, Assignments.table_name, Assignments.f_assigname) result = db.query(sql, (self.assigname,), fetchone=True) resulttuple = XMLHelper.loadXMLandvalidate(result[0]) if resulttuple[1] == False: # Bad hwspec.xml! t.e('HwSpec validation failed - ' + resulttuple[2], 1) else: t.p('Validation...Success!') self.specobj = resulttuple[0] self.__grade() else: t.e('Assignment %s does not exist!' % self.assigname, 1)
def createXml(self, objList, custId): myDoc = dom.Document() node = XMLHelper.pickle(root=objList, fabric=dom.Document(), elementName='users') node.setAttribute("custId", custId) return node.toxml()
def discoveryDevice(self, ip, type=False): ipAccessList=[] ipAccess=deviceDataClass.ipAccessMapping() ipAccess.ipRange=ip if type: ipAccessMethod=type else: ipAccessMethod=DEFAULT_SNMP_METHOD ipAccessList.append(ipAccess) node=XMLHelper.pickle(root=ipAccessList, fabric=dom.Document(), elementName=IPACCESS_WRAP) self.appHandler.putData(IPACCESS_ADD, node.toxml()) discoveryRanges=[] discoveryRange=deviceDataClass.discoveryIpRange() discoveryRange.name='Discovery'+ip discoveryRange.includeRange=ip discoveryRanges.append(discoveryRange) node1=XMLHelper.pickle(root=discoveryRanges, fabric=dom.Document(), elementName=DISCOVERY_RANGES) self.appHandler.putData(DISCOVER_RUN, node1.toxml())
def classToXml(type, hash): objList=[] obj=_typeToClassObj(type) for name in classUtility.getAttrList(obj): if name in hash.keys(): setattr(obj, name, hash[name]) objList.append(obj) node=XMLHelper.pickle(root=objList, fabric=dom.Document(), elementName=type) myXml=node.toxml() return myXml
def generateFile(self, testSuites): if not os.path.exists(str(self.testFolder)): os.makedirs(str(self.testFolder)) for suite in testSuites: type = self._setType(suite) myXml = XMLHelper.classToXml(suite, type) fileName = self.testFolder + '/' + suite.name + '.xml' output = open(fileName, 'w') output.write(myXml) output.close() setattr(suite, 'detailFile', fileName)
def getEntityValue(self, value): param = ENTITY_VALUE % value param = param.replace('"', '') self.appHandler.getData(param) values = XMLHelper.unpickleXml(self.appHandler.xml, 'entityValues', objType='list') if len(values): self.data = values[0].values else: print 'no data return'
def getDatafromFolder(self, objType, myPath, skipList=[]): fileList = os.listdir(myPath) newFiles = [] for file in fileList: if '.xml' in file and file not in skipList: newFiles.append(file) data = [] for file in newFiles: name = file.split('.')[0] myFile = open(myPath + '/' + file, 'r') text = '' myData = XMLHelper.unpickleXml(data[subkey], types, objType='list')
def getAllRulesfromREST(self): self.appHandler.getData(GET_RULE) #remove extra useless eventFilters entry as '<eventFilters>EventFilter@591783</eventFilters> doc = parseString(self.appHandler.xml) nodes = doc.getElementsByTagName('rules') if len(nodes): for name, element in XMLHelper._getElementChilds(nodes[0]): for subName, subElement in XMLHelper._getElementChilds( element): if subName == 'eventFilters': lastChild = XMLHelper._getElementChilds(subElement) if not len(lastChild): subElement.parentNode.removeChild(subElement) subElement.unlink() rules = XMLHelper.unpickle(XMLHelper._getElementChilds(nodes[0]), type='list') #index with naturalId self.rules = {} for rule in rules: self.rules[rule.attribute['naturalId']] = rule
def getRBACProfile(type): doc = parse(PROFILE_PATH + type + 'Admin.xml') profile = XMLHelper.unpickle(doc.childNodes[0]) myProfile = configModel.RbacProfile() myProfile.name = profile.name myProfile.description = profile.description myProfile.config = profile.config myFilter = configModel.eventFilter() myFilter.singleConstraint = profile.eventFilter.singleConstraint myProfile.eventFilter = myFilter return myProfile
def createQueryTemplate(self, data, numEntry=False, window=False, absolute=False, filter=False): queryList=[] report=queryDataClass.Report() report.attribute['group']=AUTOMATION report.attribute['id']=AUTOMATION report.OrderByClause=data['orderBy'] custScope=queryDataClass.CustomerScope() custScope.attribute['groupByEachCustomer']='true' include=queryDataClass.Include() include.attribute['all']='true' exclude=queryDataClass.Exclude() custScope.Include=include custScope.Exclude=exclude report.CustomerScope=custScope select=queryDataClass.SelectClause() if numEntry: select.attribute['numEntries']=data['numEntries'] else: select.attribute['numEntries']='All' if filter: select.AttrList=data['AttrList'] report.SelectClause=select reportInterval=queryDataClass.ReportInterval() if not absolute: delattr(reportInterval, 'Low') delattr(reportInterval, 'High') myWindow=queryDataClass.Window() if window: myWindow.attribute['unit']=data['unit'] myWindow.attribute['val']=data['val'] else: myWindow.attribute['unit']='Minute' myWindow.attribute['val']='60' reportInterval.Window=myWindow else: delattr(reportInterval, 'Window') reportInterval.Low=data['low'] reportInterval.High=data['high'] report.ReportInterval=reportInterval pattern=queryDataClass.PatternClause() pattern.attribute['window']='3600' subPattern=queryDataClass.SubPattern() subPattern.attribute['displayName']=AUTOMATION subPattern.attribute['name']=AUTOMATION subPattern.SingleEvtConstr=data['SingleEvtConstr'] subPattern.GroupByAttr=data['groupBy'] pattern.SubPattern.append(subPattern) report.PatternClause=pattern queryList.append(report) node=XMLHelper.pickle(root=queryList, fabric=dom.Document(), elementName='Reports') return node.toxml()
def __createDevice(self, deviceData): myDeviceList = [] for device in deviceData: myDevice = self.__createDeviceType(device['type'], device['name'], device['ip'], device['custId']) myDeviceList.append(myDevice) myObj = DeviceModels.discoveryResult("1", "1", myDeviceList) node = XMLHelper.pickle(root=myObj, fabric=dom.Document(), elementName='discoveryResult') return node.toxml()
def classToHash(obj, param=False): myData = {} nameList = getAllAttrList(obj) for name in nameList: subobj = getattr(obj, name) if not isClass(subobj): if getType(subobj) not in ['NoneType', 'list', 'dict']: myData[name] = subobj elif XMLHelper.getType(subobj) == 'dict': myData[name] = subobj elif XMLHelper.getType(subobj) == 'list': subData = [] subData = listToHash(subobj) myData[name] = subData else: myData[name] = '' else: if not param: subData = {} subData = classToHash(subobj) myData[name] = subData return myData
def save(self, filename): itemxml = self.asXML() if itemxml is None: QMessageBox.critical(None, 'Error!', 'There was no item to save!', 'OK') return try: f = file(filename, 'w') except IOError: QMessageBox.critical(None, 'Error!', 'Error opening file: ' + filename, 'OK') return f.write(XMLHelper.writexml(itemxml, UnicodeStringIO(), '', '\t', '\n')) f.close()
def save(self, filename): itemxml = self.asXML() if itemxml is None: QMessageBox.critical(None, 'Error!', 'There was no item to save!', 'OK') return try: f = file(filename, 'w') except IOError: QMessageBox.critical(None, 'Error!', 'Error opening file: ' + filename, 'OK') return f.write(XMLHelper.writexml(itemxml, UnicodeStringIO(), '', '\t', '\n')) f.close()
def getDatafromFile(fileName, objType): if '.xml' not in file: fileName += '.xml' data = [] try: doc = parse(fileName) if objType in TestConstant.objXmlWrap.keys(): keyword = TestConstant.objXmlWrap[objType] else: keyword = generalUtility.getPlural(objType) nodes = doc.getElementsByTagName(keyword) data = XMLHelper.unpickle(nodes[0], type='list') except IOError, e: print 'Cannot open the file %s for parse. Error: %s' % (fileName, e)
def getXML(fileName=False, path=False, report=False): myData = {} if path: myPath = path else: myPath = XML_PATH xmlFileList = [] if fileName: xmlFileList.append(fileName) else: xmlFileList = os.listdir(myPath) for xml in xmlFileList: if '.xml' in xml: doc = parse(myPath + '/' + xml) if report: rules = XMLHelper.unpickle(XMLHelper._getElementChilds( doc.childNodes[0]), type='list', report=True) else: rules = XMLHelper.unpickle(XMLHelper._getElementChilds( doc.childNodes[0]), type='list') for rule in rules: if hasattr(rule, 'active'): if rule.active == '': rule.active = 'true' if 'group' in rule.attribute.keys(): groupNames = rule.attribute['group'].split(',') groupNames.sort() rule.attribute['group'] = ','.join(groupNames) myHash = classToHash.classToHash(rule) myData[rule.attribute['id']] = myHash return myData
def parseOption(self, node): hasElements = False sameElements = True ptag = None for child in node.childNodes: if child.nodeType == Node.ELEMENT_NODE: hasElements = True if ptag and ptag != child.nodeName: sameElements = False ptag = child.nodeName if not node.hasAttribute('type') and not hasElements: val = XMLHelper.getText(node.childNodes) if val.lower() == 'true': return True elif val.lower() == 'false': return False else: try: return int(val) except ValueError: pass try: return float(val) except ValueError: pass return val else: if node.getAttribute('type') == 'dict' or \ (not node.hasAttribute('type') and not sameElements): vals = {} for child in node.childNodes: if child.nodeType == Node.TEXT_NODE: continue nodeName = child.nodeName if len(nodeName) > 3 and nodeName[:3] == 'N__': nodeName = nodeName[3:] elif len(nodeName) >= 2 and nodeName[ 0] == 'L' and nodeName[1].isdigit(): # old style nodeName = nodeName[1:] vals[nodeName] = self.parseOption(child) return vals elif node.getAttribute('type') == 'list' or \ (not node.hasAttribute('type') and sameElements): vals = [] for child in node.childNodes: if child.nodeType == Node.TEXT_NODE: continue vals.append(self.parseOption(child)) return vals
def parseOption(self, node): hasElements = False sameElements = True ptag = None for child in node.childNodes: if child.nodeType == Node.ELEMENT_NODE: hasElements = True if ptag and ptag != child.nodeName: sameElements = False ptag = child.nodeName if not node.hasAttribute('type') and not hasElements: val = XMLHelper.getText(node.childNodes) if val.lower() == 'true': return True elif val.lower() == 'false': return False else: try: return int(val) except ValueError: pass try: return float(val) except ValueError: pass return val else: if node.getAttribute('type') == 'dict' or \ (not node.hasAttribute('type') and not sameElements): vals = {} for child in node.childNodes: if child.nodeType == Node.TEXT_NODE: continue nodeName = child.nodeName if len(nodeName) > 3 and nodeName[:3] == 'N__': nodeName = nodeName[3:] elif len(nodeName) >= 2 and nodeName[0] == 'L' and nodeName[1].isdigit(): # old style nodeName = nodeName[1:] vals[nodeName] = self.parseOption(child) return vals elif node.getAttribute('type') == 'list' or \ (not node.hasAttribute('type') and sameElements): vals = [] for child in node.childNodes: if child.nodeType == Node.TEXT_NODE: continue vals.append(self.parseOption(child)) return vals
def createReportTemplate(data): reportList=[] include=QueryModels.Include() exclude=QueryModels.Exclude() custScope=QueryModels.CustomerScope(include, exclude) attrList=data['attrList'] select=QueryModels.SelectClause(attrList) window=QueryModels.Window() interval=QueryModels.ReportInterval(window) subPattern=QueryModels.SubPattern(data['displayName'], data['filterName'], data['constr'], groupBy) pattern=QueryModels.PatternClause(subPattern) report=QueryModels.Report(data['reportType'], data['group'], data['name'], custScope, data['desc'], select, interval, pattern, data['relevantFilter'], order) reportList.append(report) node=XMLHelper.pickle(root=reportList, fabric=dom.Document(), elementName='Reports') return node.toxml()
def save(self): scfile = os.path.join(SCOptions.getAppDirectory(), 'Spellcraft.xml') if os.access(os.path.dirname(scfile), os.W_OK): try: file = open(scfile, 'w') file.write( XMLHelper.writexml(self.asXML(), UnicodeStringIO(), '', '\t', '\n')) # POSSIBLE ISSUE file.write('\n') file.close() except Exception as ex: print(('Error saving Spellcraft.xml!! ', ex)) pass
def save(self): scfile = os.path.join(ScOptions.getAppDirectory(), 'Spellcraft.xml') if os.access(os.path.dirname(scfile), os.W_OK): try: f = open(scfile, 'w') f.write(XMLHelper.writexml(self.asXML(), UnicodeStringIO(), '', '\t', '\n')) f.write('\n') f.close() except Exception, ex: print 'Error saving Spellcraft.xml!! ', ex pass try: os.chmod(scfile, stat.S_IRUSR | stat.S_IWUSR) except: pass
def save(self): scfile = os.path.join(ScOptions.getAppDirectory(), 'Spellcraft.xml') if os.access(os.path.dirname(scfile), os.W_OK): try: f = open(scfile, 'w') f.write( XMLHelper.writexml(self.asXML(), UnicodeStringIO(), '', '\t', '\n')) f.write('\n') f.close() except Exception, ex: print 'Error saving Spellcraft.xml!! ', ex pass try: os.chmod(scfile, stat.S_IRUSR | stat.S_IWUSR) except: pass
def parseConfigReport(self, filename, scxmldoc): processor = Processor.Processor() source = InputSource.DefaultFactory.fromString( XMLHelper.writexml(scxmldoc, UnicodeStringIO(), '', '\t', '\n'), "uri:sctemplate") try: xsltUri = OsPathToUri(filename) transform = InputSource.DefaultFactory.fromUri(xsltUri) processor.appendStylesheet(transform) self.reportHtml = processor.run(source) except Exception, e: QMessageBox.critical( None, 'Error!', 'Error composing report ' + filename + "\n\n" + str(e), 'OK') return
def __getRule(self, cmd): rule = {} data = self.db.execute(cmd) for item in data: id = item[0] naturalId = item[1] myRule = ruleDataClass.rule() myRule.attribute['id'] = naturalId myRule.attribute['group'] = self.__getGroupName(id) myRule.active = str(item[2]).lower() myRule.Name = item[3] myRule.Description = item[4] eventId = item[10] incident_attr = item[11].replace(' ', '').strip() myCustScope = ruleDataClass.CustomerScope() myCustScope.attribute['groupByEachCustomer'] = str(item[5]).lower() myInclude = ruleDataClass.Include() myInclude.attribute['all'] = str(item[5]).lower() myCustScope.Include = myInclude myRule.CustomerScope = myCustScope myIncidentDef = self.__getIncidentDef(eventId) myIncidentDef.ArgList = incident_attr if myIncidentDef != '': myRule.IncidentDef = myIncidentDef type = XMLHelper.getType(item[8]) if type != 'NoneType': globalConstr = item[8].replace(' ', '').strip() else: globalConstr = '' myPattern = self.__getRulePattern(str(item[6]), RULE_FILTER_ID, id, item[7], globalConstr) myRule.PatternClause = myPattern myTrigger = ruleDataClass.TriggerEventDisplay() myTrigger.AttrList = item[9].replace(' ', '').strip() myRule.TriggerEventDisplay = myTrigger myClear = self.__getClear(id) if myClear != '': myRule.ClearCondition = myClear myHash = classToHash.classToHash(myRule) rule[naturalId] = myHash return rule
def getAllDevices(self, app=False): tagName='' if app: self.appHandler.getData(APP_QUERY) tagName=APP else: self.appHandler.getData(DEVICE_QUERY) tagName=DEV devices=XMLHelper.unpickleXml(self.appHandler.xml, tagName, type=LIST) deviceData={} for dev in devices: myHash=classToHash.classToHash(dev) if app==APP_SNMP: key=dev.accessIp+' '+dev.name else: key=dev.accessIp deviceData[key]=myHash return deviceData
def getQuery(self, appServer, singleConstr, groups=False, orders=False, outputs=False, timeUnit=False, timeValue=False, filter=False, module=False, absTimes=False, timeLow=False, timeHigh=False): inXml=self.createQueryXml(singleConstr, groupBy=groups, orderBy=orders, outputConstr=outputs, timeUnits=timeUnit, timeVal=timeValue, filter=filter, module=module, absolute=absTimes, lowTime=timeLow, highTime=timeHigh) logging.debug(inXml) myHandler=appHandler(appServer) myHandler.getQuery(inXml) myQuery=[] for data in myHandler.queryXml: subQuery='' logging.debug(data) subQuery=XMLHelper.unpickleXml(data, 'events', objType='list') for subData in subQuery: myQuery.append(subData) myRet=[] for data in myQuery: resultHash=classToHash.classToHash(data) myDic=hashMethod1(resultHash['attributes']) myRet.append(myDic) self.data=myRet
def __getData(self, name, module='config', pickle=True): myParam = module + '/' + name self.appHandler.getData(myParam) if pickle: if name in TestConstant.obj_name_trans.keys(): keyWord = TestConstant.obj_name_trans[name] else: keyWord = name if keyWord in TestConstant.obj_xml_wrap.keys(): pickKey = TestConstant.obj_xml_wrap[keyWord] else: pickKey = generalUtility.getPlural(keyWord) data = XMLHelper.unpickleXml(self.appHandler.xml, pickKey, objType='list') else: data = self.appHandler.xml return data
def __getRole(self, cmd): role = {} data = self.db.execute(cmd) for item in data: filterId = item[3] myRole = roleDataClass.Role() myRole.Name = item[0] naturalId = ROLE_ID[myRole.Name] myRole.attribute['id'] = naturalId myRole.Description = item[1] doc = parseString(item[2]) myProfile = XMLHelper.unpickle(doc.childNodes[0]) myConfig = roleDataClass.Config() myConfig.profile = myProfile myRole.Config = myConfig myRole.SingleEvtConstr = self.__getRoleConstr(filterId) myHash = classToHash.classToHash(myRole) role[naturalId] = myHash return role
def loadFromXML(self, itemnode, namehint = '', convert = False): slots = {} for child in itemnode.childNodes: if child.nodeType == Node.TEXT_NODE: continue if child.tagName == 'SLOT': slotval = child.getAttribute("Number") itemslot = self.itemslots[int(slotval)] slottype = child.getAttribute("Type") if slottype is not None and slottype != '': itemslot.setSlotType(slottype) for attr in child.childNodes: if attr.nodeType == Node.TEXT_NODE: continue val = XMLHelper.getText(attr.childNodes) if itemslot.__dict__.has_key(attr.tagName): itemslot.setAttr(attr.tagName, val) itemslot.fixEffect() elif child.tagName == 'CLASSRESTRICTIONS': for classnode in child.childNodes: if classnode.nodeType == Node.TEXT_NODE: continue val = XMLHelper.getText(classnode.childNodes) val = val.strip() if len(val) > 0: self.CLASSRESTRICTIONS.append(val) elif child.tagName[-4:] == "ITEM": # Legacy nested DROPITEM/PLAYERITEM slots type = string.lower(child.tagName[:-4]) slots[type] = self.makeSlots(type) if len(slots[type]) == 0: slots.pop(type) slotnum = -1 found = False for slot in child.childNodes: if slot.nodeType == Node.TEXT_NODE: continue slot_match = re.compile("SLOT(\d+)").match(slot.tagName) if slot_match is None: slotval = slot.getAttribute("Number") if slotval is None or slotval == '': slotnum = slotnum + 1 else: slotnum = int(slotval) else: slotnum = int(slot_match.group(1)) for attr in slot.childNodes: if attr.nodeType == Node.TEXT_NODE: continue val = XMLHelper.getText(attr.childNodes) itemslot = slots[type][slotnum] if itemslot.__dict__.has_key(attr.tagName): itemslot.setAttr(attr.tagName, val) if itemslot.type() != 'Unused': found = True itemslot.fixEffect() if not (convert or found): slots.pop(type) elif self.__dict__.has_key(child.tagName): #if child.tagName == 'ItemName': # print 'ItemName' #print XMLHelper.getText(child.childNodes) setattr(self, child.tagName, XMLHelper.getText(child.childNodes)) #exec('%s = "%s"' % (self.attrs[child.tagName], # XMLHelper.getText(child.childNodes))) if child.tagName == 'ActiveState': self.itemslots = self.makeSlots() elif child.tagName == 'TemplateIndex': self.TemplateIndex = int(self.TemplateIndex) if len(slots) > 0: if slots.has_key(self.ActiveState): self.itemslots = slots[self.ActiveState] self.itemslots = slots.pop(self.ActiveState) if len(slots) > 0: self.next = self.copy() type = slots.keys()[0] self.next.Equipped = '0' self.next.ActiveState = type self.next.itemslots = slots[type] if self.ActiveState == 'player': self.ItemName = '' if self.next.ActiveState == 'player': self.next.ItemName = '' item = self while item: if item.ActiveState == 'player' and len(item.ItemName) == 0: item.ItemName = 'Crafted Item' + namehint elif len(item.ItemName) == 0: item.ItemName = 'Drop Item' + namehint item = item.next