Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_export(self):
bts = self.bts
if bts.rpc.get_use_appbase():
content = bts.rpc.get_discussion({'author': self.author, 'permlink': self.permlink}, api="tags")
else:
content = bts.rpc.get_content(self.author, self.permlink)
c = Comment(self.authorperm, steem_instance=bts)
keys = list(content.keys())
json_content = c.json()
exclude_list = ["json_metadata", "reputation", "active_votes"]
for k in keys:
if k not in exclude_list:
if isinstance(content[k], dict) and isinstance(json_content[k], list):
self.assertEqual(list(content[k].values()), json_content[k])
elif isinstance(content[k], str) and isinstance(json_content[k], str):
self.assertEqual(content[k].encode('utf-8'), json_content[k].encode('utf-8'))
else:
self.assertEqual(content[k], json_content[k])
def curation_action(action, author, permlink, curator):
try:
authorperm = construct_authorperm(author, permlink)
post = Comment(authorperm)
app = post.json_metadata.get('app', None).split('/')[0]
isTfio = app == "travelfeed"
if post["author"] in blacklist:
return
elif action == "curate":
try:
if(isTfio):
post.upvote(weight=100, voter=curationaccount)
else:
post.upvote(weight=90, voter=curationaccount)
except Exception as error:
logger.critical("Could not upvote post "+repr(error))
try:
write_comment(post, resteemtext.format(
curator), isTfio)
except Exception as error:
print(str(e))
# Public Key
elif re.match("^" + stm.prefix + ".{48,55}$", obj):
account = stm.wallet.getAccountFromPublicKey(obj)
if account:
account = Account(account, steem_instance=stm)
key_type = stm.wallet.getKeyType(account, obj)
t = PrettyTable(["Account", "Key_type"])
t.align = "l"
t.add_row([account["name"], key_type])
print(t)
else:
print("Public Key %s not known" % obj)
# Post identifier
elif re.match(".*@.{3,16}/.*$", obj):
post = Comment(obj, steem_instance=stm)
post_json = post.json()
if post_json:
t = PrettyTable(["Key", "Value"])
t.align = "l"
for key in sorted(post_json):
if key in ["body", "active_votes"]:
value = "not shown"
else:
value = post_json[key]
if (key in ["json_metadata"]):
value = json.loads(value)
value = json.dumps(value, indent=4)
elif (key in ["tags", "active_votes"]):
value = json.dumps(value, indent=4)
t.add_row([key, value])
print(t)
except Exception as e:
error_msg = str(e)
history_count = -1
successful = False
try:
stm = Steem(node=node, num_retries=3, num_retries_call=3, timeout=30)
account = Account("gtg", steem_instance=stm)
blockchain_version = stm.get_blockchain_version()
start = timer()
Vote(authorpermvoter, steem_instance=stm)
stop = timer()
vote_time = stop - start
start = timer()
Comment(authorperm, steem_instance=stm)
stop = timer()
comment_time = stop - start
start = timer()
Account(author, steem_instance=stm)
stop = timer()
account_time = stop - start
start = timer()
account.get_followers()
stop = timer()
follow_time = stop - start
access_time = (vote_time + comment_time + account_time + follow_time) / 4.0
except NumRetriesReached:
error_msg = 'NumRetriesReached'
access_time = -1
except KeyboardInterrupt:
error_msg = 'KeyboardInterrupt'
def resteem(identifier, account):
"""Resteem an existing post"""
stm = shared_steem_instance()
if stm.rpc is not None:
stm.rpc.rpcconnect()
if not account:
account = stm.config["default_account"]
if not unlock_wallet(stm):
return
acc = Account(account, steem_instance=stm)
post = Comment(identifier, steem_instance=stm)
tx = post.resteem(account=acc)
if stm.unsigned and stm.nobroadcast and stm.steemconnect is not None:
tx = stm.steemconnect.url_from_tx(tx)
tx = json.dumps(tx, indent=4)
print(tx)
async def lang0(ctx, link):
curator = re.sub(r'\d{4}|\W|(TravelFeed)','',str(ctx.message.author),re.IGNORECASE|re.DOTALL)
if not ctx.message.channel.id == commandchannel:
await send_discord("Bot commands are only allowed in #bot-commands", ctx.message.channel.id)
return
if not ctx.message.author.id in discordcuratorlist:
await send_discord("Curator unauthorised: "+curator, logchannel)
return
await bot.add_reaction(ctx.message, "⏳")
author, permlink = resolve_authorperm(link)
authorperm = construct_authorperm(author, permlink)
post = Comment(authorperm)
actionqueue.put(Post_Action(post, "lang0", None, ctx.message))
def get_parent(self, children=None):
""" Returns the parent post with depth == 0"""
if children is None:
children = self
while children["depth"] > 0:
children = Comment(construct_authorperm(children["parent_author"], children["parent_permlink"]), steem_instance=self.steem)
return children