From bfb75807927578d9224a40bc49802a928c46cfd8 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 18 Oct 2011 17:53:04 +0400 Subject: [PATCH] Add beacons to market service --- service/market.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/service/market.py b/service/market.py index 3c2f57d9b..b9d79e64f 100644 --- a/service/market.py +++ b/service/market.py @@ -17,6 +17,7 @@ # along with pyfa. If not, see . #=============================================================================== +import re import threading import wx @@ -281,7 +282,6 @@ class Market(): 11, # Ammo 1112, # Subsystems 24) # Implants & Boosters - # Tell other threads that Market is at their service mktRdy.set() @@ -667,3 +667,51 @@ class Market(): eos.db.commit() self.priceWorkerThread.trigger(requests, cb) + + def getSystemWideEffects(self): + """ + Get dictionary with system-wide effects + """ + # Container for system-wide effects + effects = {} + # Expressions for matching when detecting effects we're looking for + validgroups = ("Black Hole Effect Beacon", + "Cataclysmic Variable Effect Beacon", + "Magnetar Effect Beacon", + "Pulsar Effect Beacon", + "Red Giant Beacon", + "Wolf Rayet Effect Beacon", + "Incursion Effect") + # Stuff we don't want to see in names + garbages = ("Effect", "Beacon") + # Get group with all the system-wide beacons + grp = self.getGroup("Effect Beacon") + beacons = self.getItemsByGroup(grp) + # Cycle through them + for beacon in beacons: + # Check if it belongs to any valid group + for group in validgroups: + # Check beginning of the name only + if re.match(group, beacon.name): + # Get full beacon name + beaconname = beacon.name + for garbage in garbages: + beaconname = re.sub(garbage, "", beaconname) + beaconname = re.sub(" {2,}", " ", beaconname).strip() + # Get short name + shortname = re.sub(group, "", beacon.name) + for garbage in garbages: + shortname = re.sub(garbage, "", shortname) + shortname = re.sub(" {2,}", " ", shortname).strip() + # Get group name + groupname = group + for garbage in garbages: + groupname = re.sub(garbage, "", groupname) + groupname = re.sub(" {2,}", " ", groupname).strip() + # Add stuff to dictionary + if not groupname in effects: + effects[groupname] = set() + effects[groupname].add((beacon, beaconname, shortname)) + # Break loop on 1st result + break + return effects