diff --git a/service/port/dna.py b/service/port/dna.py index d4661c1b8..98d4d0bee 100644 --- a/service/port/dna.py +++ b/service/port/dna.py @@ -38,7 +38,7 @@ from service.market import Market pyfalog = Logger(__name__) -def importDna(string): +def importDna(string, fitName=None): sMkt = Market.getInstance() ids = list(map(int, re.findall(r'\d+', string))) @@ -65,7 +65,10 @@ def importDna(string): f.ship = Ship(sMkt.getItem(int(info[0]))) except ValueError: f.ship = Citadel(sMkt.getItem(int(info[0]))) - f.name = "{0} - DNA Imported".format(f.ship.item.name) + if fitName is None: + f.name = "{0} - DNA Imported".format(f.ship.item.name) + else: + f.name = fitName except UnicodeEncodeError: def logtransform(s_): if len(s_) > 10: diff --git a/service/port/port.py b/service/port/port.py index f078a8279..4b5a34e07 100644 --- a/service/port/port.py +++ b/service/port/port.py @@ -236,8 +236,14 @@ class Port(object): return "EFT", (cls.importEft(lines),) # Check if string is in DNA format - if re.match("\d+(:\d+(;\d+))*::", firstLine): + dnaPattern = "\d+(:\d+(;\d+))*::" + if re.match(dnaPattern, firstLine): return "DNA", (cls.importDna(string),) + dnaChatPattern = "{})>(?P[^<>]+)".format(dnaPattern) + m = re.match(dnaChatPattern, firstLine) + if m: + return "DNA", (cls.importDna(m.group("dna"), fitName=m.group("fitName")),) + # Assume that we import stand-alone abyssal module if all else fails if activeFit is not None: @@ -262,8 +268,8 @@ class Port(object): # DNA-related methods @staticmethod - def importDna(string): - return importDna(string) + def importDna(string, fitName=None): + return importDna(string, fitName=fitName) @staticmethod def exportDna(fit, callback=None):