def inspect_dpayd_implementation(): """ Compare implemented methods with current live deployment of dpayd. """ _apis = distinct(pluck('api', api_methods)) _methods = set(pluck('method', api_methods)) avail_methods = [] s = DPay(re_raise=False) for api in _apis: err = s.exec('nonexistentmethodcall', api=api) [ avail_methods.append(x) for x in err['data']['stack'][0]['data']['api'].keys() ] avail_methods = set(avail_methods) print("\nMissing Methods:") pprint(avail_methods - _methods) print("\nLikely Deprecated Methods:") pprint(_methods - avail_methods)
async def load_sub_questionnaire(client, root_elements, parent_item, item): if "subQuestionnaire" in item: sub = await client.resources("Questionnaire").get( id=item["subQuestionnaire"]) variables = prepare_variables(item) if validate_assemble_context(sub, variables): sub = prepare_link_ids(sub, variables) propagate = project(dict(sub), PROPAGATE_ELEMENTS) dict.update(parent_item, propagate) root = project(dict(sub), WHITELISTED_ROOT_ELEMENTS.keys()) for key, value in root.items(): uniqueness = WHITELISTED_ROOT_ELEMENTS[key] current = root_elements.get(key, []) new = concat(current, value) root_elements[key] = distinct(new, uniqueness) return sub["item"] return item
async def load_sub_questionanire(root_elements, parent_item, item): if "subQuestionnaire" in item: sub = await sdk.client.resources("Questionnaire").get( id=item.subQuestionnaire) varaibles = prepare_varaibles(item) sub = prepare_bundle(sub, varaibles) propogate = project(dict(sub), PROPOGATE_ELEMENTS) dict.update(parent_item, propogate) root = project(dict(sub), WHITELISTED_ROOT_ELEMENTS.keys()) for key, value in root.items(): uniqness = WHITELISTED_ROOT_ELEMENTS[key] current = root_elements.get(key, []) new = concat(current, value) root_elements[key] = distinct(new, uniqness) return sub["item"] return item
def inspect_steemd_implementation(): """ Compare implemented methods with current live deployment of steemd. """ _apis = distinct(pluck('api', api_methods)) _methods = set(pluck('method', api_methods)) avail_methods = [] s = Steem(re_raise=False) for api in _apis: err = s.exec('nonexistentmethodcall', api=api) [ avail_methods.append(x) for x in err['data']['stack'][0]['data']['api'].keys() ] avail_methods = set(avail_methods) print("\nMissing Methods:") pprint(avail_methods - _methods) print("\nLikely Deprecated Methods:") pprint(_methods - avail_methods)
def post_basic(post): """Basic post normalization: json-md, tags, and flags.""" md = {} # At least one case where jsonMetadata was double-encoded: condenser#895 # jsonMetadata = JSON.parse(jsonMetadata); try: md = json.loads(post['json_metadata']) if not isinstance(md, dict): md = {} except Exception: pass thumb_url = '' if md and 'image' in md: if md['image']: if not isinstance(md['image'], list): md['image'] = [md['image']] md['image'] = list(filter(None, map(safe_img_url, md['image']))) if md['image']: thumb_url = md['image'][0] else: del md['image'] # clean up tags, check if nsfw tags = [post['category']] # if (typeof tags == 'string') tags = tags.split(' '); # legacy condenser compat if md and 'tags' in md and isinstance(md['tags'], list): tags = tags + md['tags'] tags = map(lambda tag: (str(tag) or '').strip('# ').lower()[:32], tags) tags = filter(None, tags) tags = list(distinct(tags))[:5] is_nsfw = 'nsfw' in tags body = post['body'] if body.find('\x00') > -1: #url = post['author'] + '/' + post['permlink'] body = body.replace('\x00', '[NUL]') # payout date is last_payout if paid, and cashout_time if pending. is_paidout = (post['cashout_time'][0:4] == '1969') payout_at = post['last_payout'] if is_paidout else post['cashout_time'] # payout is declined if max_payout = 0, or if 100% is burned is_payout_declined = False if sbd_amount(post['max_accepted_payout']) == 0: is_payout_declined = True elif len(post['beneficiaries']) == 1: benny = first(post['beneficiaries']) if benny['account'] == 'null' and int(benny['weight']) == 10000: is_payout_declined = True # payout entirely in SP is_full_power = int(post['percent_steem_dollars']) == 0 return { 'json_metadata': md, 'image': thumb_url, 'tags': tags, 'is_nsfw': is_nsfw, 'body': body, 'preview': body[0:1024], 'payout_at': payout_at, 'is_paidout': is_paidout, 'is_payout_declined': is_payout_declined, 'is_full_power': is_full_power, }