We now use EFT-style import/exports for damage profiles.

Also, percentages now shown next to damage amount instead of foot (where notifications are going)
This commit is contained in:
blitzmann
2014-09-03 14:56:44 -04:00
parent 0e10ac3928
commit 035443b4ff
5 changed files with 94 additions and 49 deletions

View File

@@ -21,6 +21,9 @@ import eos.db
import eos.types
import copy
class ImportError(Exception):
pass
class DamagePattern():
instance = None
@classmethod
@@ -68,17 +71,21 @@ class DamagePattern():
current = self.getDamagePatternList()
for pattern in current:
lookup[pattern.name] = pattern
try:
imports = eos.types.DamagePattern.importPatterns(text)
for pattern in imports:
if pattern.name in lookup:
match = lookup[pattern.name]
match.__dict__.update(pattern.__dict__)
else:
eos.db.save(pattern)
eos.db.commit()
except:
pass
imports, num = eos.types.DamagePattern.importPatterns(text)
for pattern in imports:
if pattern.name in lookup:
match = lookup[pattern.name]
match.__dict__.update(pattern.__dict__)
else:
eos.db.save(pattern)
eos.db.commit()
lenImports = len(imports)
if lenImports == 0:
raise ImportError("No patterns found for import")
if lenImports != num:
raise ImportError("%d patterns imported from clipboard; %d had errors"%(num, num-lenImports))
def exportPatterns(self):
patterns = self.getDamagePatternList()