Add beacons to market service

This commit is contained in:
DarkPhoenix
2011-10-18 17:53:04 +04:00
parent 3ff6835cbb
commit bfb7580792

View File

@@ -17,6 +17,7 @@
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
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