Skip to content

Commit

Permalink
removed default to zero, shouldn't be in this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
bgol committed Oct 17, 2014
1 parent aaf6b97 commit ca0d9ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions data/prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
######################################################################
# Main

def dumpPrices(dbFilename, withModified=False, stationID=None, file=None, defaultZero=False, debug=0):
def dumpPrices(dbFilename, withModified=False, stationID=None, file=None, debug=0):
""" Generate a 'prices' list for the given list of stations using data from the DB. """
conn = sqlite3.connect(str(dbFilename)) # so we can handle a Path object too
cur = conn.cursor()
Expand All @@ -42,7 +42,7 @@ def dumpPrices(dbFilename, withModified=False, stationID=None, file=None, defaul
modifiedStamp = "Price.modified"

stationClause = "1" if not stationID else "Station.station_id = {}".format(stationID)
defaultDemandVal = 0 if defaultZero else -1
defaultDemandVal = -1
if priceCount == 0:
# no prices, generate an emtpy one with all items
cur.execute("""
Expand Down
15 changes: 7 additions & 8 deletions trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def editUpdate(args, stationID):
with tmpPath.open("w") as tmpFile:
# Remember the filename so we know we need to delete it.
absoluteFilename = str(tmpPath.resolve())
prices.dumpPrices(args.db, withModified=args.all, file=tmpFile, stationID=stationID, defaultZero=args.zero, debug=args.debug)
prices.dumpPrices(args.db, withModified=args.all, file=tmpFile, stationID=stationID, debug=args.debug)

# Stat the file so we can determine if the user writes to it.
# Use the most recent create/modified timestamp.
Expand Down Expand Up @@ -691,7 +691,7 @@ def lookupSystem(name, intent):
except LookupError:
raise CommandLineError("Unknown {} system/station, '{}'".format(intent, name))


def distanceAlongPill(sc, percent):
"""
Estimate a distance along the Pill using 2 reference systems
Expand All @@ -701,14 +701,14 @@ def distanceAlongPill(sc, percent):
dotProduct = (sb.posX-sa.posX) * (sc.posX-sa.posX) \
+ (sb.posY-sa.posY) * (sc.posY-sa.posY) \
+ (sb.posZ-sa.posZ) * (sc.posZ-sa.posZ)
length = math.sqrt((sb.posX-sa.posX) * (sb.posX-sa.posX)
length = math.sqrt((sb.posX-sa.posX) * (sb.posX-sa.posX)
+ (sb.posY-sa.posY) * (sb.posY-sa.posY)
+ (sb.posZ-sa.posZ) * (sb.posZ-sa.posZ))
if percent:
return 100. * dotProduct / length / length

return dotProduct / length

def localCommand(args):
"""
Local systems
Expand Down Expand Up @@ -945,7 +945,7 @@ def main():
ParseArgument('--ly-per', help='Maximum light years per jump.', metavar='N.NN', type=float, dest='maxLyPer'),
]
)

# "local" shows systems local to given system.
localParser = makeSubParser(subparsers, 'local', 'Calculate local systems.', localCommand,
arguments = [
Expand Down Expand Up @@ -993,12 +993,11 @@ def main():
"The format is intended to closely resemble the presentation of the market in-game. If you change the order items are listed in, "
"the order will be kept for future edits, making it easier to quickly check for changes.",
arguments = [
ParseArgument('station', help='Name of the station to update.', type=str)
ParseArgument('station', help='Name of the station to update.', type=str)
],
switches = [
ParseArgument('--editor', help='Generates a text file containing the prices for the station and loads it into the specified editor.', default=None, type=str, action=EditAction),
ParseArgument('--all', help='Generates the temporary file with all columns and new timestamp.', action='store_true', default=False),
ParseArgument('--zero', help='Default to 0 for demand/stock values.', action='store_true', default=False),
[ # Mutually exclusive group:
ParseArgument('--sublime', help='Like --editor but uses Sublime Text (2 or 3), which is nice.', action=EditActionStoreTrue),
ParseArgument('--notepad', help='Like --editor but uses Notepad.', action=EditActionStoreTrue),
Expand Down
2 changes: 1 addition & 1 deletion tradedb.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ def lookupStation(self, name, system=None):
# If we only matched a system name, ensure that it's a single station system
# otherwise they need to specify a station name.
if len(system.stations) != 1:
raise SystemNotStationError("System '%s' has %d stations, please specify a station instead." % (system.name(), len(system.stations)))
raise SystemNotStationError("System '%s' has %d stations, please specify a station instead." % (name, len(system.stations)))
return system.stations[0]


Expand Down

0 comments on commit ca0d9ed

Please sign in to comment.