mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-08 05:20:03 +03:00
Fix for erroneous "Demand: 1" in EDDN output.
This commit is contained in:
parent
bbdacf3a31
commit
750b26ef55
8
bpc.py
8
bpc.py
@ -6,7 +6,7 @@ import codecs
|
||||
import time
|
||||
|
||||
from config import config
|
||||
from companion import commoditymap, bracketmap
|
||||
from companion import categorymap, commoditymap, bracketmap
|
||||
|
||||
def export(data, csv=False):
|
||||
|
||||
@ -25,15 +25,15 @@ def export(data, csv=False):
|
||||
h.write(header)
|
||||
|
||||
for commodity in data['lastStarport']['commodities']:
|
||||
if commodity.get('categoryname') and commodity['categoryname'] != 'NonMarketable':
|
||||
if commodity.get('categoryname') and categorymap.get(commodity['categoryname'], True):
|
||||
h.write(('%s;%s;%s;%s;%s;%s;%s;%s;%s;\n' % (
|
||||
rowheader,
|
||||
commoditymap.get(commodity['name'].strip(), commodity['name'].strip()),
|
||||
commodity.get('sellPrice') and int(commodity['sellPrice']) or '',
|
||||
commodity.get('buyPrice') and int(commodity['buyPrice']) or '',
|
||||
int(commodity['demand']) if commodity.get('demandBracket') else '',
|
||||
int(commodity.get('demand', 0)) if commodity.get('demandBracket') else '',
|
||||
bracketmap.get(commodity.get('demandBracket'), ''),
|
||||
int(commodity['stock']) if commodity.get('stockBracket') else '',
|
||||
int(commodity.get('stock', 0)) if commodity.get('stockBracket') else '',
|
||||
bracketmap.get(commodity.get('stockBracket'), ''),
|
||||
timestamp)).encode('utf-8'))
|
||||
|
||||
|
@ -22,7 +22,9 @@ holdoff = 120 # be nice
|
||||
# Map values reported by the Companion interface to names displayed in-game and recognized by trade tools
|
||||
|
||||
categorymap = { 'Narcotics': 'Legal Drugs',
|
||||
'Slaves': 'Slavery', }
|
||||
'Slaves': 'Slavery',
|
||||
'NonMarketable': False,
|
||||
'Salvage': False, }
|
||||
|
||||
commoditymap= { 'Agricultural Medicines': 'Agri-Medicines',
|
||||
'Atmospheric Extractors': 'Atmospheric Processors',
|
||||
|
8
eddn.py
8
eddn.py
@ -8,7 +8,7 @@ from sys import platform
|
||||
import time
|
||||
|
||||
from config import applongname, appversion, config
|
||||
from companion import commoditymap, bracketmap
|
||||
from companion import categorymap, commoditymap, bracketmap
|
||||
|
||||
upload = 'http://eddn-gateway.elite-markets.net:8080/upload/'
|
||||
schema = 'http://schemas.elite-markets.net/eddn/commodity/1'
|
||||
@ -35,7 +35,7 @@ def export(data, callback):
|
||||
for commodity in commodities:
|
||||
i = i+1
|
||||
callback('Sending %d/%d' % (i, len(commodities)))
|
||||
if commodity.get('categoryname') and commodity['categoryname'] != 'NonMarketable':
|
||||
if commodity.get('categoryname') and categorymap.get(commodity['categoryname'], True):
|
||||
msg = { '$schemaRef': schema,
|
||||
'header': header,
|
||||
'message': {
|
||||
@ -43,9 +43,9 @@ def export(data, callback):
|
||||
'stationName': stationName,
|
||||
'itemName': commoditymap.get(commodity['name'].strip(), commodity['name'].strip()),
|
||||
'buyPrice': int(commodity.get('buyPrice', 0)),
|
||||
'stationStock': int(commodity.get('stock', 0)),
|
||||
'stationStock': commodity.get('stockBracket') and int(commodity.get('stock', 0)),
|
||||
'sellPrice': int(commodity.get('sellPrice', 0)),
|
||||
'demand': int(commodity.get('demand', 0)),
|
||||
'demand': commodity.get('demandBracket') and int(commodity.get('demand', 0)),
|
||||
'timestamp': timestamp,
|
||||
}
|
||||
}
|
||||
|
6
td.py
6
td.py
@ -26,7 +26,7 @@ def export(data):
|
||||
# sort commodities by category
|
||||
bycategory = defaultdict(list)
|
||||
for commodity in data['lastStarport']['commodities']:
|
||||
if commodity.get('categoryname') and commodity.get('categoryname') != 'NonMarketable':
|
||||
if commodity.get('categoryname') and categorymap.get(commodity['categoryname'], True):
|
||||
bycategory[categorymap.get(commodity['categoryname'], commodity['categoryname'])].append(commodity)
|
||||
|
||||
for category in sorted(bycategory):
|
||||
@ -37,9 +37,9 @@ def export(data):
|
||||
commoditymap.get(commodity['name'].strip(), commodity['name'].strip()),
|
||||
commodity.get('sellPrice', 0),
|
||||
commodity.get('buyPrice', 0),
|
||||
int(commodity.get('demand')) if commodity.get('demandBracket') else '',
|
||||
int(commodity.get('demand', 0)) if commodity.get('demandBracket') else '',
|
||||
bracketmap.get(commodity.get('demandBracket'), '?')[0],
|
||||
int(commodity.get('stock')) if commodity.get('stockBracket') else '',
|
||||
int(commodity.get('stock', 0)) if commodity.get('stockBracket') else '',
|
||||
bracketmap.get(commodity.get('stockBracket'), '-')[0],
|
||||
timestamp))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user