diff --git a/CHANGES.txt b/CHANGES.txt index e42128d7..17016b99 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,7 +2,20 @@ TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014 ============================================================================== -v6.3.1 [wip] +WIP: +. (kfsone) buy, sell, nav and local now have consistent presentation + of each station's distance from the star, labelled "StnLs", while + interstellar distances are labelled "DistLy". + +v6.3.1 Dec 28 2014 +. (kfsone) Removed '--supply' from "update" completely, +. (kfsone) Improved the "--ls-penalty" from a flat line to a curve, + so really, stupidly, ridiculously distant stations (looking at you, + Alpha centauri) really have to be mind-blowing to show up. +. (kfsone) "run" command output shows score of routes, +. (kfsone) "misc/add-station" now has a "-u" option for updates, +. (kfsone) "misc/add-station" no-longer writes to the csv file + (after adding stations do: trade.py export --table Station) . (kfsone) Fixed #111 import not rebuilding cache . (kfsone) "maddavo" plugin is now much smarter - will try to download a smaller prices file, diff --git a/commands/buy_cmd.py b/commands/buy_cmd.py index b553113f..b1bd6622 100644 --- a/commands/buy_cmd.py +++ b/commands/buy_cmd.py @@ -37,11 +37,6 @@ default=None, type=int, ), - ParseArgument('--ages', - help='Show age of data.', - default=False, - action='store_true', - ), MutuallyExclusiveGroup( ParseArgument('--price-sort', '-P', help='(When using --near) Sort by price not distance', @@ -64,9 +59,6 @@ def run(results, cmdenv, tdb): from commands.commandenv import ResultRow - if cmdenv.ages and not cmdenv.quiet: - print("--ages is now enabled by default.") - item = tdb.lookupItem(cmdenv.item) cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID) @@ -157,7 +149,7 @@ def run(results, cmdenv, tdb): results.rows.sort(key=lambda result: result.stock, reverse=True) results.rows.sort(key=lambda result: result.price) if nearSystem and not cmdenv.sortByPrice: - results.summary.sort = "Dist" + results.summary.sort = "Ly" results.rows.sort(key=lambda result: result.dist) limit = cmdenv.limit or 0 @@ -184,11 +176,13 @@ def render(results, cmdenv, tdb): key=lambda row: '{:n}'.format(row.stock) if row.stock >= 0 else '?') if cmdenv.nearSystem: - stnRowFmt.addColumn('Dist', '>', 6, '.2f', + stnRowFmt.addColumn('DistLy', '>', 6, '.2f', key=lambda row: row.dist) stnRowFmt.addColumn('Age/days', '>', 7, '.2f', key=lambda row: row.age) + stnRowFmt.addColumn("StnLs", '>', 10, + key=lambda row: row.station.distFromStar()) stnRowFmt.addColumn("Pad", '>', '3', key=lambda row: TradeDB.padSizes[row.station.maxPadSize]) diff --git a/commands/local_cmd.py b/commands/local_cmd.py index 4de1c532..ee225c02 100644 --- a/commands/local_cmd.py +++ b/commands/local_cmd.py @@ -94,13 +94,8 @@ def run(results, cmdenv, tdb): age = "{:7.2f}".format(ages[station.ID]) except: age = "-" - if station.lsFromStar: - ls = '{}ls'.format(station.lsFromStar) - else: - ls = '?' rr = ResultRow( station=station, - ls=ls, age=age, ) row.stations.append(rr) @@ -139,8 +134,8 @@ def render(results, cmdenv, tdb): ColumnFormat("Station", '<', 32, key=lambda row: row.station.str()) ).append( - ColumnFormat("Dist", '>', '10', - key=lambda row: row.ls) + ColumnFormat("StnLs", '>', '10', + key=lambda row: row.station.distFromStar()) ).append( ColumnFormat("Age/days", '>', 7, key=lambda row: row.age) diff --git a/commands/olddata_cmd.py b/commands/olddata_cmd.py index c3a24121..9302159f 100644 --- a/commands/olddata_cmd.py +++ b/commands/olddata_cmd.py @@ -163,15 +163,15 @@ def render(results, cmdenv, tdb): ) if cmdenv.nearSystem: - rowFmt.addColumn('Dist', '>', 6, '.2f', + rowFmt.addColumn('DistLy', '>', 6, '.2f', key=lambda row: math.sqrt(row.dist2)) rowFmt.append( ColumnFormat("Age/days", '>', '8', '.2f', key=lambda row: row.age) ).append( - ColumnFormat("Ls/Star", '>', '10', - key=lambda row: row.ls) + ColumnFormat("StnLs", '>', '10', + key=lambda row: row.station.distFromStar()) ).append( ColumnFormat("Pad", '>', '3', key=lambda row: \ diff --git a/commands/sell_cmd.py b/commands/sell_cmd.py index 03b6f415..e7725e59 100644 --- a/commands/sell_cmd.py +++ b/commands/sell_cmd.py @@ -32,11 +32,6 @@ default=None, type=int, ), - ParseArgument('--ages', - help='Show age of data.', - default=False, - action='store_true', - ), ParseArgument('--price-sort', '-P', help='(When using --near) Sort by price not distance', action='store_true', @@ -51,9 +46,6 @@ def run(results, cmdenv, tdb): from commands.commandenv import ResultRow - if cmdenv.ages and not cmdenv.quiet: - print("--ages is now enabled by default.") - item = tdb.lookupItem(cmdenv.item) cmdenv.DEBUG0("Looking up item {} (#{})", item.name(), item.ID) @@ -167,11 +159,13 @@ def render(results, cmdenv, tdb): stnRowFmt.addColumn('Demand', '>', 10, key=lambda row: '{:n}'.format(row.demand) if row.demand >= 0 else '?') if cmdenv.nearSystem: - stnRowFmt.addColumn('Dist', '>', 6, '.2f', + stnRowFmt.addColumn('DistLy', '>', 6, '.2f', key=lambda row: row.dist) stnRowFmt.addColumn('Age/days', '>', 7, '.2f', key=lambda row: row.age) + stnRowFmt.addColumn('StnLs', '>', 10, + key=lambda row: row.station.distFromStar()) stnRowFmt.addColumn("Pad", '>', '3', key=lambda row: TradeDB.padSizes[row.station.maxPadSize]) diff --git a/commands/update_cmd.py b/commands/update_cmd.py index d966a1cf..3a6f8ae3 100644 --- a/commands/update_cmd.py +++ b/commands/update_cmd.py @@ -268,8 +268,7 @@ def editUpdate(tdb, cmdenv, stationID): absoluteFilename = None dbFilename = tdb.dbFilename try: - elementMask = prices.Element.basic - if cmdenv.supply: elementMask |= prices.Element.supply + elementMask = prices.Element.basic | prices.Element.supply if cmdenv.timestamps: elementMask |= prices.Element.timestamp if cmdenv.all: elementMask |= prices.Element.blanks # Open the file and dump data to it. @@ -372,6 +371,30 @@ def guidedUpdate(tdb, cmdenv): saveTemporaryFile(tmpPath) +def uploadUpdated(): + try: + import requests + except ImportError: + if platform.system() == "Windows": + prompt = "C:\ThisDir\>" + else: + prompt = "$" + raise SystemExit("""Missing 'requests' module: + +You don't appear to have the Python module "requests" installed. + +It can be installed with Python's package installer, e.g: + {prompt} pip install requests + +For additional help, consult: + Bitbucket Wiki http://kfs.org/td/wiki + Facebook Group http://kfs.org/td/group + ED Forum Thread http://kfs.org/td/thread +""".format( + prompt=prompt + )) + + ###################################################################### # Perform query and populate result set @@ -392,24 +415,17 @@ def run(results, cmdenv, tdb): if not cmdenv.quiet: print( "NOTE:\n" - ". The Update UI is still somewhat experimental.\n" - ". Press CTRL-C here to abort editing, or else " - "just close the window to save.\n" - ". Use '-q' to hide this message,\n" - ". '-F' to make the update window appear infront " - "of Elite: Dangerous (Windowed),\n" - ". '-A' to force all items to show if stuff is " - "missing from a station.", + ". Press CTRL-C here to abort edit, otherwise " + "just close the update window to save.\n" + ". '-F' makes the window show in-front of the " + "E:D Window.\n" + ". '-A' forces all items to be listed.\n", file=sys.stderr ) guidedUpdate(tdb, cmdenv) - return None - - if not cmdenv.quiet and cmdenv.supply: - print("NOTE: '--supply' (-S) is deprecated.") - - # User specified one of the options to use an editor. - editUpdate(tdb, cmdenv, cmdenv.startStation.ID) + else: + # User specified one of the options to use an editor. + editUpdate(tdb, cmdenv, cmdenv.startStation.ID) return None diff --git a/data/Station.csv b/data/Station.csv index 85cfe80a..4ba15db4 100644 --- a/data/Station.csv +++ b/data/Station.csv @@ -39,7 +39,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size '37 Xi Bootis','Schirba Plant',0,'?','?' '39 Tauri','Porta',0,'?','?' '41 Gamma Serpentis','Abe Landing',0,'?','?' -'44 Chi Draconis','Lawson Camp',0,'?','?' +'44 chi Draconis','Lawson Camp',0,'?','?' '47 Ursae Majoris','Avdeyev Beacon',0,'?','?' '54 G. Antlia','Boas Orbital',0,'?','?' '61 Cygni','Broglie Terminal',26,'?','L' @@ -116,6 +116,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Aknango','Bischoff Dock',0,'?','?' 'Aknango','Pinto Hub',0,'?','?' 'Aknango','Skolem Landing',0,'?','?' +'Akualanu','Hughes Vista',0,'?','?' 'Al Mina','Dana Port',0,'?','?' 'Alacagui','Husband Refinery',0,'N','?' 'Alacarakmo','Julian Survey',0,'?','?' @@ -194,6 +195,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Apala','Popper Port',0,'?','?' 'Apala','Walker Port',0,'?','?' 'Apala','Wilson City',0,'?','?' +'Apathaam','Reamy Dock',0,'?','?' 'Aphra','Beckman Terminal',1961,'Y','?' 'Apoyas','Bloss Hanger',0,'?','M' 'Apoyas','Tomita Port',0,'?','M' @@ -219,8 +221,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Arouca','Shipton Orbital',0,'?','?' 'Arro Naga','Gillekens Gateway',0,'?','?' 'Aruagea','Hornby Colony',14482,'?','?' -'Asellus Primus','Beagle 2 Landing',0,'?','?' -'Asellus Primus','Foster Research Lab',0,'?','?' +'Asellus Primus','Beagle 2 Landing',1210,'N','L' +'Asellus Primus','Foster Research Lab',170,'N','M' 'Asphodel','John Irving Station',195,'N','L' 'Asphodel','Saaviks Sanctuary',0,'?','?' 'Asvienses','Asami City',0,'?','?' @@ -246,19 +248,20 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Atum','Leckie City',0,'?','?' 'Aulendiae','Aleksandrov Colony',11308,'?','M' 'Aulendiae','Drew Colony',11413,'?','M' -'Aulin','Aulin Enterprise',0,'?','?' -'Aulin','Edwards Ring',0,'?','?' +'Aulin','Aulin Enterprise',111,'N','L' +'Aulin','Edwards Ring',334,'N','M' 'Aulin','Kuo City',0,'?','?' 'Aulis','Dezhurov Gateway',0,'?','?' 'Awang','Clark Holdings',0,'?','?' 'Azaladshu','Goddard Outpost',0,'?','?' -'B2 Carinae','Dixon Ring',38136,'?','L' -'B2 Carinae','Herschel City',39836,'?','M' -'B2 Carinae','Hewish Port',34104,'?','M' -'B2 Carinae','Kawasato City',37892,'?','L' -'B2 Carinae','Mechain Vision',37895,'?','L' -'B2 Carinae','Muller Orbital',37282,'?','L' -'B2 Carinae','Secchi Hub',37896,'?','M' +'Aztlan','Tannhauser Gate',0,'?','?' +'b2 Carinae','Dixon Ring',38136,'?','L' +'b2 Carinae','Herschel City',39836,'?','M' +'b2 Carinae','Hewish Port',34104,'?','M' +'b2 Carinae','Kawasato City',37892,'?','L' +'b2 Carinae','Mechain Vision',37895,'?','L' +'b2 Carinae','Muller Orbital',37282,'?','L' +'b2 Carinae','Secchi Hub',37896,'?','M' 'Baga','Shipton Exchange',0,'?','?' 'Bagalis','Borlaug Dock',0,'?','?' 'Bagalis','Evans Platform',0,'?','?' @@ -274,7 +277,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Bakara','Arzachel Colony',0,'?','?' 'Balatu','Haise Dock',0,'?','L' 'Balatu','Parker Enterprise',0,'?','?' -'Baltah''Sine','Baltha''Sine Station',0,'?','?' +'Baltah''sine','Baltha''Sine Station',0,'?','?' 'Barnard''s Star','Boston Base',63,'?','L' 'Barnard''s Star','Levi-Strauss Installation',8,'?','M' 'Barnard''s Star','Miller Depot',38,'?','L' @@ -351,7 +354,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Bhil Mina','Sturckow Dock',0,'?','?' 'Bhil Mina','Thuot Port',0,'?','?' 'Bhil Mina','Zholobov Terminal',0,'?','?' -'Bhodha','Harawi Terminal',0,'?','L' +'bhodha','Harawi Terminal',0,'?','L' 'Bhritzameno','Dalton City',1920,'?','M' 'Bhritzameno','Feynman Terminal',1382,'Y','L' 'Biamoana','Artyukhin Port',0,'?','M' @@ -363,6 +366,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Blata','Gurragchaa Holdings',0,'?','?' 'Blata','Nowak Landing',0,'?','?' 'Blata','Sinclair Orbital',0,'?','?' +'Bobadzihozo','Barr Refinery',0,'?','?' +'Bobadzihozo','Bolkow Colony',0,'?','?' 'Bodb Dearg','Qushji Landing',0,'?','?' 'Bolg','Moxon''s Mojo',0,'?','?' 'Borasetani','Hodgson Vision',0,'?','?' @@ -438,6 +443,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Chaac','Lem Dock',0,'?','?' 'Chacobog','Trinh Enterprise',0,'?','?' 'Chamunda','Gidzenko Ring',0,'?','?' +'Changthini','Walker Platform',0,'?','?' 'Chanii','Lundwall Hub',0,'?','?' 'Chapo','Nachtigal Vision',0,'?','?' 'Chapoyo','Piccard Port',0,'?','?' @@ -483,6 +489,9 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Codorain','Dean Station',1057,'?','M' 'Codorain','Safdie Terminal',736,'?','M' 'Coelrind','Siegel Hanger',0,'?','?' +'Colanja','Garriott Settlement',9952,'?','L' +'Colanja','Teng-Hui Landing',9999,'?','?' +'Colanja','Watson Horizons',9969,'?','M' 'Condovichs','Walters Port',8803,'Y','L' 'Coquim','Evans Settlement',0,'?','?' 'Coquim','Hirayama Installation',0,'?','?' @@ -573,6 +582,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Duberdicus','Bartini Dock',0,'?','?' 'Duberdicus','Bond Park',0,'?','?' 'Duberdicus','Foster Hub',0,'?','?' +'Duronese','Mukai Platform',0,'?','?' 'Duwaredari','Scott Dock',0,'?','?' 'DX 799','Shargin Plant',0,'?','?' 'Edenapel','Yu Market',81,'Y','L' @@ -596,9 +606,9 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Epsilon Eridani','Davies Station',281,'N','L' 'Epsilon Eridani','Fortress Cousens',0,'N','L' 'Epsilon Indi','Mansfield Orbiter',0,'?','?' -'Eranin','Azeban City',0,'?','?' -'Eranin','Azeban Orbital',0,'?','?' -'Eranin','Eranin 4 Survey',0,'?','?' +'Eranin','Azeban City',295,'Y','L' +'Eranin','Azeban Orbital',295,'Y','M' +'Eranin','Eranin 4 Survey',2020,'N','M' 'Eravarenth','Celsius Terminal',2752,'Y','M' 'Eravarenth','Cooper Landing',1904,'Y','M' 'Eravate','Ackerman Market',273,'Y','L' @@ -622,8 +632,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Evergreen','Kazantsev Ring',144,'?','?' 'Evergreen','McCaffrey Enterprise',144,'?','?' 'Farowalan','Bamford City',0,'?','?' -'Faust 3566','Murphy Gateway',0,'?','?' -'Faust 3566','Perry Dock',0,'?','?' +'FAUST 3566','Murphy Gateway',0,'?','?' +'FAUST 3566','Perry Dock',0,'?','?' 'Ferenchia','Melvin Mine',0,'?','?' 'Finteno','Kolmogorov Station',0,'?','?' 'FK5 2550','Jemison Dock',0,'?','?' @@ -652,22 +662,24 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Frigaha','Engle Orbital',75,'N','M' 'Frigaha','Onizuka Landing',136,'N','M' 'Friggirawi','Griffin Station',0,'?','?' +'Frigur','Barba Hub',0,'?','?' +'Frigur','Illy Landing',0,'?','?' 'Fujin','Futen Spaceport',0,'?','?' 'Fular','Kotov Orbital',0,'?','?' 'G 121-8','Brosnan Gateway',0,'?','?' 'G 123-49','Herreshoff Freeport',0,'?','?' 'G 123-49','Jet-Gang',0,'?','?' 'G 139-50','Filipchenko City',7,'N','L' -'G 141-21','Andreas Orbital',0,'?','L' -'G 141-21','Birdseye Dock',0,'?','?' -'G 141-21','Clement Terminal',0,'?','?' -'G 141-21','Collins Enterprise',0,'?','?' -'G 141-21','Feoktistov Enterprise',0,'N','L' -'G 141-21','Kimbrough Enterprise',0,'?','?' -'G 141-21','Ray Orbital',0,'Y','L' -'G 141-21','Tognini Terminal',0,'Y','L' -'G 141-21','Wolf Enterprise',0,'?','?' 'G 14-6','Yamazaki Orbital',0,'?','?' +'G 141-21','Andreas Orbital',31,'?','L' +'G 141-21','Birdseye Dock',987,'?','?' +'G 141-21','Clement Terminal',360,'?','?' +'G 141-21','Collins Enterprise',166,'?','?' +'G 141-21','Feoktistov Enterprise',31,'N','L' +'G 141-21','Kimbrough Enterprise',165,'?','?' +'G 141-21','Ray Orbital',42,'Y','L' +'G 141-21','Tognini Terminal',77,'Y','L' +'G 141-21','Wolf Enterprise',17,'?','?' 'G 175-42','Werber Platform',1153,'Y','L' 'G 180-18','Alexandria Gateway',0,'?','?' 'G 181-6','Thomas Installation',0,'?','?' @@ -683,7 +695,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Gabraceni','Stanley Station',195,'N','L' 'Gamma Doradus','Wang City',40000,'?','?' 'Gamma Mensae','Koch Installation',0,'?','M' -'Gat 2','Thompson Vision',19498,'N','?' +'GAT 2','Thompson Vision',19498,'N','?' 'Gatonese','Shavers''s Claim',0,'?','?' 'GCRV 13292','Walheim Dock',0,'?','?' 'GCRV 4654','Herzfeld Landing',0,'?','?' @@ -714,8 +726,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Gorgon','Burnet City',0,'?','?' 'Gorgon','Ray Hub',0,'?','?' 'GQ Virginis','Garriott Colony',0,'?','?' -'GR 316','Hoyle Point',0,'?','?' -'GR 316','Sucharitkul Settlement',0,'?','?' +'GR 316','Hoyle Point',16795,'N','M' +'GR 316','Sucharitkul Settlement',4,'N','M' 'Grabika','Hermite Horizons',0,'?','?' 'Grabri','Platform',0,'?','?' 'Granthaimi','Parmitano Colony',0,'?','?' @@ -736,7 +748,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Gyton''s Hope','Gyton''s Eyrie',0,'?','?' 'Gyton''s Hope','Iskareen',0,'?','?' 'Gyton''s Hope','Margulies Hub',0,'?','?' -'H Draconis','Brislington',0,'?','?' +'h Draconis','Brislington',0,'?','?' 'Hach','Evans City',0,'?','?' 'Hach','Galilei Station',0,'?','?' 'Hach','Zudov Orbital',0,'?','?' @@ -875,8 +887,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Huokang','Steiner City',0,'?','?' 'Hurukuntak','Bauschinger Terminal',0,'?','?' 'Hyperion','Ivens Ring',0,'?','?' -'I Bootis','Chango Dock',0,'?','?' -'I Bootis','Maher Stellar Research',0,'?','?' +'i Bootis','Chango Dock',1095,'Y','L' +'i Bootis','Maher Stellar Research',20934,'Y','M' 'Icontia','Betancourt Refinery',0,'?','?' 'Igala','Laliberte Camp',0,'?','?' 'Igbirikan','Barratt Hub',0,'?','?' @@ -912,12 +924,12 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'K Camelopardalis','Payette Hub',0,'?','?' 'Kaal','Vercors Station',0,'?','?' 'Kaba','Robinson Station',0,'?','?' -'Kadu Mist','Burroughs City',0,'?','?' -'Kadu Mist','Darnielle Terminal',0,'?','?' -'Kadu Mist','Shosuke Gateway',0,'?','?' -'Kadu Mist','Stephens City',0,'?','?' -'Kadu Mist','Yolen Gateway',0,'?','?' -'Kaha''I','Bohm Station',0,'?','?' +'Kadu mist','Burroughs City',0,'?','?' +'Kadu mist','Darnielle Terminal',0,'?','?' +'Kadu mist','Shosuke Gateway',0,'?','?' +'Kadu mist','Stephens City',0,'?','?' +'Kadu mist','Yolen Gateway',0,'?','?' +'Kaha''i','Bohm Station',0,'?','?' 'Kaiakul','Barlowe Station',0,'?','?' 'Kaliki','Trimble Station',0,'?','?' 'Kaline','Due Station',0,'?','?' @@ -1214,6 +1226,9 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Logoni','Burnell Vision',0,'?','?' 'Logoni','Knight Platform',0,'?','?' 'Lokapuri','McArthur Dock',0,'?','?' +'Lombi','Lubbock Dock',0,'?','?' +'Lombi','Xin Hub',0,'?','?' +'Lombi','Young Hub',0,'?','?' 'Lopu Maris','Garan Settlement',0,'?','?' 'Lopu Maris','Messerschmid Outpost',0,'?','?' 'LP 102-320','Shepard Hub',0,'?','?' @@ -1234,13 +1249,13 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'LP 27-9','Shonin Orbital',0,'?','?' 'LP 280-9','Lewitt Colony',0,'?','?' 'LP 29-188','Smith Enterprise',0,'?','?' +'LP 30-55','Crown Platform',0,'?','?' +'LP 30-55','Reis Dock',0,'?','?' 'LP 302-22','Avicenna City',0,'?','?' 'LP 302-22','Bloomfield Dock',0,'?','?' 'LP 302-22','Carrier Dock',0,'?','?' 'LP 302-22','Fermi Orbital',0,'?','?' 'LP 302-22','Parise Hub',0,'?','?' -'LP 30-55','Crown Platform',0,'?','?' -'LP 30-55','Reis Dock',0,'?','?' 'LP 320-359','Fisher Camp',0,'?','?' 'LP 322-836','Bolotov Port',0,'?','?' 'LP 332-45','Thoreau Station',0,'?','?' @@ -1252,13 +1267,13 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'LP 465-14','Oluwafemi Terminal',0,'?','?' 'LP 48-567','Crown Holdings',0,'?','?' 'LP 48-567','Noakes Hanger',0,'?','?' +'LP 5-88','Hirase Holdings',0,'?','?' +'LP 5-88','Midgley Settlement',0,'?','?' +'LP 5-88','Song Dock',0,'?','?' 'LP 51-17','Archambault Horizons',0,'?','?' 'LP 552-48','Anning Port',0,'?','M' 'LP 552-48','Virtanen Terminal',370,'N','L' 'LP 581-36','McKay Gateway',0,'?','?' -'LP 5-88','Hirase Holdings',0,'?','?' -'LP 5-88','Midgley Settlement',0,'?','?' -'LP 5-88','Song Dock',0,'?','?' 'LP 64-194','Longyear Survey',0,'?','?' 'LP 673-13','Brown Orbital',0,'?','?' 'LP 69-457','Carrier Hub',0,'?','?' @@ -1277,10 +1292,10 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'LP 862-184','Mayr Hanger',156,'?','?' 'LP 862-184','Winne Plant',106,'?','?' 'LP 887-68','Hope Platform',0,'?','?' -'LP 903-21','Avdeyev Settlement',0,'?','?' 'LP 90-39','Guerrero Terminal',0,'?','?' 'LP 90-39','Hermite Hanger',0,'?','?' 'LP 90-39','Robson Terminal',0,'?','?' +'LP 903-21','Avdeyev Settlement',0,'?','?' 'LP 908-11','Huygens Ring',0,'?','?' 'LP 908-11','Smith Hub',0,'?','?' 'LP 908-11','So-Yeon City',0,'?','?' @@ -1379,10 +1394,14 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'LTT 9810','Minkowski Orbital',0,'?','L' 'LTT 9810','Trimble Vision',187,'N','M' 'Lu Pah','Rothfuss Mines',0,'?','?' +'LU Velorum','Alten Gateway',0,'?','?' +'LU Velorum','Card Enterprise',0,'?','?' +'LU Velorum','Miletus Station',0,'?','?' 'Lu Yupik','Bagian Survey',0,'?','?' 'Lu Yupik','Edison Settlement',0,'?','?' 'Lucab Ku','Potter Station',0,'?','?' 'Luchantauo','Dashiell Colony',0,'?','?' +'Luchoer','Truman Reformatory',0,'?','?' 'Luggerates','Stewart Settlement',0,'?','?' 'Lugh','Adamson Enterprise',0,'?','?' 'Lugh','Balandin Gateway',0,'?','?' @@ -1413,6 +1432,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Manathajeri','Bennett Stop',0,'?','?' 'Manathajeri','Lysenko Mine',0,'?','?' 'Mannona','Thornycroft Penal Colony',0,'?','?' +'Mantxe','Carpini Station',0,'?','?' 'Maorsi','Karachkina City',0,'?','?' 'Maramovoy','Melnick Gateway',0,'?','?' 'Marasing','Thiele Enterprise',0,'?','?' @@ -1450,6 +1470,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Mentsuchua','Hulse Holdings',0,'?','M' 'Miao Thixo','Plante Enterprise',0,'?','?' 'Midgard','Rontgen Port',0,'?','?' +'Midgcut','Metcalf Dock',2819,'?','?' 'Mildeptu','Buchli City',115505,'Y','L' 'Mildeptu','Gerst Platform',115505,'?','?' 'Mildeptu','Singer Enterprise',115505,'N','M' @@ -1459,9 +1480,12 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Mizar','Judson Station',160000,'?','?' 'Mokosh','Bethe Station',2500,'?','?' 'Mokosh','Lubin Orbital',0,'?','?' +'Mokowa','Dhawan Outpost',0,'?','?' 'Mombaluma','Bennett Colony',0,'?','?' 'Mombaluma','Hughes-Fulford Terminal',0,'?','?' 'Mombaluma','Leavitt Orbital',0,'?','?' +'Momoirent','Gamow Port',0,'?','?' +'Momoirent','Jahn Dock',0,'?','?' 'Momus Reach','Ralphus',0,'?','?' 'Momus Reach','Tartarus Point',0,'?','?' 'Montet','Seddon Gateway',1542,'?','?' @@ -1497,7 +1521,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Nandjabinja','Brand City',0,'?','?' 'Nandjalato','Dorsett Colony',984,'N','M' 'Nandjalato','Tereshkova Colony',759,'N','M' -'Nang Ta-Khian','Hay Point',0,'?','?' +'Nang Ta-khian','Hay Point',0,'?','?' 'Nangkano','Sarafanov Hub',0,'?','?' 'Narim','Hamuy Colony',0,'?','?' 'Narim','Pond Vision',0,'?','?' @@ -1643,6 +1667,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Path','Carpenter Port',7,'?','M' 'Paul-Friedrichs Star','Paul-Friedrichs Base Camp',0,'?','?' 'Payayan','Mills Park',0,'?','?' +'Pell','Luiken Hub',0,'?','?' 'Pemede','Gidzenko Terminal',0,'?','?' 'Pemede','Gurragchaa Hub',0,'?','?' 'Pemede','Leavitt Orbital',0,'?','?' @@ -1651,6 +1676,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Percunceni','Hulse Vision',533,'N','M' 'Percunceni','Reid Vision',310,'N','M' 'Perendi','Shepherd Installation',0,'?','?' +'Phi Eridani','Hill Survey',0,'?','?' 'Pi Piscis Austrini','Al-Kashi Terminal',96000,'?','?' 'Pi Piscis Austrini','Farghani Hub',96000,'?','?' 'Pi Piscis Austrini','Farghanihub',96000,'?','?' @@ -1658,10 +1684,10 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Pi Piscis Austrini','Louis de Lacaille Terminal',96000,'?','?' 'Pi Piscis Austrini','Taylor Jr. Station',96000,'?','?' 'Pi Piscis Austrini','Ulloa Dock',96000,'?','?' +'Pi-fang','Brooks Estate',0,'?','?' 'Pican','Robinson Prospect',0,'?','?' 'Pices','Knipling Port',0,'?','?' 'Pices','Pontes Port',0,'?','?' -'Pi-Fang','Brooks Estate',0,'?','?' 'Piran','Garcia Gateway',0,'?','?' 'Pliny','Sharman Gateway',0,'?','?' 'PLX 695','Dover',0,'?','?' @@ -1681,6 +1707,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Puskabui','Heng Orbital',0,'?','?' 'Putamasin','Hartog Terminal',0,'?','?' 'Putamasin','Weil Orbital',0,'?','?' +'Qa''wakana','Tall Dock',0,'?','?' 'Quator','Quator Station',0,'?','?' 'Queche','Rutherford Works',0,'?','?' 'Quechua','Crown Ring',0,'?','?' @@ -1700,6 +1727,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Rasalhague','Kidman Terminal',0,'?','M' 'Rasalhague','Vasyutin Dock',291,'Y','L' 'Rataxo','Bus Hub',0,'?','?' +'Raurici','Flammarion Mines',0,'?','?' 'Raurugba','Endate Enterprise',1088,'N','L' 'Raurugba','Jackson Hub',2096,'?','M' 'Raurugba','Ritchey Landing',1457,'?','M' @@ -1710,6 +1738,7 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Reorte','Davies High',0,'?','?' 'Reshas','Banks Port',0,'?','?' 'Reshas','Luiken City',0,'?','?' +'Reynes','Embakasi',0,'?','?' 'Rho Cancri','Hamilton Reserve',0,'?','?' 'Rho Geminorum','Crick Enterprise',11437,'Y','L' 'Rho Geminorum','Drew Gateway',11738,'N','M' @@ -1763,7 +1792,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Ross 705','Ejety City',0,'?','?' 'Ross 709','Reisman Settlement',0,'?','?' 'Ross 720','Raleigh Orbital',0,'?','?' -'Ross 730','Pavlov Settlement',0,'?','?' +'Ross 730','Drebbel City',12,'?','?' +'Ross 730','Pavlov Settlement',5,'?','?' 'Ross 733','Forest Terminal',0,'?','M' 'Ross 733','Schottky Station',0,'?','M' 'Ross 733','Strekalov Gateway',0,'?','L' @@ -1811,6 +1841,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Shoujeman','Baxter Camp',0,'?','?' 'Shouvul','Brady City',0,'?','?' 'Shouvul','Dutton Enterprise',0,'?','?' +'Sibil','Salpeter Vision',0,'?','?' +'Sibil','Very Station',0,'?','?' 'Sigma Bootis','Meikle Platform',0,'?','?' 'Sinann','Jones Point',0,'?','?' 'Sinann','Phillips Arena',0,'?','?' @@ -1865,12 +1897,13 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'StKM 1-626','Dzhanibekov Orbital',0,'?','?' 'StKM 1-626','Fleming City',0,'?','?' 'StKM 1-626','Fujimori Terminal',0,'?','?' -'Styx','Boyle Terminal',0,'?','?' -'Styx','Searfoss Plant',0,'?','?' +'Styx','Boyle Terminal',72,'N','M' +'Styx','Searfoss Plant',646,'N','M' 'Suchagga','Sherrington Platform',251,'?','?' 'Sudz','Divis Enterprise',0,'?','?' 'Sugrivik','Delbruck Dock',0,'?','?' 'Suhte','Cavendish Station',0,'?','?' +'Sun Takush','McNair Gateway',0,'?','?' 'Suraci','Priestley Ring',0,'?','?' 'Surya','Burbank Camp',0,'?','?' 'Susama','Kaku Dock',0,'?','?' @@ -1976,6 +2009,13 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Undadja','McArthur Hanger',0,'?','?' 'Undadja','Rutherford Depot',0,'?','?' 'Uoluskas','Moisuc Dock',0,'?','?' +'Urcia','Bond Port',0,'?','?' +'Urcia','De Kamp Port',0,'?','?' +'Urcia','Fedden City',0,'?','?' +'Urcia','Izumikawa Market',0,'?','?' +'Urcia','Mikulin Dock',0,'?','?' +'Urcia','Millosevich Terminal',0,'?','?' +'Urcia','Sitterly Vision',0,'?','?' 'Uszaa','Clauss Dock',0,'?','?' 'Uszaa','Guest Installation',0,'?','?' 'Uszaa','Patterson Dock',0,'?','?' @@ -2004,8 +2044,8 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'V775 Herculi','Beatty Port',87000,'N','?' 'V775 Herculi','Vlamingh Hub',87120,'?','?' 'V775 Herculi','Vonarburg Enterprise',2396,'?','?' -'V816 Herculis','Hobaugh Hanger',0,'?','?' -'V816 Herculis','Willis Installation',0,'?','?' +'V816 Herculis','Hobaugh Hanger',1060,'N','M' +'V816 Herculis','Willis Installation',1020,'?','?' 'V886 Centauri','Garriott Terminal',775,'N','M' 'V886 Centauri','Tanner City',953,'Y','L' 'V989 Cassiopeiae','Low Works',0,'?','?' @@ -2120,10 +2160,10 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Yaso Kondi','Wheeler Market',0,'?','?' 'Yax Balam','Ivanchenkov Plant',0,'?','?' 'Yax Balam','Kendrick Holdings',0,'?','?' -'Ye''Kuapemas','Hawke''s Progress',0,'?','?' +'Ye''kuapemas','Hawke''s Progress',0,'?','?' 'Yemaia','Hartog Relay',0,'?','?' 'Yen Di','Brown Dock',0,'?','?' -'Yen K''Uie','Siddha Gateway',1099,'?','L' +'Yen K''uie','Siddha Gateway',1099,'?','L' 'Yggdrajang','Schade Platform',0,'?','?' 'Yoruba','Carpenters Terminal',0,'?','?' 'Yota','Baturin Vision',554,'?','M' @@ -2141,6 +2181,9 @@ unq:name@System.system_id,unq:name,ls_from_star,blackmarket,max_pad_size 'Zeessze','Hoyle Fort',491,'?','L' 'Zeessze','Nicollier Hanger',490,'?','L' 'Zeessze','Rosseland Gateway',197,'?','L' +'Zelacanto','Druillet Dock',0,'?','?' +'Zelacanto','Peltier Vision',0,'?','?' +'Zelacanto','Tousey Colony',0,'?','?' 'Zephyrus','Eyo6',0,'?','?' 'Zeta Aquilae','Mohmand Holdings',661,'?','?' 'Zeta Aquilae','Oefelein Plant',404,'?','?' diff --git a/misc/add-station.py b/misc/add-station.py index a4843a76..8ba4d08b 100644 --- a/misc/add-station.py +++ b/misc/add-station.py @@ -17,20 +17,6 @@ class AddStationError(Exception): pass -def grepl(regex, filename): - """ - Search a file for a regex, return -1 if not found, - otherwise returns the line number of the first match. - """ - - lineNo = 0 - with open(filename, "rU") as fh: - for line in fh: - if regex.search(line): - return lineNo - lineNo += 1 - return -1 - def lookupSystem(conn, sysName): cur = conn.cursor() @@ -87,6 +73,7 @@ def addStation( distLs, blackMarket, maxPadSize, + update=False, ): """ Adds a station to the csv and db if not already present. @@ -106,44 +93,16 @@ def addStation( "Unrecognized system {}.".format(sysName) ) - stationID = lookupStation(conn, systemID, stnName) - if stationID: + originalID = lookupStation(conn, systemID, stnName) + if originalID and not update: raise AddStationError( "Station matching {}/{} found in db cache.".format( sysName, stnName, )) - sysCsvName = sysName.replace("'", "''") - stnCsvName = stnName.replace("'", "''") - - # Does it already exist in the .csv file? - grepRe = re.compile(r"'{}','{}',".format( - sysCsvName, stnCsvName - ), re.IGNORECASE - ) - - csvFile = "data/Station.csv" - matchLine = grepl(grepRe, csvFile) - if matchLine >= 0: - raise AddStationError( - "{}/{} found in {} at line {}".format( - sysCsvName, stnCsvName, csvFile, matchLine, - )) - - # Add to the .csv first. - with open(csvFile, "a") as fh: - fh.write("'{}','{}',{},'{}','{}'\n".format( - sysCsvName, - stnCsvName, - distLs, - blackMarket, - maxPadSize, - )) - - # Now insert into the DB. cur = conn.cursor() cur.execute(""" - INSERT INTO Station ( + INSERT OR REPLACE INTO Station ( system_id, name, ls_from_star, @@ -160,7 +119,8 @@ def addStation( stationID = cur.lastrowid conn.commit() - print("ADDED: #{}: {}/{} ls={}, bm={}, pad={}".format( + print("{}: #{}: {}/{} ls={}, bm={}, pad={}".format( + "ADDED" if not originalID else "UPDATED", stationID, sysName, stnName, distLs, blackMarket, maxPadSize, @@ -197,9 +157,15 @@ def main(): sys.argv[1] in ('--help', '-h', '-?', '/?', '/help'): usage() + update = False + args = sys.argv[1:] + if args[0] == '-u': + update = True + args = args[1:] + # Join args together into a string, then break them # apart on /s and remove padding - argStr = ' '.join(sys.argv[1:]).replace('::', '/') + argStr = ' '.join(args).replace('::', '/') values = [ s.strip() for s in argStr.split('/') ] if len(values) < 2: @@ -241,7 +207,7 @@ def main(): "Unrecognized station option: {}".format(val) ) - addStation(conn, values[0], values[1], dist, blackMarket, maxPadSize) + addStation(conn, values[0], values[1], dist, blackMarket, maxPadSize, update=update) if __name__ == "__main__": diff --git a/plugins/maddavo_plug.py b/plugins/maddavo_plug.py index f15f9215..aee9210f 100644 --- a/plugins/maddavo_plug.py +++ b/plugins/maddavo_plug.py @@ -158,16 +158,13 @@ def run(self): tdenv.ignoreUnknown = True - if cacheNeedsRebuild: - tdb = tdb - # Make sure we disconnect from the db - if tdb.conn: - tdb.conn.close() - tdb.conn = tdb.cur = None - tdb.reloadCache() - tdb.load( - maxSystemLinkLy=tdenv.maxSystemLinkLy, - ) + # Let the system decide if it needs to reload-cache + tdb.close() + tdb.reloadCache() + tdb.load( + maxSystemLinkLy=tdenv.maxSystemLinkLy, + ) + tdb.close() # Scan the file for the latest data. firstDate = None @@ -186,6 +183,7 @@ def run(self): for line in fh: if line.startswith('@'): lastStn = line[2:-1] + continue if not line.startswith(' ') or len(line) < minLen: continue m = dateRe.search(line) diff --git a/scripts/trade.bat b/scripts/trade.bat index 4167574c..ee56b963 100644 --- a/scripts/trade.bat +++ b/scripts/trade.bat @@ -10,7 +10,7 @@ rem --== Set default values above to prevent being asked each run ==-- set /P update=Update database from maddavo? (Y\N): if /I not "%update%"=="Y" goto menu :update -..\trade.py import --maddavo --option=stncsv --option=syscsv -v +..\trade.py import --plug=maddavo --option=stncsv --option=syscsv -v echo Update Complete pause :menu @@ -52,4 +52,4 @@ if "%jumps%"=="" set jumps=%DEFAULT_JUMPS% if "%age%"=="" set age=%DEFAULT_AGE% ..\trade.py run --cap=%capacity% --ly=%lightyears% -vvv --cr=%credits% --fr=%location% -MD=%age% --hops %hops% --jum %jumps% pause -goto menu \ No newline at end of file +goto menu diff --git a/tradecalc.py b/tradecalc.py index f491d27b..470690b2 100644 --- a/tradecalc.py +++ b/tradecalc.py @@ -104,13 +104,16 @@ def genSubValues(key): yield key(tr) longestNameLen = max(genSubValues(key=lambda tr: len(tr.name()))) - text = self.str() + ":\n" + text = self.str() + if detail >= 1: + text += " (score: {:f})".format(self.score) + text += "\n" if detail > 1: if detail > 2: text += self.summary() + "\n" hopFmt = " Load from {station}:\n{purchases}" hopStepFmt = (" {qty:>4} x {item:<{longestName}}" - " {eacost:>10n}cr each, {ttlcost:>10n}cr total {age}\n") + " {eacost:>10n}cr each, {ttlcost:>10n}cr total, data from {age}\n") jumpsFmt = (" Jump {jumps}\n") dockFmt = " Unload at {station} => Gain {gain:n}cr ({tongain:n}cr/ton) => {credits:n}cr\n" footer = ' ' + '-' * 76 + "\n" @@ -156,8 +159,14 @@ def makeAge(value): key=lambda tradeOpt: tradeOpt[1] * tradeOpt[0].gainCr, reverse=True): - age = max(trade.srcAge, trade.dstAge) - age = "("+makeAge(max(trade.srcAge, trade.dstAge))+")" + # Are they within 30 minutes of each other? + if abs(trade.srcAge - trade.dstAge) <= (30*60): + age = max(trade.srcAge, trade.dstAge) + age = makeAge(age) + else: + srcAge = makeAge(trade.srcAge) + dstAge = makeAge(trade.dstAge) + age = "{} and {}".format(srcAge, dstAge) purchases += hopStepFmt.format( qty=qty, item=trade.name(), eacost=trade.costCr, @@ -519,11 +528,14 @@ def getBestHops(self, routes, restrictTo=None): # This will amortize for the start/end stations score = trade.gainCr if lsPenalty: - supercruiseKls = dstStation.lsFromStar / 1000 - penalty = lsPenalty * supercruiseKls - if supercruiseKls > 4: - boost = supercruiseKls / 250 - penalty *= boost + # Only want 1dp + cruiseKls = int(dstStation.lsFromStar / 100) / 10 + # Produce a curve that favors distances under 1kls + # positively, starts to penalize distances over 1k, + # and after 4kls starts to penalize aggresively + # http://goo.gl/Otj2XP + penalty = ((cruiseKls ** 2) - cruiseKls) / 3 + penalty *= lsPenalty score *= (1 - penalty) dstID = dstStation.ID try: diff --git a/tradedb.py b/tradedb.py index ba5b1aa2..aa636116 100644 --- a/tradedb.py +++ b/tradedb.py @@ -162,6 +162,18 @@ def name(self): return '%s/%s' % (self.system.name(), self.dbname) + def distFromStar(self): + """Describes the distance from the station to the star.""" + ls = self.lsFromStar + if not ls: + return '?' + if ls < 4000: + return '{:n}'.format(ls) + if ls < 40000: + return '{:.1f}K'.format(ls / 1000) + return '{:.2f}ly'.format(ls / (365*24*60*60)) + + def str(self): return self.dbname