MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / fetchPrices

Method fetchPrices

service/marketSources/fuzzwork.py:52–73  ·  view source on GitHub ↗
(priceMap, fetchTimeout, system=None)

Source from the content-addressed store, hash-verified

50
51 @staticmethod
52 def fetchPrices(priceMap, fetchTimeout, system=None):
53 params = {'types': ','.join(str(typeID) for typeID in priceMap)}
54 for k, v in locations.get(system, {}).items():
55 params[k] = v
56 baseurl = 'https://market.fuzzwork.co.uk/aggregates/'
57 network = Network.getInstance()
58 resp = network.get(url=baseurl, type=network.PRICES, params=params, timeout=fetchTimeout)
59 data = resp.json()
60 # Cycle through all types we've got from request
61 for typeID, typeData in data.items():
62 try:
63 typeID = int(typeID)
64 price = float(typeData['sell']['percentile'])
65 except (KeyError, TypeError):
66 continue
67 # Fuzzworks returns 0 when there's no data for item
68 if price == 0:
69 continue
70 if typeID not in priceMap:
71 continue
72 priceMap[typeID].update(PriceStatus.fetchSuccess, price)
73 del priceMap[typeID]
74
75
76Price.register(FuzzworkMarket)

Callers 1

__init__Method · 0.95

Calls 4

itemsMethod · 0.80
getMethod · 0.45
getInstanceMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected