From 3665da5a7d01b9ebc9feee761e323d0717be8919 Mon Sep 17 00:00:00 2001 From: Holger Nahrstaedt <holgernahrstaedt@gmx.de> Date: Tue, 21 Apr 2020 07:38:59 +0200 Subject: [PATCH] Fix invalid escape sequence --- CHANGELOG.rst | 3 +++ beem/blockchaininstance.py | 6 +++--- beem/cli.py | 10 +++++----- beem/hive.py | 2 +- beem/utils.py | 16 ++++++++-------- beemapi/graphenerpc.py | 2 ++ setup.py | 2 +- tests/beem/test_cli.py | 4 +++- 8 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f42f1a34..a6bca6e2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,7 @@ Changelog ========= 0.23.0 ------ +* new chain ID for HF24 on HIVE has been added * set hive as default for default_chain * get_steem_nodes added to NodeList * Prepared for Hive HF 24 @@ -16,6 +17,8 @@ Changelog * Rshares, vote percentage and SBD/HBD calculation has been fixed for votes * post_rshares parameter added to all vote calculations * Account class has now get_token_power(), get_voting_value() and get_vote_pct_for_vote_value() +* HF 23 and HF24 operations were added thanks to @flugschwein +* Downvote power was added to Snapshot thanks to @flugschwein 0.22.14 ------- diff --git a/beem/blockchaininstance.py b/beem/blockchaininstance.py index 0754188c..0c8c90f4 100644 --- a/beem/blockchaininstance.py +++ b/beem/blockchaininstance.py @@ -1670,17 +1670,17 @@ class BlockChainInstance(object): if parse_body: def get_urls(mdstring): - return list(set(re.findall('http[s]*://[^\s"><\)\(]+', mdstring))) + return list(set(re.findall(r'http[s]*://[^\s"><\)\(]+', mdstring))) def get_users(mdstring): users = [] - for u in re.findall('(^|[^a-zA-Z0-9_!#$%&*@ï¼ \/]|(^|[^a-zA-Z0-9_+~.-\/#]))[@ï¼ ]([a-z][-\.a-z\d]+[a-z\d])', mdstring): + for u in re.findall(r'(^|[^a-zA-Z0-9_!#$%&*@ï¼ \/]|(^|[^a-zA-Z0-9_+~.-\/#]))[@ï¼ ]([a-z][-\.a-z\d]+[a-z\d])', mdstring): users.append(list(u)[-1]) return users def get_hashtags(mdstring): hashtags = [] - for t in re.findall('(^|\s)(#[-a-z\d]+)', mdstring): + for t in re.findall(r'(^|\s)(#[-a-z\d]+)', mdstring): hashtags.append(list(t)[-1]) return hashtags diff --git a/beem/cli.py b/beem/cli.py index d3b86b51..475e4326 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -3590,9 +3590,9 @@ def info(objects): print(t.get_string(sortby="Key")) # Block for obj in objects: - if re.match("^[0-9-]*$", obj) or re.match("^-[0-9]*$", obj) or re.match("^[0-9-]*:[0-9]", obj) or re.match("^[0-9-]*:-[0-9]", obj): + if re.match(r"^[0-9-]*$", obj) or re.match(r"^-[0-9]*$", obj) or re.match(r"^[0-9-]*:[0-9]", obj) or re.match(r"^[0-9-]*:-[0-9]", obj): tran_nr = '' - if re.match("^[0-9-]*:[0-9-]", obj): + if re.match(r"^[0-9-]*:[0-9-]", obj): obj, tran_nr = obj.split(":") if int(obj) < 1: b = Blockchain(blockchain_instance=stm) @@ -3630,7 +3630,7 @@ def info(objects): print(t) else: print("Block number %s unknown" % obj) - elif re.match("^[a-zA-Z0-9\-\._]{2,16}$", obj): + elif re.match(r"^[a-zA-Z0-9\-\._]{2,16}$", obj): account = Account(obj, blockchain_instance=stm) t = PrettyTable(["Key", "Value"]) t.align = "l" @@ -3665,7 +3665,7 @@ def info(objects): except exceptions.WitnessDoesNotExistsException as e: print(str(e)) # Public Key - elif re.match("^" + stm.prefix + ".{48,55}$", obj): + elif re.match(r"^" + stm.prefix + ".{48,55}$", obj): account = stm.wallet.getAccountFromPublicKey(obj) if account: account = Account(account, blockchain_instance=stm) @@ -3677,7 +3677,7 @@ def info(objects): else: print("Public Key %s not known" % obj) # Post identifier - elif re.match(".*@.{3,16}/.*$", obj): + elif re.match(r".*@.{3,16}/.*$", obj): post = Comment(obj, blockchain_instance=stm) post_json = post.json() if post_json: diff --git a/beem/hive.py b/beem/hive.py index 6726e4e5..8868b74a 100644 --- a/beem/hive.py +++ b/beem/hive.py @@ -435,4 +435,4 @@ class Hive(BlockChainInstance): @property def vests_symbol(self): """ get the current chains symbol for VESTS """ - return self.vests_token_symbol + return self.vest_token_symbol diff --git a/beem/utils.py b/beem/utils.py index 6b27e701..5c410cdb 100644 --- a/beem/utils.py +++ b/beem/utils.py @@ -98,14 +98,14 @@ def assets_from_string(text): Splits the string into two assets with the separator being on of the following: ``:``, ``/``, or ``-``. """ - return re.split(r"[\-:/]", text) + return re.split(r"[\-:\/]", text) def sanitize_permlink(permlink): permlink = permlink.strip() - permlink = re.sub("_|\s|\.", "-", permlink) - permlink = re.sub("[^\w-]", "", permlink) - permlink = re.sub("[^a-zA-Z0-9-]", "", permlink) + permlink = re.sub(r"_|\s|\.", "-", permlink) + permlink = re.sub(r"[^\w-]", "", permlink) + permlink = re.sub(r"[^a-zA-Z0-9-]", "", permlink) permlink = permlink.lower() return permlink @@ -154,15 +154,15 @@ def resolve_authorperm(identifier): """ # without any http(s) - match = re.match("@?([\w\-\.]*)/([\w\-]*)", identifier) + match = re.match(r"@?([\w\-\.]*)/([\w\-]*)", identifier) if hasattr(match, "group"): return match.group(1), match.group(2) # dtube url - match = re.match("([\w\-\.]+[^#?\s]+)/#!/v/?([\w\-\.]*)/([\w\-]*)", identifier) + match = re.match(r"([\w\-\.]+[^#?\s]+)/#!/v/?([\w\-\.]*)/([\w\-]*)", identifier) if hasattr(match, "group"): return match.group(2), match.group(3) # url - match = re.match("([\w\-\.]+[^#?\s]+)/@?([\w\-\.]*)/([\w\-]*)", identifier) + match = re.match(r"([\w\-\.]+[^#?\s]+)/@?([\w\-\.]*)/([\w\-]*)", identifier) if not hasattr(match, "group"): raise ValueError("Invalid identifier") return match.group(2), match.group(3) @@ -195,7 +195,7 @@ def construct_authorperm(*args): def resolve_root_identifier(url): - m = re.match("/([^/]*)/@([^/]*)/([^#]*).*", url) + m = re.match(r"/([^/]*)/@([^/]*)/([^#]*).*", url) if not m: return "", "" else: diff --git a/beemapi/graphenerpc.py b/beemapi/graphenerpc.py index 84dffaa2..61ef1cdf 100644 --- a/beemapi/graphenerpc.py +++ b/beemapi/graphenerpc.py @@ -304,10 +304,12 @@ class GrapheneRPC(object): chain_id = None network_version = None is_hive = False + is_steem = False for key in props: if key[-8:] == "CHAIN_ID": chain_id = props[key] is_hive = key[:4] == "HIVE" + is_steem = key[:5] == "STEEM" elif key[-18:] == "BLOCKCHAIN_VERSION": network_version = props[key] diff --git a/setup.py b/setup.py index b2c8e482..11e1a410 100755 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ except LookupError: ascii = codecs.lookup('ascii') codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs')) -VERSION = '0.23.0' +VERSION = '0.23.1' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized'] diff --git a/tests/beem/test_cli.py b/tests/beem/test_cli.py index ed01740f..8514c081 100644 --- a/tests/beem/test_cli.py +++ b/tests/beem/test_cli.py @@ -131,8 +131,10 @@ class Testcases(unittest.TestCase): def test_info2(self): runner = CliRunner() - result = runner.invoke(cli, ['info', '--', '-1:1']) + result = runner.invoke(cli, ['info', '--', '42725832:-1']) self.assertEqual(result.exit_code, 0) + result = runner.invoke(cli, ['info', '--', '42725832:1']) + self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['info', 'gtg']) self.assertEqual(result.exit_code, 0) result = runner.invoke(cli, ['info', "@gtg/witness-gtg-log"]) -- GitLab