Skip to content

Commit

Permalink
Whitespace/indent cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Apr 30, 2015
1 parent 6ea2deb commit 95de1cf
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 54 deletions.
4 changes: 1 addition & 3 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
Expand Down
2 changes: 1 addition & 1 deletion commands/buy_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion commands/import_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
######################################################################
# Helpers


######################################################################
# Perform query and populate result set

Expand Down
2 changes: 1 addition & 1 deletion commands/local_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion commands/market_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion commands/nav_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions commands/olddata_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions commands/sell_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
26 changes: 13 additions & 13 deletions commands/update_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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',
),
Expand Down Expand Up @@ -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)
)


Expand All @@ -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",
Expand All @@ -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)
]
Expand Down Expand Up @@ -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:
Expand Down
42 changes: 21 additions & 21 deletions prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,7 +68,7 @@ def dumpPrices(
SELECT COUNT(*)
FROM StationItem
WHERE station_id = {}
""".format(stationID))
""".format(stationID))
if not cur.fetchone()[0]:
getBlanks = True

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def makeUnit(value):
return "{:>5.01f}{}".format(unitSize, unit)
unitSize /= 1024
return None


def rateVal(bytes, duration):
"""
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 95de1cf

Please sign in to comment.