hive-nectar 0.0.2__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 hive-nectar might be problematic. Click here for more details.
- hive_nectar-0.0.2.dist-info/METADATA +182 -0
- hive_nectar-0.0.2.dist-info/RECORD +86 -0
- hive_nectar-0.0.2.dist-info/WHEEL +4 -0
- hive_nectar-0.0.2.dist-info/entry_points.txt +2 -0
- hive_nectar-0.0.2.dist-info/licenses/LICENSE.txt +23 -0
- nectar/__init__.py +32 -0
- nectar/account.py +4371 -0
- nectar/amount.py +475 -0
- nectar/asciichart.py +270 -0
- nectar/asset.py +82 -0
- nectar/block.py +446 -0
- nectar/blockchain.py +1178 -0
- nectar/blockchaininstance.py +2284 -0
- nectar/blockchainobject.py +221 -0
- nectar/blurt.py +563 -0
- nectar/cli.py +6285 -0
- nectar/comment.py +1217 -0
- nectar/community.py +513 -0
- nectar/constants.py +111 -0
- nectar/conveyor.py +309 -0
- nectar/discussions.py +1709 -0
- nectar/exceptions.py +149 -0
- nectar/hive.py +546 -0
- nectar/hivesigner.py +420 -0
- nectar/imageuploader.py +72 -0
- nectar/instance.py +129 -0
- nectar/market.py +1013 -0
- nectar/memo.py +449 -0
- nectar/message.py +357 -0
- nectar/nodelist.py +444 -0
- nectar/price.py +557 -0
- nectar/profile.py +65 -0
- nectar/rc.py +308 -0
- nectar/snapshot.py +726 -0
- nectar/steem.py +582 -0
- nectar/storage.py +53 -0
- nectar/transactionbuilder.py +622 -0
- nectar/utils.py +545 -0
- nectar/version.py +2 -0
- nectar/vote.py +557 -0
- nectar/wallet.py +472 -0
- nectar/witness.py +617 -0
- nectarapi/__init__.py +11 -0
- nectarapi/exceptions.py +123 -0
- nectarapi/graphenerpc.py +589 -0
- nectarapi/node.py +178 -0
- nectarapi/noderpc.py +229 -0
- nectarapi/rpcutils.py +97 -0
- nectarapi/version.py +2 -0
- nectarbase/__init__.py +14 -0
- nectarbase/ledgertransactions.py +75 -0
- nectarbase/memo.py +243 -0
- nectarbase/objects.py +429 -0
- nectarbase/objecttypes.py +22 -0
- nectarbase/operationids.py +102 -0
- nectarbase/operations.py +1297 -0
- nectarbase/signedtransactions.py +48 -0
- nectarbase/transactions.py +11 -0
- nectarbase/version.py +2 -0
- nectargrapheneapi/__init__.py +6 -0
- nectargraphenebase/__init__.py +27 -0
- nectargraphenebase/account.py +846 -0
- nectargraphenebase/aes.py +52 -0
- nectargraphenebase/base58.py +192 -0
- nectargraphenebase/bip32.py +494 -0
- nectargraphenebase/bip38.py +134 -0
- nectargraphenebase/chains.py +149 -0
- nectargraphenebase/dictionary.py +3 -0
- nectargraphenebase/ecdsasig.py +326 -0
- nectargraphenebase/objects.py +123 -0
- nectargraphenebase/objecttypes.py +6 -0
- nectargraphenebase/operationids.py +3 -0
- nectargraphenebase/operations.py +23 -0
- nectargraphenebase/prefix.py +11 -0
- nectargraphenebase/py23.py +38 -0
- nectargraphenebase/signedtransactions.py +201 -0
- nectargraphenebase/types.py +419 -0
- nectargraphenebase/unsignedtransactions.py +283 -0
- nectargraphenebase/version.py +2 -0
- nectarstorage/__init__.py +38 -0
- nectarstorage/base.py +306 -0
- nectarstorage/exceptions.py +16 -0
- nectarstorage/interfaces.py +237 -0
- nectarstorage/masterpassword.py +239 -0
- nectarstorage/ram.py +30 -0
- nectarstorage/sqlite.py +334 -0
nectar/asciichart.py
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import sys
|
|
3
|
+
from math import ceil, floor
|
|
4
|
+
|
|
5
|
+
# Basic idea from https://github.com/kroitor/asciichart
|
|
6
|
+
# ╱ ╲ ╳ ─ └┲┲┲─
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsciiChart(object):
|
|
10
|
+
"""Can be used to plot price and trade history
|
|
11
|
+
|
|
12
|
+
:param int height: Height of the plot
|
|
13
|
+
:param int width: Width of the plot
|
|
14
|
+
:param int offset: Offset between tick strings and y-axis (default is 3)
|
|
15
|
+
:param str placeholder: Defines how the numbers on the y-axes are formatted (default is '{:8.2f}')
|
|
16
|
+
:param str charset: sets the charset for plotting, uft8 or ascii (default: utf8)
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, height=None, width=None, offset=3, placeholder="{:8.2f} ", charset="utf8"):
|
|
20
|
+
self.height = height
|
|
21
|
+
self.width = width
|
|
22
|
+
self.offset = offset
|
|
23
|
+
self.placeholder = placeholder
|
|
24
|
+
self.clear_data()
|
|
25
|
+
if charset == "ascii" or sys.version_info[0] < 3:
|
|
26
|
+
self.char_set = {
|
|
27
|
+
"first_axis_elem": "|",
|
|
28
|
+
"axis_elem": "|",
|
|
29
|
+
"axis_elem_with_graph": "|",
|
|
30
|
+
"curve_ar": "\\",
|
|
31
|
+
"curve_lb": "\\",
|
|
32
|
+
"curve_br": "/",
|
|
33
|
+
"curve_la": "/",
|
|
34
|
+
"curve_hl": "-",
|
|
35
|
+
"curve_vl": "|",
|
|
36
|
+
"curve_hl_dot": "-",
|
|
37
|
+
"curve_vl_dot": "|",
|
|
38
|
+
}
|
|
39
|
+
else:
|
|
40
|
+
self.char_set = {
|
|
41
|
+
"first_axis_elem": "┼",
|
|
42
|
+
"axis_elem": "┤",
|
|
43
|
+
"axis_elem_with_graph": "┼",
|
|
44
|
+
"curve_ar": "╰",
|
|
45
|
+
"curve_lb": "╮",
|
|
46
|
+
"curve_br": "╭",
|
|
47
|
+
"curve_la": "╯",
|
|
48
|
+
"curve_hl": "─",
|
|
49
|
+
"curve_vl": "│",
|
|
50
|
+
"curve_hl_dot": "┈",
|
|
51
|
+
"curve_vl_dot": "┊",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
def clear_data(self):
|
|
55
|
+
"""Clears all data"""
|
|
56
|
+
self.canvas = []
|
|
57
|
+
self.minimum = None
|
|
58
|
+
self.maximum = None
|
|
59
|
+
self.n = None
|
|
60
|
+
self.skip = 1
|
|
61
|
+
|
|
62
|
+
def set_parameter(self, height=None, offset=None, placeholder=None):
|
|
63
|
+
"""Can be used to change parameter"""
|
|
64
|
+
if height is not None:
|
|
65
|
+
self.height = height
|
|
66
|
+
if offset is not None:
|
|
67
|
+
self.offset = offset
|
|
68
|
+
if placeholder is not None:
|
|
69
|
+
self.placeholder = placeholder
|
|
70
|
+
self._calc_plot_parameter()
|
|
71
|
+
|
|
72
|
+
def adapt_on_series(self, series):
|
|
73
|
+
"""Calculates the minimum, maximum and length from the given list
|
|
74
|
+
|
|
75
|
+
:param list series: time series to plot
|
|
76
|
+
|
|
77
|
+
.. testcode::
|
|
78
|
+
|
|
79
|
+
from nectar.asciichart import AsciiChart
|
|
80
|
+
chart = AsciiChart()
|
|
81
|
+
series = [1, 2, 3, 7, 2, -4, -2]
|
|
82
|
+
chart.adapt_on_series(series)
|
|
83
|
+
chart.new_chart()
|
|
84
|
+
chart.add_axis()
|
|
85
|
+
chart.add_curve(series)
|
|
86
|
+
print(str(chart))
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
self.minimum = min(series)
|
|
90
|
+
self.maximum = max(series)
|
|
91
|
+
self.n = len(series)
|
|
92
|
+
self._calc_plot_parameter()
|
|
93
|
+
|
|
94
|
+
def _calc_plot_parameter(self, minimum=None, maximum=None, n=None):
|
|
95
|
+
"""Calculates parameter from minimum, maximum and length"""
|
|
96
|
+
if minimum is not None:
|
|
97
|
+
self.minimum = minimum
|
|
98
|
+
if maximum is not None:
|
|
99
|
+
self.maximum = maximum
|
|
100
|
+
if n is not None:
|
|
101
|
+
self.n = n
|
|
102
|
+
if self.n is None or self.maximum is None or self.minimum is None:
|
|
103
|
+
return
|
|
104
|
+
interval = abs(float(self.maximum) - float(self.minimum))
|
|
105
|
+
if interval == 0:
|
|
106
|
+
interval = 1
|
|
107
|
+
if self.height is None:
|
|
108
|
+
self.height = interval
|
|
109
|
+
self.ratio = self.height / interval
|
|
110
|
+
self.min2 = floor(float(self.minimum) * self.ratio)
|
|
111
|
+
self.max2 = ceil(float(self.maximum) * self.ratio)
|
|
112
|
+
if self.min2 == self.max2:
|
|
113
|
+
self.max2 += 1
|
|
114
|
+
intmin2 = int(self.min2)
|
|
115
|
+
intmax2 = int(self.max2)
|
|
116
|
+
self.rows = abs(intmax2 - intmin2)
|
|
117
|
+
if self.width is not None:
|
|
118
|
+
self.skip = int(self.n / self.width)
|
|
119
|
+
if self.skip < 1:
|
|
120
|
+
self.skip = 1
|
|
121
|
+
else:
|
|
122
|
+
self.skip = 1
|
|
123
|
+
|
|
124
|
+
def plot(self, series, return_str=False):
|
|
125
|
+
"""All in one function for plotting
|
|
126
|
+
|
|
127
|
+
.. testcode::
|
|
128
|
+
|
|
129
|
+
from nectar.asciichart import AsciiChart
|
|
130
|
+
chart = AsciiChart()
|
|
131
|
+
series = [1, 2, 3, 7, 2, -4, -2]
|
|
132
|
+
chart.plot(series)
|
|
133
|
+
"""
|
|
134
|
+
self.clear_data()
|
|
135
|
+
self.adapt_on_series(series)
|
|
136
|
+
self.new_chart()
|
|
137
|
+
self.add_axis()
|
|
138
|
+
self.add_curve(series)
|
|
139
|
+
if not return_str:
|
|
140
|
+
print(str(self))
|
|
141
|
+
else:
|
|
142
|
+
return str(self)
|
|
143
|
+
|
|
144
|
+
def new_chart(self, minimum=None, maximum=None, n=None):
|
|
145
|
+
"""Clears the canvas
|
|
146
|
+
|
|
147
|
+
.. testcode::
|
|
148
|
+
|
|
149
|
+
from nectar.asciichart import AsciiChart
|
|
150
|
+
chart = AsciiChart()
|
|
151
|
+
series = [1, 2, 3, 7, 2, -4, -2]
|
|
152
|
+
chart.adapt_on_series(series)
|
|
153
|
+
chart.new_chart()
|
|
154
|
+
chart.add_axis()
|
|
155
|
+
chart.add_curve(series)
|
|
156
|
+
print(str(chart))
|
|
157
|
+
|
|
158
|
+
"""
|
|
159
|
+
if minimum is not None:
|
|
160
|
+
self.minimum = minimum
|
|
161
|
+
if maximum is not None:
|
|
162
|
+
self.maximum = maximum
|
|
163
|
+
if n is not None:
|
|
164
|
+
self.n = n
|
|
165
|
+
self._calc_plot_parameter()
|
|
166
|
+
self.canvas = [
|
|
167
|
+
[" "] * (int(self.n / self.skip) + self.offset) for i in range(self.rows + 1)
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
def add_axis(self):
|
|
171
|
+
"""Adds a y-axis to the canvas
|
|
172
|
+
|
|
173
|
+
.. testcode::
|
|
174
|
+
|
|
175
|
+
from nectar.asciichart import AsciiChart
|
|
176
|
+
chart = AsciiChart()
|
|
177
|
+
series = [1, 2, 3, 7, 2, -4, -2]
|
|
178
|
+
chart.adapt_on_series(series)
|
|
179
|
+
chart.new_chart()
|
|
180
|
+
chart.add_axis()
|
|
181
|
+
chart.add_curve(series)
|
|
182
|
+
print(str(chart))
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
# axis and labels
|
|
186
|
+
interval = abs(float(self.maximum) - float(self.minimum))
|
|
187
|
+
intmin2 = int(self.min2)
|
|
188
|
+
intmax2 = int(self.max2)
|
|
189
|
+
for y in range(intmin2, intmax2 + 1):
|
|
190
|
+
label = self.placeholder.format(
|
|
191
|
+
float(self.maximum) - ((y - intmin2) * interval / self.rows)
|
|
192
|
+
)
|
|
193
|
+
if label:
|
|
194
|
+
self._set_y_axis_elem(y, label)
|
|
195
|
+
|
|
196
|
+
def _set_y_axis_elem(self, y, label):
|
|
197
|
+
intmin2 = int(self.min2)
|
|
198
|
+
self.canvas[y - intmin2][max(self.offset - len(label), 0)] = label
|
|
199
|
+
if y == 0:
|
|
200
|
+
self.canvas[y - intmin2][self.offset - 1] = self.char_set["first_axis_elem"]
|
|
201
|
+
else:
|
|
202
|
+
self.canvas[y - intmin2][self.offset - 1] = self.char_set["axis_elem"]
|
|
203
|
+
|
|
204
|
+
def _map_y(self, y_float):
|
|
205
|
+
intmin2 = int(self.min2)
|
|
206
|
+
return int(round(y_float * self.ratio) - intmin2)
|
|
207
|
+
|
|
208
|
+
def add_curve(self, series):
|
|
209
|
+
"""Add a curve to the canvas
|
|
210
|
+
|
|
211
|
+
:param list series: List width float data points
|
|
212
|
+
|
|
213
|
+
.. testcode::
|
|
214
|
+
|
|
215
|
+
from nectar.asciichart import AsciiChart
|
|
216
|
+
chart = AsciiChart()
|
|
217
|
+
series = [1, 2, 3, 7, 2, -4, -2]
|
|
218
|
+
chart.adapt_on_series(series)
|
|
219
|
+
chart.new_chart()
|
|
220
|
+
chart.add_axis()
|
|
221
|
+
chart.add_curve(series)
|
|
222
|
+
print(str(chart))
|
|
223
|
+
|
|
224
|
+
"""
|
|
225
|
+
if self.n is None:
|
|
226
|
+
self.adapt_on_series(series)
|
|
227
|
+
if len(self.canvas) == 0:
|
|
228
|
+
self.new_chart()
|
|
229
|
+
y0 = self._map_y(series[0])
|
|
230
|
+
self._set_elem(y0, -1, self.char_set["axis_elem_with_graph"])
|
|
231
|
+
for x in range(0, len(series[:: self.skip]) - 1):
|
|
232
|
+
y0 = self._map_y(series[:: self.skip][x + 0])
|
|
233
|
+
y1 = self._map_y(series[:: self.skip][x + 1])
|
|
234
|
+
if y0 == y1:
|
|
235
|
+
self._draw_h_line(y0, x, x + 1, line=self.char_set["curve_hl"])
|
|
236
|
+
else:
|
|
237
|
+
self._draw_diag(y0, y1, x)
|
|
238
|
+
start = min(y0, y1) + 1
|
|
239
|
+
end = max(y0, y1)
|
|
240
|
+
self._draw_v_line(start, end, x, line=self.char_set["curve_vl"])
|
|
241
|
+
|
|
242
|
+
def _draw_diag(self, y0, y1, x):
|
|
243
|
+
"""Plot diagonal element"""
|
|
244
|
+
if y0 > y1:
|
|
245
|
+
c1 = self.char_set["curve_ar"]
|
|
246
|
+
c0 = self.char_set["curve_lb"]
|
|
247
|
+
else:
|
|
248
|
+
c1 = self.char_set["curve_br"]
|
|
249
|
+
c0 = self.char_set["curve_la"]
|
|
250
|
+
self._set_elem(y1, x, c1)
|
|
251
|
+
self._set_elem(y0, x, c0)
|
|
252
|
+
|
|
253
|
+
def _draw_h_line(self, y, x_start, x_end, line="-"):
|
|
254
|
+
"""Plot horizontal line"""
|
|
255
|
+
for x in range(x_start, x_end):
|
|
256
|
+
self._set_elem(y, x, line)
|
|
257
|
+
|
|
258
|
+
def _draw_v_line(self, y_start, y_end, x, line="|"):
|
|
259
|
+
"""Plot vertical line"""
|
|
260
|
+
for y in range(y_start, y_end):
|
|
261
|
+
self._set_elem(y, x, line)
|
|
262
|
+
|
|
263
|
+
def _set_elem(self, y, x, c):
|
|
264
|
+
"""Plot signle element into canvas"""
|
|
265
|
+
self.canvas[self.rows - y][x + self.offset] = c
|
|
266
|
+
|
|
267
|
+
def __repr__(self):
|
|
268
|
+
return "\n".join(["".join(row) for row in self.canvas])
|
|
269
|
+
|
|
270
|
+
__str__ = __repr__
|
nectar/asset.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from .blockchainobject import BlockchainObject
|
|
3
|
+
from .exceptions import AssetDoesNotExistsException
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Asset(BlockchainObject):
|
|
7
|
+
"""Deals with Assets of the network.
|
|
8
|
+
|
|
9
|
+
:param str Asset: Symbol name or object id of an asset
|
|
10
|
+
:param bool lazy: Lazy loading
|
|
11
|
+
:param bool full: Also obtain bitasset-data and dynamic asset dat
|
|
12
|
+
:param Steem steem_instance: Steem
|
|
13
|
+
instance
|
|
14
|
+
:returns: All data of an asset
|
|
15
|
+
|
|
16
|
+
.. note:: This class comes with its own caching function to reduce the
|
|
17
|
+
load on the API server. Instances of this class can be
|
|
18
|
+
refreshed with ``Asset.refresh()``.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
type_id = 3
|
|
22
|
+
|
|
23
|
+
def __init__(self, asset, lazy=False, full=False, blockchain_instance=None, **kwargs):
|
|
24
|
+
self.full = full
|
|
25
|
+
super(Asset, self).__init__(
|
|
26
|
+
asset, lazy=lazy, full=full, blockchain_instance=blockchain_instance, **kwargs
|
|
27
|
+
)
|
|
28
|
+
# self.refresh()
|
|
29
|
+
|
|
30
|
+
def refresh(self):
|
|
31
|
+
"""Refresh the data from the API server"""
|
|
32
|
+
self.chain_params = self.blockchain.get_network()
|
|
33
|
+
if self.chain_params is None:
|
|
34
|
+
from nectargraphenebase.chains import known_chains
|
|
35
|
+
|
|
36
|
+
self.chain_params = known_chains["HIVE"]
|
|
37
|
+
self["asset"] = ""
|
|
38
|
+
found_asset = False
|
|
39
|
+
for asset in self.chain_params["chain_assets"]:
|
|
40
|
+
if self.identifier in [asset["symbol"], asset["asset"], asset["id"]]:
|
|
41
|
+
self["asset"] = asset["asset"]
|
|
42
|
+
self["precision"] = asset["precision"]
|
|
43
|
+
self["id"] = asset["id"]
|
|
44
|
+
self["symbol"] = asset["symbol"]
|
|
45
|
+
found_asset = True
|
|
46
|
+
break
|
|
47
|
+
if not found_asset:
|
|
48
|
+
raise AssetDoesNotExistsException(
|
|
49
|
+
self.identifier + " chain_assets:" + str(self.chain_params["chain_assets"])
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def symbol(self):
|
|
54
|
+
return self["symbol"]
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def asset(self):
|
|
58
|
+
return self["asset"]
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def precision(self):
|
|
62
|
+
return self["precision"]
|
|
63
|
+
|
|
64
|
+
def __eq__(self, other):
|
|
65
|
+
if isinstance(other, (Asset, dict)):
|
|
66
|
+
return (
|
|
67
|
+
self["symbol"] == other["symbol"]
|
|
68
|
+
and self["asset"] == other["asset"]
|
|
69
|
+
and self["precision"] == other["precision"]
|
|
70
|
+
)
|
|
71
|
+
else:
|
|
72
|
+
return self["symbol"] == other
|
|
73
|
+
|
|
74
|
+
def __ne__(self, other):
|
|
75
|
+
if isinstance(other, (Asset, dict)):
|
|
76
|
+
return (
|
|
77
|
+
self["symbol"] != other["symbol"]
|
|
78
|
+
or self["asset"] != other["asset"]
|
|
79
|
+
or self["precision"] != other["precision"]
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
return self["symbol"] != other
|