MCPcopy Create free account
hub / github.com/pyfa-org/Pyfa / importPatterns

Method importPatterns

eos/saveddata/targetProfile.py:348–417  ·  view source on GitHub ↗
(cls, text)

Source from the content-addressed store, hash-verified

346
347 @classmethod
348 def importPatterns(cls, text):
349 lines = re.split('[\n\r]+', text)
350 patterns = []
351 numPatterns = 0
352
353 # When we import damage profiles, we create new ones and update old ones. To do this, get a list of current
354 # patterns to allow lookup
355 lookup = {}
356 current = eos.db.getTargetProfileList()
357 for pattern in current:
358 lookup[pattern.rawName] = pattern
359
360 for line in lines:
361 try:
362 if line.strip()[0] == "#": # comments
363 continue
364 line = line.split('#', 1)[0] # allows for comments
365 type, data = line.rsplit('=', 1)
366 type, data = type.strip(), [d.strip() for d in data.split(',')]
367 except (KeyboardInterrupt, SystemExit):
368 raise
369 except:
370 pyfalog.warning("Data isn't in correct format, continue to next line.")
371 continue
372
373 if type not in ("TargetProfile", "TargetResists"):
374 continue
375
376 numPatterns += 1
377 name, dataRes, dataMisc = data[0], data[1:5], data[5:8]
378 fields = {}
379
380 for index, val in enumerate(dataRes):
381 val = float(val) if val else 0
382 if math.isinf(val):
383 val = 0
384 try:
385 assert 0 <= val <= 100
386 fields["%sAmount" % cls.DAMAGE_TYPES[index]] = val / 100
387 except (KeyboardInterrupt, SystemExit):
388 raise
389 except:
390 pyfalog.warning("Caught unhandled exception in import patterns.")
391 continue
392
393 if len(dataMisc) == 3:
394 for index, val in enumerate(dataMisc):
395 try:
396 fieldName = ("maxVelocity", "signatureRadius", "radius")[index]
397 except IndexError:
398 break
399 val = float(val) if val else 0
400 if fieldName != "signatureRadius" and math.isinf(val):
401 val = 0
402 fields[fieldName] = val
403
404 if len(fields) in (4, 7): # Avoid possible blank lines
405 if name.strip() in lookup:

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
saveMethod · 0.80
TargetProfileClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected