From 95de1cf78bd8e071ab4e2e220801f101eabe21ac Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Wed, 29 Apr 2015 00:09:10 -0700 Subject: [PATCH] Whitespace/indent cleanup --- cache.py | 4 +--- commands/buy_cmd.py | 2 +- commands/import_cmd.py | 1 - commands/local_cmd.py | 2 +- commands/market_cmd.py | 2 +- commands/nav_cmd.py | 2 +- commands/olddata_cmd.py | 4 ++-- commands/sell_cmd.py | 16 ++++++++-------- commands/update_cmd.py | 26 ++++++++++++------------- prices.py | 42 ++++++++++++++++++++--------------------- transfers.py | 4 ++-- 11 files changed, 51 insertions(+), 54 deletions(-) diff --git a/cache.py b/cache.py index c133b3b8..88338ba9 100644 --- a/cache.py +++ b/cache.py @@ -789,9 +789,7 @@ def processItemLine(matches): if localAdd > 0: tdenv.NOTE( "Placeholder stations are added to the local DB only " - "(not the .CSV)." - ) - tdenv.NOTE( + "(not the .CSV).\n" "Use 'trade.py export --table Station' " "if you /need/ to persist them." ) diff --git a/commands/buy_cmd.py b/commands/buy_cmd.py index c4a738ad..0f72af21 100644 --- a/commands/buy_cmd.py +++ b/commands/buy_cmd.py @@ -188,7 +188,7 @@ def sql_query(cmdenv, tdb, queries, mode): ) cmdenv.DEBUG0('SQL: {}', stmt) return tdb.query(stmt, bindValues) - + ###################################################################### # Perform query and populate result set diff --git a/commands/import_cmd.py b/commands/import_cmd.py index 506342c0..5c0eaac3 100644 --- a/commands/import_cmd.py +++ b/commands/import_cmd.py @@ -100,7 +100,6 @@ ###################################################################### # Helpers - ###################################################################### # Perform query and populate result set diff --git a/commands/local_cmd.py b/commands/local_cmd.py index 44b9f324..02b7ffd9 100644 --- a/commands/local_cmd.py +++ b/commands/local_cmd.py @@ -174,7 +174,7 @@ def render(results, cmdenv, tdb): .format(results.summary.ly, results.summary.near.name()) ) - # Compare system names so we can tell + # Compare system names so we can tell maxSysLen = max_len(results.rows, key=lambda row: row.system.name()) sysRowFmt = RowFormat().append( diff --git a/commands/market_cmd.py b/commands/market_cmd.py index b8bc5852..0b7e7007 100644 --- a/commands/market_cmd.py +++ b/commands/market_cmd.py @@ -46,7 +46,7 @@ def render_units(units, level): return '?' levelNames = { -1: '?', 1: 'L', 2: 'M', 3: 'H' } return "{:n}{}".format(units, levelNames[level]) - + def run(results, cmdenv, tdb): origin = cmdenv.startStation diff --git a/commands/nav_cmd.py b/commands/nav_cmd.py index 51580323..257052cd 100644 --- a/commands/nav_cmd.py +++ b/commands/nav_cmd.py @@ -179,7 +179,7 @@ def render(results, cmdenv, tdb): rowFmt.addColumn("JumpLy", '>', '7', '.2f', key=lambda row: row.jumpLy) if cmdenv.detail: - rowFmt.addColumn("Stations", '>', 2, + rowFmt.addColumn("Stations", '>', 2, key=lambda row: len(row.system.stations)) if cmdenv.detail: rowFmt.addColumn("DistLy", '>', '7', '.2f', diff --git a/commands/olddata_cmd.py b/commands/olddata_cmd.py index c3111358..57b1330e 100644 --- a/commands/olddata_cmd.py +++ b/commands/olddata_cmd.py @@ -189,7 +189,7 @@ def render(results, cmdenv, tdb): if not results or not results.rows: raise TradeException("No data found") - # Compare system names so we can tell + # Compare system names so we can tell longestNamed = max(results.rows, key=lambda row: len(row.station.name())) longestNameLen = len(longestNamed.station.name()) @@ -204,7 +204,7 @@ def render(results, cmdenv, tdb): rowFmt.addColumn('DistLy', '>', 6, '.2f', key=lambda row: row.dist ) - + rowFmt.append( ColumnFormat("Age/days", '>', '8', '.2f', key=lambda row: row.age) diff --git a/commands/sell_cmd.py b/commands/sell_cmd.py index 8d7a0717..31a3dbb7 100644 --- a/commands/sell_cmd.py +++ b/commands/sell_cmd.py @@ -116,14 +116,14 @@ def run(results, cmdenv, tdb): whereClause = ' AND '.join(constraints) stmt = """ - SELECT DISTINCT {columns} - FROM {tables} - WHERE {where} - """.format( - columns=','.join(columns), - tables=tables, - where=whereClause - ) + SELECT DISTINCT {columns} + FROM {tables} + WHERE {where} + """.format( + columns=','.join(columns), + tables=tables, + where=whereClause + ) cmdenv.DEBUG0('SQL: {}', stmt) cur = tdb.query(stmt, bindValues) diff --git a/commands/update_cmd.py b/commands/update_cmd.py index e0a2c1eb..427733cc 100644 --- a/commands/update_cmd.py +++ b/commands/update_cmd.py @@ -26,7 +26,7 @@ ParseArgument('starting', help='Name of the station to update.', type=str) ] switches = [ - ParseArgument('--timestamps', '-T', + ParseArgument('--timestamps', '-T', help='[Text editing] Includes timestamps in the update.', action='store_true', default=False, @@ -42,7 +42,7 @@ dest='useDemand', default=False, ), - ParseArgument('--force-na', '-0', + ParseArgument('--force-na', '-0', help="Forces 'unk' supply to become 'n/a' by default", action='store_true', default=False, @@ -96,19 +96,19 @@ default=None, type=str, ), - ParseArgument('--sublime', + ParseArgument('--sublime', help='Like --editor but uses Sublime Text (2 or 3).', action='store_const', const='sublime', dest='editing', ), - ParseArgument('--notepad', + ParseArgument('--notepad', help='Like --editor but uses Notepad.', action='store_const', const='notepad', dest='editing', ), - ParseArgument('--npp', + ParseArgument('--npp', help='Like --editor but uses Notepad++.', action='store_const', const='npp', dest='editing', ), - ParseArgument('--vim', + ParseArgument('--vim', help='Like --editor but uses vim.', action='store_const', const='vim', dest='editing', ), @@ -196,10 +196,10 @@ def getEditorPaths(cmdenv, editorName, envVar, windowsFolders, winExe, nixExe): pass raise CommandLineError( - "ERROR: Unable to locate {} editor.\n" - "Either specify the path to your editor with --editor " - "or set the {} environment variable to point to it." - .format(editorName, envVar) + "ERROR: Unable to locate {} editor.\n" + "Either specify the path to your editor with --editor " + "or set the {} environment variable to point to it." + .format(editorName, envVar) ) @@ -220,7 +220,7 @@ def editUpdate(tdb, cmdenv, stationID): if cmdenv.editing == 'sublime': cmdenv.DEBUG0("Sublime mode") editor = editor or \ - getEditorPaths(cmdenv, + getEditorPaths(cmdenv, "sublime", "SUBLIME_EDITOR", ["Sublime Text 3", "Sublime Text 2"], "sublime_text.exe", @@ -244,7 +244,7 @@ def editUpdate(tdb, cmdenv, stationID): if not editor: # Hack... Hackity hack, hack, hack. # This has a disadvantage in that: we don't check for just "vim" (no .exe) under Windows - vimDirs = [ + vimDirs = [ "Git\\share\\vim\\vim{}".format(vimVer) for vimVer in range(70,75) ] @@ -384,7 +384,7 @@ def guidedUpdate(tdb, cmdenv): print("*** YOUR UPDATES WILL BE SAVED AS {} ***".format( "prices.last" )) - + if tmpPath: saveTemporaryFile(tmpPath) if "EXCEPTIONS" in os.environ: diff --git a/prices.py b/prices.py index cad0d2d4..d4b3418c 100644 --- a/prices.py +++ b/prices.py @@ -47,15 +47,15 @@ def dumpPrices( systems = { ID: name for (ID, name) in cur.execute("SELECT system_id, name FROM System") } stations = { - ID: [ name, systems[sysID] ] - for (ID, name, sysID) - in cur.execute("SELECT station_id, name, system_id FROM Station") + ID: [ name, systems[sysID] ] + for (ID, name, sysID) + in cur.execute("SELECT station_id, name, system_id FROM Station") } categories = { ID: name for (ID, name) in cur.execute("SELECT category_id, name FROM Category") } items = { - ID: [ name, catID, categories[catID] ] - for (ID, name, catID) - in cur.execute("SELECT item_id, name, category_id FROM Item") + ID: [ name, catID, categories[catID] ] + for (ID, name, catID) + in cur.execute("SELECT item_id, name, category_id FROM Item") } # find longest item name @@ -68,7 +68,7 @@ def dumpPrices( SELECT COUNT(*) FROM StationItem WHERE station_id = {} - """.format(stationID)) + """.format(stationID)) if not cur.fetchone()[0]: getBlanks = True @@ -106,10 +106,10 @@ def dumpPrices( """ sql = stmt.format( - stationWhere=stationWhere, - defDemand=defaultDemandVal, - itemJoin=itemJoin, - ) + stationWhere=stationWhere, + defDemand=defaultDemandVal, + itemJoin=itemJoin, + ) if debug: print(sql) cur.execute(sql) @@ -147,16 +147,16 @@ def dumpPrices( levelWidth = 9 outFmt = ( - " {{:<{width}}}" - " {{:>{crwidth}}}" - " {{:>{crwidth}}}" - " {{:>{lvlwidth}}}" - " {{:>{lvlwidth}}}".format( - width=longestNameLen, - crwidth=maxCrWidth, - lvlwidth=levelWidth, - ) - ) + " {{:<{width}}}" + " {{:>{crwidth}}}" + " {{:>{crwidth}}}" + " {{:>{lvlwidth}}}" + " {{:>{lvlwidth}}}".format( + width=longestNameLen, + crwidth=maxCrWidth, + lvlwidth=levelWidth, + ) + ) if withTimes: outFmt += " {}" outFmt += "\n" diff --git a/transfers.py b/transfers.py index 10c85dd0..09ffcd1d 100644 --- a/transfers.py +++ b/transfers.py @@ -73,7 +73,7 @@ def makeUnit(value): return "{:>5.01f}{}".format(unitSize, unit) unitSize /= 1024 return None - + def rateVal(bytes, duration): """ @@ -216,7 +216,7 @@ def get_json_data(url): requests = import_requests() req = requests.get(url, stream=True) - # credit for the progress indicator: + # credit for the progress indicator: # http://stackoverflow.com/a/15645088/257645 totalLength = req.headers.get('content-length') if totalLength is None: