From f4f028b843d0dca08b5f77f38d1e69bf58d3363d Mon Sep 17 00:00:00 2001 From: blitzmann Date: Sat, 7 Feb 2015 22:59:15 -0500 Subject: [PATCH] Fix #258: broken EFT cfg import --- service/port.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/service/port.py b/service/port.py index 600cb4bcc..e3bfe9dd7 100644 --- a/service/port.py +++ b/service/port.py @@ -18,6 +18,7 @@ #=============================================================================== import re +import os import xml.dom from eos.types import State, Slot, Module, Cargo, Fit, Ship, Drone, Implant, Booster @@ -35,7 +36,7 @@ class Port(object): """Service which houses all import/export format functions""" @classmethod - def importAuto(cls, string, sourceFileName=None, activeFit=None, callback=None): + def importAuto(cls, string, path=None, activeFit=None, callback=None): # Get first line and strip space symbols of it to avoid possible detection errors firstLine = re.split("[\n\r]+", string.strip(), maxsplit=1)[0] firstLine = firstLine.strip() @@ -46,8 +47,9 @@ class Port(object): # If we've got source file name which is used to describe ship name # and first line contains something like [setup name], detect as eft config file - if re.match("\[.*\]", firstLine) and sourceFileName is not None: - shipName = sourceFileName.rsplit('.')[0] + if re.match("\[.*\]", firstLine) and path is not None: + filename = os.path.split(path)[1] + shipName = filename.rsplit('.')[0] return "EFT Config", cls.importEftCfg(shipName, string, callback) # If no file is specified and there's comma between brackets, @@ -208,7 +210,7 @@ class Port(object): try: sMkt.getItem(shipname) except: - return + return [] # empty list is expected # If client didn't take care of encoding file contents into Unicode, # do it using fallback encoding ourselves