tradedangerous 10.16.10__py3-none-any.whl → 10.16.11__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tradedangerous might be problematic. Click here for more details.

tradedangerous/cache.py CHANGED
@@ -919,7 +919,7 @@ def buildCache(tdb, tdenv):
919
919
 
920
920
  tdenv.NOTE(
921
921
  "Rebuilding cache file: this may take a few moments.",
922
- file = sys.stderr
922
+ stderr=True,
923
923
  )
924
924
 
925
925
  dbPath = tdb.dbPath
@@ -963,7 +963,7 @@ def buildCache(tdb, tdenv):
963
963
  tdenv.NOTE(
964
964
  "Missing \"{}\" file - no price data.",
965
965
  pricesPath,
966
- file = sys.stderr,
966
+ stderr=True,
967
967
  )
968
968
 
969
969
  tempDB.commit()
@@ -218,7 +218,7 @@ class ImportPlugin(plugins.ImportPluginBase):
218
218
  self.execute('COMMIT')
219
219
  self.tdb.close()
220
220
  # Need to make sure cached tables are updated
221
- for table in [ "Item", "Station", "System", "StationItem" ]:
221
+ for table in [ "Item", "Station", "System" ]:
222
222
  _, path = csvexport.exportTableToFile( self.tdb, self.tdenv, table )
223
223
 
