MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / run

Method run

service/character.py:56–100  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

54 self.running = True
55
56 def run(self):
57 paths = self.paths
58 sCharacter = Character.getInstance()
59 all5_character = es_Character("All 5", 5)
60 all_skill_ids = []
61 for skill in all5_character.skills:
62 # Parse out the skill item IDs to make searching it easier later on
63 all_skill_ids.append(skill.itemID)
64
65 for path in paths:
66 if not self.running:
67 break
68 try:
69 charFile = open(path, mode='r').read()
70 doc = minidom.parseString(charFile)
71 if doc.documentElement.tagName not in ("SerializableCCPCharacter", "SerializableUriCharacter"):
72 pyfalog.error("Incorrect EVEMon XML sheet")
73 raise RuntimeError("Incorrect EVEMon XML sheet")
74 name = doc.getElementsByTagName("name")[0].firstChild.nodeValue
75 securitystatus = doc.getElementsByTagName("securityStatus")[0].firstChild.nodeValue or 0
76 skill_els = doc.getElementsByTagName("skill")
77 skills = []
78 for skill in skill_els:
79 if int(skill.getAttribute("typeID")) in all_skill_ids and (0 <= int(skill.getAttribute("level")) <= 5):
80 skills.append({
81 "typeID": int(skill.getAttribute("typeID")),
82 "level": int(skill.getAttribute("level")),
83 })
84 else:
85 pyfalog.error(
86 "Attempted to import unknown skill {0} (ID: {1}) (Level: {2})",
87 skill.getAttribute("name"),
88 skill.getAttribute("typeID"),
89 skill.getAttribute("level"),
90 )
91 char = sCharacter.new(name + " (EVEMon)")
92 sCharacter.apiUpdateCharSheet(char.ID, skills, securitystatus)
93 except (KeyboardInterrupt, SystemExit):
94 raise
95 except Exception as e:
96 pyfalog.error("Exception on character import:")
97 pyfalog.error(e)
98 continue
99
100 wx.CallAfter(self.callback)
101
102 def stop(self):
103 self.running = False

Callers

nothing calls this directly

Calls 5

getAttributeMethod · 0.80
newMethod · 0.80
getInstanceMethod · 0.45
appendMethod · 0.45
apiUpdateCharSheetMethod · 0.45

Tested by

no test coverage detected