tradedangerous 12.7.6__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.
Files changed (87) hide show
  1. py.typed +1 -0
  2. trade.py +49 -0
  3. tradedangerous/__init__.py +43 -0
  4. tradedangerous/cache.py +1381 -0
  5. tradedangerous/cli.py +136 -0
  6. tradedangerous/commands/TEMPLATE.py +74 -0
  7. tradedangerous/commands/__init__.py +244 -0
  8. tradedangerous/commands/buildcache_cmd.py +102 -0
  9. tradedangerous/commands/buy_cmd.py +427 -0
  10. tradedangerous/commands/commandenv.py +372 -0
  11. tradedangerous/commands/exceptions.py +94 -0
  12. tradedangerous/commands/export_cmd.py +150 -0
  13. tradedangerous/commands/import_cmd.py +222 -0
  14. tradedangerous/commands/local_cmd.py +243 -0
  15. tradedangerous/commands/market_cmd.py +207 -0
  16. tradedangerous/commands/nav_cmd.py +252 -0
  17. tradedangerous/commands/olddata_cmd.py +270 -0
  18. tradedangerous/commands/parsing.py +221 -0
  19. tradedangerous/commands/rares_cmd.py +298 -0
  20. tradedangerous/commands/run_cmd.py +1521 -0
  21. tradedangerous/commands/sell_cmd.py +262 -0
  22. tradedangerous/commands/shipvendor_cmd.py +60 -0
  23. tradedangerous/commands/station_cmd.py +68 -0
  24. tradedangerous/commands/trade_cmd.py +181 -0
  25. tradedangerous/commands/update_cmd.py +67 -0
  26. tradedangerous/corrections.py +55 -0
  27. tradedangerous/csvexport.py +234 -0
  28. tradedangerous/db/__init__.py +27 -0
  29. tradedangerous/db/adapter.py +192 -0
  30. tradedangerous/db/config.py +107 -0
  31. tradedangerous/db/engine.py +259 -0
  32. tradedangerous/db/lifecycle.py +332 -0
  33. tradedangerous/db/locks.py +208 -0
  34. tradedangerous/db/orm_models.py +500 -0
  35. tradedangerous/db/paths.py +113 -0
  36. tradedangerous/db/utils.py +661 -0
  37. tradedangerous/edscupdate.py +565 -0
  38. tradedangerous/edsmupdate.py +474 -0
  39. tradedangerous/formatting.py +210 -0
  40. tradedangerous/fs.py +156 -0
  41. tradedangerous/gui.py +1146 -0
  42. tradedangerous/mapping.py +133 -0
  43. tradedangerous/mfd/__init__.py +103 -0
  44. tradedangerous/mfd/saitek/__init__.py +3 -0
  45. tradedangerous/mfd/saitek/directoutput.py +678 -0
  46. tradedangerous/mfd/saitek/x52pro.py +195 -0
  47. tradedangerous/misc/checkpricebounds.py +287 -0
  48. tradedangerous/misc/clipboard.py +49 -0
  49. tradedangerous/misc/coord64.py +83 -0
  50. tradedangerous/misc/csvdialect.py +57 -0
  51. tradedangerous/misc/derp-sentinel.py +35 -0
  52. tradedangerous/misc/diff-system-csvs.py +159 -0
  53. tradedangerous/misc/eddb.py +81 -0
  54. tradedangerous/misc/eddn.py +349 -0
  55. tradedangerous/misc/edsc.py +437 -0
  56. tradedangerous/misc/edsm.py +121 -0
  57. tradedangerous/misc/importeddbstats.py +54 -0
  58. tradedangerous/misc/prices-json-exp.py +179 -0
  59. tradedangerous/misc/progress.py +194 -0
  60. tradedangerous/plugins/__init__.py +249 -0
  61. tradedangerous/plugins/edcd_plug.py +371 -0
  62. tradedangerous/plugins/eddblink_plug.py +861 -0
  63. tradedangerous/plugins/edmc_batch_plug.py +133 -0
  64. tradedangerous/plugins/spansh_plug.py +2647 -0
  65. tradedangerous/prices.py +211 -0
  66. tradedangerous/submit-distances.py +422 -0
  67. tradedangerous/templates/Added.csv +37 -0
  68. tradedangerous/templates/Category.csv +17 -0
  69. tradedangerous/templates/RareItem.csv +143 -0
  70. tradedangerous/templates/TradeDangerous.sql +338 -0
  71. tradedangerous/tools.py +40 -0
  72. tradedangerous/tradecalc.py +1302 -0
  73. tradedangerous/tradedb.py +2320 -0
  74. tradedangerous/tradeenv.py +313 -0
  75. tradedangerous/tradeenv.pyi +109 -0
  76. tradedangerous/tradeexcept.py +131 -0
  77. tradedangerous/tradeorm.py +183 -0
  78. tradedangerous/transfers.py +192 -0
  79. tradedangerous/utils.py +243 -0
  80. tradedangerous/version.py +16 -0
  81. tradedangerous-12.7.6.dist-info/METADATA +106 -0
  82. tradedangerous-12.7.6.dist-info/RECORD +87 -0
  83. tradedangerous-12.7.6.dist-info/WHEEL +5 -0
  84. tradedangerous-12.7.6.dist-info/entry_points.txt +3 -0
  85. tradedangerous-12.7.6.dist-info/licenses/LICENSE +373 -0
  86. tradedangerous-12.7.6.dist-info/top_level.txt +2 -0
  87. tradegui.py +24 -0