224
224
  self.print(
@@ -1,18 +1,44 @@
1
- from __future__ import absolute_import, with_statement, print_function, division, unicode_literals
1
+ # The runtime environment TD tools are expected to run with is encapsulated
2
+ # into a single object, the TradeEnv. See TradeEnv docstring for more.
3
+ from __future__ import annotations
2
4
 
3
5
  import os
4
- import traceback
5
6
  import sys
7
+ import traceback
8
+ import typing
9
+ from contextlib import contextmanager
10
+
11
+ # Import some utilities from the 'rich' library that provide ways to colorize and animate
12
+ # the console output, along with other useful features.
13
+ # If the user has 'EXCEPTIONS' defined to something in the environment, then we can
14
+ # immediately benefit from beautified stacktraces.
15
+ from rich.console import Console
16
+ from rich.traceback import install as install_rich_traces
17
+
18
+
19
+ if typing.TYPE_CHECKING:
20
+ from typing import Any, Dict, Iterator
21
+
22
+
6
23
  _ROOT = os.path.abspath(os.path.dirname(__file__))
7
24
 
8
25
 
9
- class TradeEnv(object):
26
+ # Create a single instance of the console for everyone to use, unless they really
27
+ # want to do something unusual.
28
+ CONSOLE = Console()
29
+ STDERR = Console(stderr=True)
30
+
31
+ if os.getenv("EXCEPTIONS"):
32
+ # This makes call stacks show additional context and do syntax highlighting
33
+ # that can turn reading a callstack from hours into seconds.
34
+ install_rich_traces(console=STDERR, show_locals=False, extra_lines=1)
35
+
36
+
37
+ class TradeEnv:
10
38
  """
11
- Container for a TradeDangerous "environment", which is a
12
- collection of operational parameters.
39
+ Container for a TradeDangerous "environment", which is a collection of operational parameters.
13
40
 
14
- To print debug lines, use DEBUG<N>, e.g. DEBUG0, which
15
- takes a format() string and parameters, e.g.
41
+ To print debug lines, use DEBUG<N>, e.g. DEBUG0, which takes a format() string and parameters, e.g.
16
42
 
17
43
  DEBUG1("hello, {world}{}", "!", world="world")
18
44
 
@@ -35,51 +61,90 @@ class TradeEnv(object):
35
61
  'csvDir': os.environ.get('TD_CSV') or os.environ.get('TD_DATA') or os.path.join(os.getcwd(), 'data'),
36
62
  'tmpDir': os.environ.get('TD_TMP') or os.path.join(os.getcwd(), 'tmp'),
37
63
  'templateDir': os.path.join(_ROOT, 'templates'),
38
- 'cwDir': os.getcwd()
64
+ 'cwDir': os.getcwd(),
65
+ 'console': CONSOLE,
66
+ 'stderr': STDERR,
39
67
  }
40
68
 
41
69
  encoding = sys.stdout.encoding
70
+
42
71
  if str(sys.stdout.encoding).upper() != 'UTF-8':
43
-
44
- def uprint(self, *args, **kwargs):
72
+ def uprint(self, *args, stderr: bool = False, style: str = None, **kwargs) -> None:
73
+ """ unicode-handling print: when the stdout stream is not utf-8 supporting,
74
+ we do a little extra io work to ensure users don't get confusing unicode
75
+ errors. When the output stream *is* utf-8, tradeenv replaces this method
76
+ with a less expensive method.
77
+ :param stderr: report to stderr instead of stdout
78
+ :param style: specify a 'rich' console style to use when the stream supports it
79
+ """
80
+ console = self.stderr if stderr else self.console
45
81
  try:
46
- print(*args, **kwargs)
82
+ # Attempt to print; the 'file' argument isn't spuported by rich, so we'll
83
+ # need to fall-back on old print when someone specifies it.
84
+ console.print(*args, style=style, **kwargs)
85
+
47
86
  except UnicodeEncodeError as e:
87
+ # Characters in the output couldn't be translated to unicode.
48
88
  if not self.quiet:
49
- print(
50
- "CAUTION: Your terminal/console couldn't handle some "
89
+ self.stderr.print(
90
+ "[orange3][bold]CAUTION: Your terminal/console couldn't handle some "
51
91
  "text I tried to print."
52
92
  )
53
93
  if 'EXCEPTIONS' in os.environ:
54
94
  traceback.print_exc()
55
95
  else:
56
- print(str(e))
96
+ self.stderr.print(e)
97
+
98
+ # Try to translate each ary into a viable stirng using utf error-replacement.
57
99
  strs = [
58
- str(arg).
59
- encode(TradeEnv.encoding, errors = 'replace').
60
- decode(TradeEnv.encoding)
100
+ str(arg)
101
+ .encode(TradeEnv.encoding, errors="replace")
102
+ .decode(TradeEnv.encoding)
61
103
  for arg in args
62
104
  ]
63
- print(*strs, **kwargs)
105
+ console.print(*strs, style=style, **kwargs)
64
106
 
65
107
  else:
66
- uprint = print
108
+ def uprint(self, *args, stderr: bool = False, style: str = None, **kwargs) -> None:
109
+ """ unicode-handling print: when the stdout stream is not utf-8 supporting,
110
+ this method is replaced with one that tries to provide users better support
111
+ when a unicode error appears in the wild.
112
+
113
+ :param file: [optional] stream to write to (disables styles/rich support)
114
+ :param style: [optional] specify a rich style for the output text
115
+ """
116
+ console = self.stderr if stderr else self.console
117
+ console.print(*args, style=style, **kwargs)
67
118
 
68
- def __init__(self, properties = None, **kwargs):
69
- properties = properties or dict()
119
+
120
+ def __init__(self, properties: Optional[Union[argparse.Namespace, Dict]] = None, **kwargs) -> None:
121
+ # Inject the defaults into ourselves in a dict-like way
70
122
  self.__dict__.update(self.defaults)
71
- if properties:
72
- self.__dict__.update(properties.__dict__)
73
- if kwargs:
74
- self.__dict__.update(kwargs)
75
-
76
- def __getattr__(self, key):
123
+
124
+ # If properties is a namespace, extract the dictionary; otherwise use it as-is
125
+ if properties and hasattr(properties, '__dict__'): # which arparse.Namespace has
126
+ properties = properties.__dict__
127
+ # Merge into our dictionary
128
+ self.__dict__.update(properties or {})
129
+
130
+ # Merge the kwargs dictionary
131
+ self.__dict__.update(kwargs or {})
132
+
133
+ # When debugging has been enabled on startup, enable slightly more
134
+ # verbose rich backtraces.
135
+ if self.__dict__['debug']:
136
+ install_rich_traces(console=STDERR, show_locals=True, extra_lines=2)
137
+
138
+ def __getattr__(self, key: str) -> Any:
77
139
  """ Return the default for attributes we don't have """
140
+
141
+ # The first time the DEBUG attribute is referenced, register a method for it.
78
142
  if key.startswith("DEBUG"):
79
143
 
80
144
  # Self-assembling DEBUGN functions
81
145
  def __DEBUG_ENABLED(outText, *args, **kwargs):
82
- print('#', outText.format(*args, **kwargs))
146
+ # Give debug output a less contrasted color.
147
+ self.console.print(f"[dim]#{outText.format(*args, **kwargs)}[/dim]")
83
148
 
84
149
  def __DEBUG_DISABLED(*args, **kwargs):
85
150
  pass
@@ -96,10 +161,11 @@ class TradeEnv(object):
96
161
 
97
162
  if key == "NOTE":
98
163
 
99
- def __NOTE_ENABLED(outText, *args, file = None, **kwargs):
164
+ def __NOTE_ENABLED(outText, *args, stderr: bool = False, **kwargs):
100
165
  self.uprint(
101
166
  "NOTE:", str(outText).format(*args, **kwargs),
102
- file = file,
167
+ style="bold",
168
+ stderr=stderr,
103
169
  )
104
170
 
105
171
  def __NOTE_DISABLED(*args, **kwargs):
@@ -115,10 +181,11 @@ class TradeEnv(object):
115
181
 
116
182
  if key == "WARN":
117
183
 
118
- def _WARN_ENABLED(outText, *args, file = None, **kwargs):
184
+ def _WARN_ENABLED(outText, *args, stderr: bool = False, **kwargs):
119
185
  self.uprint(
120
186
  "WARNING:", str(outText).format(*args, **kwargs),
121
- file = file
187
+ style="orange3",
188
+ stderr=stderr,
122
189
  )
123
190
 
124
191
  def _WARN_DISABLED(*args, **kwargs):
tradedangerous/version.py CHANGED
@@ -12,5 +12,5 @@
12
12
  """just keeper of current version"""
13
13
 
14
14
  # TODO: remember to update tests when version changes
15
- __version__ = '10.16.10'
15
+ __version__ = '10.16.11'
16
16
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tradedangerous
3
- Version: 10.16.10
3
+ Version: 10.16.11
4
4
  Summary: Trade-Dangerous is a set of powerful trading tools for Elite Dangerous, organized around one of the most powerful trade run optimizers available.
5
5
  Home-page: https://github.com/eyeonus/Trade-Dangerous
6
6
  Author: eyeonus
@@ -1,5 +1,5 @@
1
1
  tradedangerous/__init__.py,sha256=5ZeypoZaM8hlh6c-yTkD8x5hZYP8q3Q8a3bVeicHr90,1122
2
- tradedangerous/cache.py,sha256=MIoNCWE3AJohhx0r4m5xgf4C_4YkynWgfJyUokhuG98,33859
2
+ tradedangerous/cache.py,sha256=PvXo4EaKVUcU-h5akCFQpClK_zVxNu0BzGEIJf5ffB0,33848
3
3
  tradedangerous/cli.py,sha256=ycGkzMszwpP9OrngFIyhQbYoZ2wzRhJMTDCW1YhLrNI,4727
4
4
  tradedangerous/corrections.py,sha256=QMs-7MKLw2imFgIHthnwcpqWT1yJTb3CrABJw9LaKLA,1441
5
5
  tradedangerous/csvexport.py,sha256=OcOKe_VIgafw6rCvG3k5tM11KwwoYXMNY5DSSfCC0mU,8705
@@ -16,12 +16,12 @@ tradedangerous/tools.py,sha256=pp-4WtA12SVaaQHFJFOMTF7EDFRCU2mQeOhC4xoXmEk,1331
16
16
  tradedangerous/trade.py,sha256=vBEJZR3Bybesw9FMelcHOTRA7KqKeH-4_wqbJ4VMB_E,1779
17
17
  tradedangerous/tradecalc.py,sha256=GyuYZNuyfn0y0eoPbxDEI7dxTJtHmRXAKFMpiR0Z1iU,42004
18
18
  tradedangerous/tradedb.py,sha256=6JzoSAiW1WJjkWxeGMJkN63GHTBp9RA0dkfRviuEHeM,73515
19
- tradedangerous/tradeenv.py,sha256=FeeSvDI4Zpi5hJk2UAwrR_0Y7Y_gtYH0ofPEHKHLEBY,4412
19
+ tradedangerous/tradeenv.py,sha256=8uByR4m-xzZxNSBLQnDHS4uJMPohf3mP5R_rsXnhmds,7887
20
20
  tradedangerous/tradeexcept.py,sha256=aZ-Y31MbkjF7lmAzBAbaMsPPE7FEEfuf4gaX2GvriDk,368
21
21
  tradedangerous/tradegui.py,sha256=JbGFnsWupgesk6hrcUgKSdD9NNDyo0U9gh6m3DccAwU,782
22
22
  tradedangerous/transfers.py,sha256=NmXXk2aF88YkAvYqc9Syt_aO6d2jJjC-OxoRFoOyQH4,9923
23
23
  tradedangerous/utils.py,sha256=PUPvAEqUyxYGqqQa0b_yfLAvq8YVUxK6HfdS-CxM-Lo,5186
24
- tradedangerous/version.py,sha256=ObElDg8HjFIYhjl7ct9SkBNKb_o4DpsNomg_3x-kGK0,648
24
+ tradedangerous/version.py,sha256=BV5It3d62BF5GhEeSfIzL1rZ7TJs5UsvyfMfrDKf4lc,648
25
25
  tradedangerous/commands/TEMPLATE.py,sha256=7oXL124aqxGHwnb0h9yRylUiwc6M5QrRrGVrubwI1gg,2124
26
26
  tradedangerous/commands/__init__.py,sha256=6B0WuqkFBOll5Hj67yKDAnhmyr5ZAnHc6nzUNEUh384,9640
27
27
  tradedangerous/commands/buildcache_cmd.py,sha256=oJvP06fA8svnHrfrpWkHKR16cba8GIhHdMOyZqds18Y,2332
@@ -66,14 +66,14 @@ tradedangerous/plugins/eddblink_plug.py,sha256=7lqUjXQrZFuEBsXZNNmX6lQvGuqZeWrVS
66
66
  tradedangerous/plugins/edmc_batch_plug.py,sha256=3Ptr-SZqaZFR8ViIIrp9Ak7rvfU3zl11AZYBhIceN7s,4224
67
67
  tradedangerous/plugins/journal_plug.py,sha256=K1oIeI7E3mb04fvYLXyoAh7fOTyM9NBelibTI88MIDQ,23696
68
68
  tradedangerous/plugins/netlog_plug.py,sha256=Gw_HSZWpN17D--OIYEM3Vo8y9SvDOv9UwAUfY24kz28,13460
69
- tradedangerous/plugins/spansh_plug.py,sha256=FSdmBAxpLxud2tmEvY3zhCPXwMRi66DCb0HYhC_up2w,21807
69
+ tradedangerous/plugins/spansh_plug.py,sha256=WOpTm9C4oXPfFeEaSQtcu82OqX1uAuNGNy8wVY4iw_I,21792
70
70
  tradedangerous/templates/Added.csv,sha256=8o54civQCcS9y7_DBo0GX196XWRbbREQqKDYTKibsgQ,649
71
71
  tradedangerous/templates/Category.csv,sha256=8xwUDcBZE25T6x6dZGlRUMTCqeDLt3a9LXU5h6hRHV8,250
72
72
  tradedangerous/templates/RareItem.csv,sha256=F1RhRnTD82PiwrVUO-ai2ErGH2PTqNnQaDw5mcgljXs,10483
73
73
  tradedangerous/templates/TradeDangerous.sql,sha256=kHZ7JBSY5lh2DnqayAxoO-apvXKB510SqhAzkT21YHY,8138
74
- tradedangerous-10.16.10.dist-info/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
75
- tradedangerous-10.16.10.dist-info/METADATA,sha256=2kJbWwMymuIntaUaWk5rqDlROeVr1lFB2CiEwbHAvTo,4422
76
- tradedangerous-10.16.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
77
- tradedangerous-10.16.10.dist-info/entry_points.txt,sha256=pSwa-q0ob443uiKux7xFKYQl8uen66iDTnjdrQhNLx8,92
78
- tradedangerous-10.16.10.dist-info/top_level.txt,sha256=bF29i-oEltmNICgElEKxNsg83oahJvxg3a7YrxZi9Rk,15
79
- tradedangerous-10.16.10.dist-info/RECORD,,
74
+ tradedangerous-10.16.11.dist-info/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
75
+ tradedangerous-10.16.11.dist-info/METADATA,sha256=3ABvfKWRpcrTpz8weaPffXQJ5eTllqRD1R6XkzPUFb0,4422
76
+ tradedangerous-10.16.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
77
+ tradedangerous-10.16.11.dist-info/entry_points.txt,sha256=pSwa-q0ob443uiKux7xFKYQl8uen66iDTnjdrQhNLx8,92
78
+ tradedangerous-10.16.11.dist-info/top_level.txt,sha256=bF29i-oEltmNICgElEKxNsg83oahJvxg3a7YrxZi9Rk,15
79
+ tradedangerous-10.16.11.dist-info/RECORD,,