Skip to content

Commit

Permalink
Added TradeEnv.NOTE
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Jan 1, 2015
1 parent de42271 commit 68b6767
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tradeenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ class TradeEnv(object):
"""
Container for a TradeDangerous "environment", which is a
collection of operational parameters.
To print debug lines, use DEBUG<N>, e.g. DEBUG0, which
takes a format() string and parameters, e.g.
DEBUG1("hello, {world}{}", "!", world="world")
is equivalent to:
if tdenv.debug >= 1:
print("#hello, {world}{}".format(
"!", world="world"
))
Use "NOTE" to print remarks which can be disabled with -q.
"""

defaults = {
Expand Down Expand Up @@ -41,6 +55,22 @@ def __DEBUG_DISABLED(*args, **kwargs):
debugFn = __DEBUG_DISABLED
setattr(self, key, debugFn)
return debugFn

if key == "NOTE":
def __NOTE_ENABLED(outText, *args, file=None, **kwargs):
print("NOTE:", outText.format(*args, **kwargs), file=file)

def __NOTE_DISABLED(*args, **kwargs):
pass

# Tried to call "NOTE" but it hasn't been called yet,
if not self.quiet:
noteFn = __NOTE_ENABLED
else:
noteFn = __NOTE_DISABLED
setattr(self, key, noteFn)
return noteFn

return default


0 comments on commit 68b6767

Please sign in to comment.