From 14ed4bd8888ff71125a6858ca76ba7cfdd0b96a7 Mon Sep 17 00:00:00 2001 From: Jonathan Harris Date: Sun, 29 Sep 2019 18:25:03 +0100 Subject: [PATCH] Revert some non-Python3 related changes --- EDMarketConnector.wxs | 898 ++++++++++++++++++++---------------------- eddb.py | 28 +- outfitting.py | 6 +- setup.py | 12 +- 4 files changed, 453 insertions(+), 491 deletions(-) diff --git a/EDMarketConnector.wxs b/EDMarketConnector.wxs index d3dd5f69..9d7077e2 100644 --- a/EDMarketConnector.wxs +++ b/EDMarketConnector.wxs @@ -113,421 +113,404 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -539,61 +522,58 @@ + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + + + + @@ -601,21 +581,19 @@ - + - - - + - + @@ -629,13 +607,13 @@ - + - + - - + + @@ -650,16 +628,16 @@ - + - + - + - + diff --git a/eddb.py b/eddb.py index a3f07229..eb3f2ad1 100755 --- a/eddb.py +++ b/eddb.py @@ -3,33 +3,18 @@ # build databases from files systems.csv and stations.json from http://eddb.io/api # -import argparse import pickle import csv import json import requests -def load_file(filename): - if filename == 'systems.csv' and args.systems_file: - print('load_file: systems.csv from local file') - return open(args.systems_file, newline='') - elif filename == 'stations.json' and args.stations_file: - print('load_file: stations.json from local file') - stations = [] - with open(args.stations_file) as jsonl_file: - for l in jsonl_file: - stations.append(json.loads(l)) - return stations - else: - raise AssertionError('load_file called with unsupported filename') +def download(filename): + r = requests.get('https://eddb.io/archive/v6/' + filename, stream=True) + print('\n%s\t%dK' % (filename, len(r.content) / 1024)) + return r if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Utilises eddb.io data files to produce... FIXME') - parser.add_argument('-S', '--systems-file', help="Specify a local file copy of eddb.io's systems.csv") - parser.add_argument('-s', '--stations-file', help="Specify a local file copy of eddb.io's stations.json") - args = parser.parse_args() - # Ellipsoid that encompasses most of the systems in the bubble (but not outliers like Sothis) RX = RZ = 260 CY = -50 @@ -61,7 +46,8 @@ if __name__ == "__main__": 'y' : float(s['y']), 'z' : float(s['z']), 'is_populated' : int(s['is_populated']), - } for s in csv.DictReader(load_file('systems.csv')) } + } for s in csv.DictReader(download('systems.csv').iter_lines(decode_unicode=True)) } + #} for s in csv.DictReader(open('systems.csv')) } print('%d\tsystems' % len(systems)) # Build another dict containing all systems considered to be in the @@ -130,7 +116,7 @@ if __name__ == "__main__": print('\n%d saved systems' % len(system_ids)) # station_id by (system_id, station_name) - stations = load_file('stations.json') + stations = json.loads(download('stations.json').content) # let json do the utf-8 decode station_ids = { (x['system_id'], x['name']) : x['id'] # Pilgrim's Ruin in HR 3005 id 70972 has U+2019 quote for x in stations if x['max_landing_pad_size'] diff --git a/outfitting.py b/outfitting.py index 6b381640..061cb4f3 100644 --- a/outfitting.py +++ b/outfitting.py @@ -464,12 +464,8 @@ def lookup(module, ship_map, entitled=False): (new['class'], new['rating']) = (str(name[2][4:]), 'A') elif len(name) < 4 and name[1] in ['guardianfsdbooster']: # Hack! No class. (new['class'], new['rating']) = (str(name[2][4:]), 'H') - elif len(name) < 4 and name[0] == 'dronecontrol' and name[1] == 'resourcesiphon': - # 128066402,Int_DroneControl_ResourceSiphon,internal,Limpet Control,,,,1,I, - (new['class'], new['rating']) = (1, 'I') else: - if len(name) < 3: - raise AssertionError('%s: length < 3]' % (name)) + if len(name) < 3: raise AssertionError('%s: length < 3]' % (name)) if not name[2].startswith('size') or not name[3].startswith('class'): raise AssertionError('%s: Unknown class/rating "%s/%s"' % (module['id'], name[2], name[3])) new['class'] = str(name[2][4:]) new['rating'] = (name[1]=='buggybay' and planet_rating_map or diff --git a/setup.py b/setup.py index 5aad4d19..f8eab66a 100755 --- a/setup.py +++ b/setup.py @@ -8,14 +8,13 @@ Usage: """ from distutils.core import setup -import py2exe - -import platform -import sys +import codecs import os from os.path import exists, isdir, join -import shutil +import platform import re +import shutil +import sys from tempfile import gettempdir from config import appname as APPNAME, applongname as APPLONGNAME, appcmdname as APPCMDNAME, appversion as VERSION @@ -147,6 +146,8 @@ elif sys.platform=='win32': setup( name = APPLONGNAME, + version = VERSION, + app = [APP], windows = [ {'dest_base': APPNAME, 'script': APP, 'icon_resources': [(0, '%s.ico' % APPNAME)], @@ -165,6 +166,7 @@ setup( } ], data_files = DATA_FILES, options = OPTIONS, + setup_requires = [sys.platform=='darwin' and 'py2app' or 'py2exe'], ) PKG = None