1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

Handle non-ASCII Cmdr and ship names in command-line output

This commit is contained in:
Jonathan Harris 2017-11-17 18:10:39 +00:00
parent b860b85d91
commit 44f3025cc6
2 changed files with 8 additions and 9 deletions

View File

@ -118,7 +118,7 @@ def export(data, filename=None):
# Construct description
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']:
if not slot:
string += '\n'

View File

@ -1,4 +1,5 @@
from collections import OrderedDict
import csv
from sys import platform
from functools import partial
import time
@ -141,11 +142,10 @@ def status(data):
def export_status(data, filename):
h = open(filename, 'wt')
h.write('Category,Value\n')
h = csv.writer(open(filename, 'wb'))
h.writerow(['Category', 'Value'])
for thing in status(data):
h.write(','.join(thing) + '\n')
h.close()
h.writerow([x.encode('utf-8') for x in thing])
# 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]
def export_ships(data, filename):
h = open(filename, 'wt')
h.write('Id,Ship,Name,System,Station,Value\n')
h = csv.writer(open(filename, 'wb'))
h.writerow(['Id', 'Ship', 'Name', 'System', 'Station', 'Value'])
for thing in ships(data):
h.write(','.join(thing) + '\n')
h.close()
h.writerow([x.encode('utf-8') for x in thing])
class StatsDialog():