@@ -0,0 +1,133 @@
1
+ from pathlib import Path
2
+
3
+ from .. import fs
4
+ from ..commands.exceptions import CommandLineError
5
+ from . import PluginException, ImportPluginBase
6
+
7
+ class ImportPlugin(ImportPluginBase):
8
+ """
9
+ Plugin that imports multiple .price files at once
10
+ """
11
+
12
+ PRICE_GLOB = "*.prices"
13
+ BATCH_FILE = "batch.prices"
14
+
15
+ pluginOptions = {
16
+ 'files': 'Path to some .price files to import (file=file1;file2)',
17
+ 'folder': 'Path to a folder containing .price files (folder=pathToFolder)'
18
+ }
19
+
20
+ def __init__(self, tdb, tdenv):
21
+ super().__init__(tdb, tdenv)
22
+
23
+ """
24
+ Returns the newest file.
25
+ """
26
+ def file_get_newer(self, a, b):
27
+ if a.stat().st_mtime > b.stat().st_mtime:
28
+ return a
29
+ return b
30
+
31
+ """
32
+ Returns a list of stations in a file
33
+ """
34
+ def file_get_stations(self, a):
35
+ contents = a.read_text()
36
+ stations = []
37
+ for line in contents.split("\n"):
38
+ if "@" in line:
39
+ stations.append(line[2:])
40
+ return stations
41
+
42
+ """
43
+ Given a list of files, does analysis to determine
44
+ whether they are duplicates.
45
+ """
46
+ def sanitize_files(self, files):
47
+ stations_seen = {}
48
+
49
+ for f in files:
50
+ filePath = Path(f)
51
+ if not filePath.is_file():
52
+ raise CommandLineError("File not found: {}".format(
53
+ str(filePath)
54
+ ))
55
+
56
+ stations = self.file_get_stations(filePath)
57
+
58
+ # Does not support resolving multiple stations (yet)
59
+ if len(stations) > 1:
60
+ raise PluginException("EDMC Batch unable to process files with multiple stations. Use normal import.")
61
+
62
+ for s in stations:
63
+ if s in stations_seen:
64
+ cur_file = stations_seen[s]
65
+ # Set the newer file as the one we'll use.
66
+ stations_seen[s] = self.file_get_newer(cur_file, f)
67
+ else:
68
+ stations_seen[s] = f
69
+
70
+ return stations_seen.values()
71
+
72
+ """
73
+ Set the environment for the import command to import our files
74
+ """
75
+ def set_environment(self, files):
76
+ tdenv = self.tdenv
77
+ path_list = files
78
+ fs.ensurefolder(tdenv.tmpDir)
79
+ batchfile = tdenv.tmpDir / Path(self.BATCH_FILE)
80
+ if batchfile.exists():
81
+ batchfile.unlink()
82
+ # We now have a list of paths. Add all contents to a new file
83
+ temp_file = open(batchfile, "w")
84
+
85
+ for f in path_list:
86
+ contents = f.read_text()
87
+ temp_file.writelines("# File: {}\n".format(f))
88
+ temp_file.write(contents)
89
+
90
+ # Set the file we're reading from to the temp file
91
+ tdenv.filename = str(batchfile.absolute())
92
+
93
+ def split_files(self, files):
94
+ file_list = self.getOption("files").split(";")
95
+ path_list = []
96
+ for f in file_list:
97
+ path_list.append(Path(f))
98
+ return path_list
99
+
100
+ def get_prices_in_folder(self, directory):
101
+ folderToSplit = Path(directory)
102
+ if not folderToSplit.is_dir():
103
+ raise CommandLineError("Path is not a directory: {}".format(
104
+ str(folderToSplit)
105
+ ))
106
+
107
+ filesInFolder = folderToSplit.glob(self.PRICE_GLOB)
108
+ file_list = []
109
+ for i in filesInFolder:
110
+ file_list.append(i)
111
+
112
+ return file_list
113
+
114
+ def run(self):
115
+ # Grab files option and validate
116
+ files = self.getOption("files")
117
+ folder = self.getOption("folder")
118
+
119
+ if files is None and folder is None:
120
+ raise PluginException("Argument Required")
121
+
122
+ # The list of files to import...
123
+ file_list = []
124
+
125
+ if files:
126
+ file_list.extend(self.split_files(files))
127
+ if folder:
128
+ file_list.extend(self.get_prices_in_folder(folder))
129
+
130
+ # Split into a path list, verify all paths are good.
131
+ self.set_environment(self.sanitize_files(file_list))
132
+ return True
133
+