diff --git a/beem/account.py b/beem/account.py index 6af0dae42f0ca665a781851d1a018ebfb788e355..398a93c50ca91a7d1f49a66b53f28cfd8e075e81 100644 --- a/beem/account.py +++ b/beem/account.py @@ -364,7 +364,7 @@ class Account(BlockchainObject): ret += " %.2f $\n" % (self.get_voting_value_SBD()) ret += "full in %s \n" % (self.get_recharge_time_str()) ret += "--- Downvoting Power ---\n" - ret += "%.2f %% \n" % (self.get_downvoting_power()) + ret += "%.2f %% \n" % (self.get_downvoting_power()) ret += "--- Balance ---\n" ret += "%.2f SP, " % (self.get_steem_power()) ret += "%s, %s\n" % (str(self.balances["available"][0]), str(self.balances["available"][1])) @@ -478,10 +478,10 @@ class Account(BlockchainObject): def get_downvoting_power(self, with_regeneration=True): """ Returns the account downvoting power in the range of 0-100% - """ - if not "downvote_manabar" in self: + """ + if "downvote_manabar" not in self: return 0 - + manabar = self.get_downvote_manabar() if with_regeneration: total_down_vp = manabar["current_mana_pct"] @@ -493,7 +493,7 @@ class Account(BlockchainObject): if total_down_vp > 100: return 100 if total_down_vp < 0: - return 0 + return 0 return total_down_vp def get_vests(self, only_own_vests=False): @@ -795,7 +795,7 @@ class Account(BlockchainObject): elif raw_data: ret = self.steem.rpc.get_blog({'account': account, 'start_entry_id': start_entry_id, 'limit': limit}, api='follow') if isinstance(ret, dict) and "blog" in ret: - ret = ret["blog"] + ret = ret["blog"] return [ c for c in ret ] @@ -809,18 +809,18 @@ class Account(BlockchainObject): ] except: success = False - + if not self.steem.rpc.get_use_appbase() or not success: if raw_data and short_entries: return [ c for c in self.steem.rpc.get_blog_entries(account, start_entry_id, limit, api='follow') ] - + elif raw_data: return [ c for c in self.steem.rpc.get_blog(account, start_entry_id, limit, api='follow') ] - + else: from .comment import Comment return [ @@ -928,7 +928,7 @@ class Account(BlockchainObject): elif direction == "following": followers = self.steem.rpc.get_following(query, api='follow') if isinstance(followers, dict) and 'following' in followers: - followers = followers['following'] + followers = followers['following'] else: if direction == "follower": followers = self.steem.rpc.get_followers(self.name, last_user, what, limit, api='follow') @@ -1053,7 +1053,7 @@ class Account(BlockchainObject): balances = self.total_balances else: return - + if isinstance(symbol, dict) and "symbol" in symbol: symbol = symbol["symbol"] @@ -1152,7 +1152,7 @@ class Account(BlockchainObject): vesting_shares = self["vesting_shares"].amount if reserve_ratio is None or reserve_ratio["max_virtual_bandwidth"] is None: return {"used": None, - "allocated": None} + "allocated": None} max_virtual_bandwidth = float(reserve_ratio["max_virtual_bandwidth"]) total_vesting_shares = Amount(global_properties["total_vesting_shares"], steem_instance=self.steem).amount allocated_bandwidth = (max_virtual_bandwidth * (vesting_shares + received_vesting_shares) / total_vesting_shares) @@ -1510,7 +1510,7 @@ class Account(BlockchainObject): ret = self.steem.rpc.list_votes({"start": [account, start_author, start_permlink], "limit": 1000, "order": "by_voter_comment"}, api="database")["votes"] if start_author != "": if len(ret) == 0: - finished = True + finished = True ret = ret[1:] for vote in ret: if vote["voter"] != account: diff --git a/beem/amount.py b/beem/amount.py index 132a55a3a4189300af303f2c05a739acfe36c863..b596041adee95ed54b7e9bac784452df2518a578 100644 --- a/beem/amount.py +++ b/beem/amount.py @@ -117,8 +117,6 @@ class Amount(dict): self["symbol"] = self["asset"]["symbol"] self["amount"] = Decimal(amount["amount"]) / Decimal(10 ** self["asset"]["precision"]) - - elif isinstance(amount, (float)) and asset and isinstance(asset, Asset): self["amount"] = str(amount) self["asset"] = asset @@ -272,6 +270,7 @@ class Amount(dict): def __floordiv__(self, other): a = self.copy() if isinstance(other, Amount): + from .price import Price check_asset(other["asset"], self["asset"]) return Price(self, other, steem_instance=self.steem) else: diff --git a/beem/cli.py b/beem/cli.py index 6f23e29a5b4bb715179dd8cedad0ce446a548595..a86cbe8fe95a1020885d12a6598d394a3a0f7d15 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -1537,7 +1537,6 @@ def uploadimage(image, account, image_name): stm.rpc.rpcconnect() if not account: account = stm.config["default_account"] - author = account if not unlock_wallet(stm): return iu = ImageUploader(steem_instance=stm) @@ -2540,7 +2539,7 @@ def curation(authorperm, account, limit, min_vote, max_vote, min_performance, ma stm.rpc.rpcconnect() if authorperm is None: authorperm = 'all' - if account is None and authorperm is not 'all': + if account is None and authorperm != 'all': show_all_voter = True else: show_all_voter = False diff --git a/beem/comment.py b/beem/comment.py index 7403d06573f9b79e3a1bb79b166ffeb4632399b9..ab737db47b6ff1b8d967e95446328d7dba651350 100644 --- a/beem/comment.py +++ b/beem/comment.py @@ -152,7 +152,7 @@ class Comment(BlockchainObject): if self.use_tags_api: content = self.steem.rpc.get_discussion({'author': author, 'permlink': permlink}, api="tags") else: - content =self.steem.rpc.list_comments({"start":[author, permlink], "limit":1, "order":"by_permlink"}, api="database") + content =self.steem.rpc.list_comments({"start": [author, permlink], "limit": 1, "order": "by_permlink"}, api="database") if content is not None and "comments" in content: content =content["comments"] if isinstance(content, list) and len(content) >0: diff --git a/beem/price.py b/beem/price.py index 74afde0f1bbf8fc5bd7215a05c164c15cb2a7150..2b956775de8691f1a497bebd6460662f438dc07e 100644 --- a/beem/price.py +++ b/beem/price.py @@ -83,7 +83,7 @@ class Price(dict): ): self.steem = steem_instance or shared_steem_instance() - if price is "": + if price == "": price = None if (price is not None and isinstance(price, string_types) and not base and not quote): import re diff --git a/beem/wallet.py b/beem/wallet.py index d7edee03278f800d48bef4df715d1d02bc7ffda2..ca62df908769d21c360166ac699b5ae0d2d431bf 100644 --- a/beem/wallet.py +++ b/beem/wallet.py @@ -110,7 +110,7 @@ class Wallet(object): # Manually provided keys keys = {} # struct with pubkey as key and wif as value token = {} - keyMap = {} # type:wif pairs to force certain keys + keyMap = {} # wif pairs to force certain keys def __init__(self, steem_instance=None, *args, **kwargs): self.steem = steem_instance or shared_steem_instance() diff --git a/beemapi/graphenerpc.py b/beemapi/graphenerpc.py index cbcd0a784b398077e3ab676a4bb2204afde85098..a82f36daf61985ba2379bc52afcc480ee6129a1d 100644 --- a/beemapi/graphenerpc.py +++ b/beemapi/graphenerpc.py @@ -459,7 +459,7 @@ class GrapheneRPC(object): api_name = get_api_name(self.is_appbase_ready(), *args, **kwargs) if self.is_appbase_ready() and self.use_condenser: api_name = "condenser_api" - if (api_name == None): + if (api_name is None): api_name = 'database_api' # let's be able to define the num_retries per query diff --git a/beemapi/steemnoderpc.py b/beemapi/steemnoderpc.py index a2084a33ecebb5e8eec672451cc0d4d221294de3..6d6705c4247d9226b9ef8b6db23359ff1fdb381f 100644 --- a/beemapi/steemnoderpc.py +++ b/beemapi/steemnoderpc.py @@ -117,7 +117,7 @@ class SteemNodeRPC(GrapheneRPC): raise exceptions.NoMethodWithName(msg) elif re.search("Could not find API", msg): if self._check_api_name(msg): - if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: + if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: self.nodes.disable_node() self._switch_to_next_node(msg, "ApiNotSupported") doRetry = True @@ -151,7 +151,7 @@ class SteemNodeRPC(GrapheneRPC): elif re.search("Assert Exception:v.is_object(): Input data have to treated as object", msg): raise exceptions.UnhandledRPCError("Use Operation(op, appbase=True) to prevent error: " + msg) elif re.search("Client returned invalid format. Expected JSON!", msg): - if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: + if self.nodes.working_nodes_count > 1 and self.nodes.num_retries > -1: self.nodes.disable_node() self._switch_to_next_node(msg) doRetry = True diff --git a/beembase/operations.py b/beembase/operations.py index c941dd44e4955e1798637a67507e8d0357a9c246..775e74d9ac0a0f5d3e3bb2deda70261e28e54553 100644 --- a/beembase/operations.py +++ b/beembase/operations.py @@ -31,6 +31,7 @@ from .objects import ( Beneficiaries, Beneficiary, CommentOptionExtensions, + SocialActionVariant ) default_prefix = "STM" @@ -38,8 +39,8 @@ default_prefix = "STM" def check_for_class(self, args): if isArgsThisClass(self, args): - self.data = args[0].data - return True + self.data = args[0].data + return True else: return False @@ -300,8 +301,7 @@ class Account_update2(GrapheneObject): posting = Optional(Permission(kwargs["posting"], prefix=prefix)) else: posting = Optional(None) - - + if "memo_key" in kwargs: memo_key = Optional(Permission(kwargs["memo_key"], prefix=prefix)) else: @@ -360,7 +360,6 @@ class Update_proposal_votes(GrapheneObject): return if len(args) == 1 and len(kwargs) == 0: kwargs = args[0] - prefix = kwargs.get("prefix", default_prefix) extensions = Array([]) proposal_ids = [] for e in kwargs["proposal_ids"]: @@ -958,7 +957,7 @@ class Social_action(GrapheneObject): # handle action action = kwargs.get('action') - if action == None: + if action is None: action_obj = kwargs.get('social_action_comment_create') action_id = 0 if action_obj and type(action_obj) == dict: