From 9d2244f2e5f25404740d8acc41b41dab366bea5e Mon Sep 17 00:00:00 2001 From: Holger Nahrstaedt <holgernahrstaedt@gmx.de> Date: Thu, 4 Jun 2020 23:47:34 +0200 Subject: [PATCH] add repl.it --- .replit | 2 ++ README.rst | 3 +++ beem/cli.py | 15 +++++++++------ beem/version.py | 2 +- beemapi/version.py | 2 +- beembase/version.py | 2 +- beemgraphenebase/version.py | 2 +- setup.py | 2 +- 8 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 .replit diff --git a/.replit b/.replit new file mode 100644 index 00000000..6e7a0f4a --- /dev/null +++ b/.replit @@ -0,0 +1,2 @@ +language = "python3" +run = "python beem/cli.py" diff --git a/README.rst b/README.rst index a6983b02..8347b2a6 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,9 @@ The library name is derived from a beam machine, similar to the analogy between :target: https://anaconda.org/conda-forge/beem +.. image:: https://repl.it/badge/github/holgern/beem + :target: https://repl.it/github/holgern/beem + Current build status -------------------- diff --git a/beem/cli.py b/beem/cli.py index d7ef2099..cfe314f3 100644 --- a/beem/cli.py +++ b/beem/cli.py @@ -4366,12 +4366,12 @@ def featureflags(account, signing_account): @click.option('--draws', '-d', help='Number of draws (default = 1)', default=1) @click.option('--participants', '-p', help='Number of participants or file name including participants (one participant per line), (default = 100)', default="100") @click.option('--hashtype', '-h', help='Can be md5, sha256, sha512 (default = sha256)', default="sha256") -@click.option('--seperator', '-s', help='Is used for sha256 and sha512 to seperate the draw number from the seed (default = ,)', default=",") +@click.option('--separator', '-s', help='Is used for sha256 and sha512 to seperate the draw number from the seed (default = ,)', default=",") @click.option('--account', '-a', help='The account which broadcasts the reply') @click.option('--reply', '-r', help='Parent post/comment authorperm. When set, the results will be broadcasted as reply to this authorperm.', default=None) @click.option('--without-replacement', '-w', help='When set, numbers are drawed without replacement.', is_flag=True, default=False) @click.option('--markdown', '-m', help='When set, results are returned in markdown format', is_flag=True, default=False) -def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply, without_replacement, markdown): +def draw(block, trx_id, draws, participants, hashtype, separator, account, reply, without_replacement, markdown): """ Generate pseudo-random numbers based on trx id, block id and previous block id. When using --reply, the result is directly broadcasted as comment @@ -4391,12 +4391,15 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply blockchain = Blockchain(blockchain_instance=stm) block = blockchain.get_current_block() data = None + for trx in block.transactions: if trx["transaction_id"] == trx_id: data = trx elif trx_id is None: trx_id = trx["transaction_id"] data = trx + if trx_id is None: + trx_id = "0" if os.path.exists(participants): with open(participants) as f: @@ -4437,11 +4440,11 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply if hashtype == "md5": number = int(random.random() * len(draw_list)) elif hashtype == "sha256": - seed = hashlib.sha256((trx_id + block["block_id"] + block["previous"] + seperator +str(i + 1)).encode()).digest() + seed = hashlib.sha256((trx_id + block["block_id"] + block["previous"] + separator +str(i + 1)).encode()).digest() bigRand = int.from_bytes(seed, 'big') number = bigRand % (len(draw_list)) elif hashtype == "sha512": - seed = hashlib.sha512((trx_id + block["block_id"] + block["previous"] + seperator +str(i + 1)).encode()).digest() + seed = hashlib.sha512((trx_id + block["block_id"] + block["previous"] + separator +str(i + 1)).encode()).digest() bigRand = int.from_bytes(seed, 'big') number = bigRand % (len(draw_list)) results.append(draw_list[number]) @@ -4455,9 +4458,9 @@ def draw(block, trx_id, draws, participants, hashtype, seperator, account, reply body = "The following results can be checked with:\n" body += "```\n" if without_replacement: - body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s' -w\n" % (draws, participants, block["id"], trx_id, hashtype, seperator) + body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s' -w\n" % (draws, participants, block["id"], trx_id, hashtype, separator) else: - body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s'\n" % (draws, participants, block["id"], trx_id, hashtype, seperator) + body += "beempy draw -d %d -p %d -b %d -t %s -h %s -s '%s'\n" % (draws, participants, block["id"], trx_id, hashtype, separator) body += "```\n\n" body += "| key | value |\n" body += "| --- | --- |\n" diff --git a/beem/version.py b/beem/version.py index 6788b518..07b16fba 100644 --- a/beem/version.py +++ b/beem/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beemapi/version.py b/beemapi/version.py index 6788b518..07b16fba 100644 --- a/beemapi/version.py +++ b/beemapi/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beembase/version.py b/beembase/version.py index 6788b518..07b16fba 100644 --- a/beembase/version.py +++ b/beembase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/beemgraphenebase/version.py b/beemgraphenebase/version.py index 6788b518..07b16fba 100644 --- a/beemgraphenebase/version.py +++ b/beemgraphenebase/version.py @@ -1,2 +1,2 @@ """THIS FILE IS GENERATED FROM beem SETUP.PY.""" -version = '0.23.11' +version = '0.23.12' diff --git a/setup.py b/setup.py index 83a7359a..354f6dd8 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.11' +VERSION = '0.23.12' tests_require = ['mock >= 2.0.0', 'pytest', 'pytest-mock', 'parameterized'] -- GitLab