Skip to content

Commit

Permalink
Fix typo and improved handling of symbols in comment
Browse files Browse the repository at this point in the history
  • Loading branch information
holgern committed Oct 7, 2018
1 parent 305ed6b commit d0abdfc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
20 changes: 16 additions & 4 deletions beem/comment.py
Expand Up @@ -88,9 +88,13 @@ def _parse_json_data(self, comment):
"total_pending_payout_value",
"promoted",
]
if self.steem.sbd_symbol is not None:
symbol = self.steem.sbd_symbol
else:
symbol = self.steem.steem_symbol
for p in sbd_amounts:
if p in comment and isinstance(comment.get(p), (string_types, list, dict)):
comment[p] = Amount(comment.get(p, "0.000 %s" % (self.steem.sbd_symbol)), steem_instance=self.steem)
if p in comment and isinstance(comment.get(p), (string_types, list, dict)) and symbol is not None:
comment[p] = Amount(comment.get(p, "0.000 %s" % (symbol)), steem_instance=self.steem)

# turn json_metadata into python dict
meta_str = comment.get("json_metadata", "{}")
Expand Down Expand Up @@ -276,7 +280,11 @@ def is_comment(self):
def reward(self):
""" Return the estimated total SBD reward.
"""
a_zero = Amount(0, self.steem.sbd_symbol, steem_instance=self.steem)
if self.steem.sbd_symbol is not None:
symbol = self.steem.sbd_symbol
else:
symbol = self.steem.steem_symbol
a_zero = Amount(0, symbol, steem_instance=self.steem)
total = Amount(self.get("total_payout_value", a_zero), steem_instance=self.steem)
pending = Amount(self.get("pending_payout_value", a_zero), steem_instance=self.steem)
return total + pending
Expand All @@ -285,7 +293,11 @@ def is_pending(self):
""" Return if the payout is pending (the post/comment
is younger than 7 days)
"""
a_zero = Amount(0, self.steem.sbd_symbol, steem_instance=self.steem)
if self.steem.sbd_symbol is not None:
symbol = self.steem.sbd_symbol
else:
symbol = self.steem.steem_symbol
a_zero = Amount(0, symbol, steem_instance=self.steem)
total = Amount(self.get("total_payout_value", a_zero), steem_instance=self.steem)
post_age_days = self.time_elapsed().total_seconds() / 60 / 60 / 24
return post_age_days < 7.0 and float(total) == 0
Expand Down
2 changes: 1 addition & 1 deletion beem/snapshot.py
Expand Up @@ -40,7 +40,7 @@ def reset(self):
"""
self.own_vests = [Amount(0, self.steem.vests_symbol, steem_instance=self.steem)]
self.own_steem = [Amount(0, self.steem.steem_symbol, steem_instance=self.steem)]
self.own_sbd = [Amount(0, self.steem.steem_symbol, steem_instance=self.steem)]
self.own_sbd = [Amount(0, self.steem.sbd_symbol, steem_instance=self.steem)]
self.delegated_vests_in = [{}]
self.delegated_vests_out = [{}]
self.timestamps = [addTzInfo(datetime(1970, 1, 1, 0, 0, 0, 0))]
Expand Down
2 changes: 2 additions & 0 deletions beem/steem.py
Expand Up @@ -1907,6 +1907,8 @@ def _get_asset_symbol(self, asset_id):
for asset in self.chain_params['chain_assets']:
if asset['id'] == asset_id:
return asset['symbol']
if asset_id < 3:
return None
raise KeyError("asset ID not found in chain assets")

@property
Expand Down

0 comments on commit d0abdfc

Please sign in to comment.