mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-05 01:43:16 +03:00
Handle non-ASCII Cmdr and ship names in command-line output
This commit is contained in:
parent
b860b85d91
commit
44f3025cc6
@ -118,7 +118,7 @@ def export(data, filename=None):
|
|||||||
|
|
||||||
# Construct description
|
# Construct description
|
||||||
ship = ship_map.get(data['ship']['name'].lower(), data['ship']['name'])
|
ship = ship_map.get(data['ship']['name'].lower(), data['ship']['name'])
|
||||||
string = '[%s]\n' % (data['ship'].get('shipName') and ', '.join([ship, data['ship']['shipName']]) or ship)
|
string = '[%s]\n' % (data['ship'].get('shipName') and ', '.join([ship, data['ship']['shipName'].encode('utf-8')]) or ship)
|
||||||
for slot in ['H', 'L', 'M', 'S', 'U', None, 'BH', 'RB', 'TM', 'FH', 'EC', 'PC', 'SS', 'FS', None, 'MC', None, '9', '8', '7', '6', '5', '4', '3', '2', '1']:
|
for slot in ['H', 'L', 'M', 'S', 'U', None, 'BH', 'RB', 'TM', 'FH', 'EC', 'PC', 'SS', 'FS', None, 'MC', None, '9', '8', '7', '6', '5', '4', '3', '2', '1']:
|
||||||
if not slot:
|
if not slot:
|
||||||
string += '\n'
|
string += '\n'
|
||||||
|
15
stats.py
15
stats.py
@ -1,4 +1,5 @@
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
import csv
|
||||||
from sys import platform
|
from sys import platform
|
||||||
from functools import partial
|
from functools import partial
|
||||||
import time
|
import time
|
||||||
@ -141,11 +142,10 @@ def status(data):
|
|||||||
|
|
||||||
|
|
||||||
def export_status(data, filename):
|
def export_status(data, filename):
|
||||||
h = open(filename, 'wt')
|
h = csv.writer(open(filename, 'wb'))
|
||||||
h.write('Category,Value\n')
|
h.writerow(['Category', 'Value'])
|
||||||
for thing in status(data):
|
for thing in status(data):
|
||||||
h.write(','.join(thing) + '\n')
|
h.writerow([x.encode('utf-8') for x in thing])
|
||||||
h.close()
|
|
||||||
|
|
||||||
|
|
||||||
# Returns id,name,shipName,system,station,value
|
# Returns id,name,shipName,system,station,value
|
||||||
@ -165,11 +165,10 @@ def ships(data):
|
|||||||
return [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], str(ship['value']['total'])) for ship in ships if ship]
|
return [ (str(ship['id']), ship_map.get(ship['name'].lower(), ship['name']), ship.get('shipName', ''), ship['starsystem']['name'], ship['station']['name'], str(ship['value']['total'])) for ship in ships if ship]
|
||||||
|
|
||||||
def export_ships(data, filename):
|
def export_ships(data, filename):
|
||||||
h = open(filename, 'wt')
|
h = csv.writer(open(filename, 'wb'))
|
||||||
h.write('Id,Ship,Name,System,Station,Value\n')
|
h.writerow(['Id', 'Ship', 'Name', 'System', 'Station', 'Value'])
|
||||||
for thing in ships(data):
|
for thing in ships(data):
|
||||||
h.write(','.join(thing) + '\n')
|
h.writerow([x.encode('utf-8') for x in thing])
|
||||||
h.close()
|
|
||||||
|
|
||||||
|
|
||||||
class StatsDialog():
|
class StatsDialog():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user