def get(self, currency, address): """ Returns addresses' neighbors in the address graph as CSV """ args = neighbors_parser.parse_args() direction = args.get("direction") check_inputs(address=address, currency=currency) if "in" in direction: def query_function(page_state): return addressesDAO.list_address_incoming_relations( currency, address, page_state) direction = 'incoming' else: def query_function(page_state): return addressesDAO.list_address_outgoing_relations( currency, address, page_state) direction = 'outgoing' try: return Response(to_csv(query_function), mimetype="text/csv", headers=create_download_header( '{} neighbors of address {} ({}).csv' .format(direction, address, currency.upper()))) except ValueError: abort(404, "Address {} not found in currency {}" .format(address, currency))
def get(self, currency, height): """ Returns a CSV with all the transactions of the block """ check_inputs(currency=currency, height=height) def query_function(_): result = blocksDAO.list_block_txs(currency, height) if result: txs = result["txs"] block_height = result["height"] for tx in txs: tx['block_height'] = block_height return None, txs abort(404, "Block {} not found in currency {}".format(height, currency)) try: return Response(to_csv(query_function), mimetype="text/csv", headers=create_download_header( 'transactions of block {} ({}).csv'.format( height, currency.upper()))) except ValueError: abort(404, "Block {} not found in currency {}".format(height, currency))
def list_address_txs_csv(currency, address): def query_function(page_state): result = list_address_txs(currency, address, page_state) return (result.next_page, result.address_txs) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'transactions of address {} ({}).csv' .format(address, currency.upper())))
def list_address_links_csv(currency, address, neighbor): def query_function(_): result = list_address_links(currency, address, neighbor) return (None, result) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'transactions between {} and {} ({}).csv' .format(address, neighbor, currency.upper())))
def list_entity_tags_csv(currency, entity): def query_function(_): tags = list_entity_tags(currency, entity) return (None, tags) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'tags of entity {} ({}).csv'.format( entity, currency.upper())))
def list_entity_addresses_csv(currency, entity): def query_function(page_state): result = list_entity_addresses(currency, entity, page_state) return (result.next_page, result.addresses) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'addresses of entity {} ({}).csv'.format( entity, currency.upper())))
def list_address_tags_csv(currency, address): def query_function(_): tags = commonDAO.list_address_tags(currency, address) return (None, tags) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'tags of address {} ({}).csv' .format(address, currency.upper())))
def list_address_neighbors_csv(currency, address, direction): def query_function(page_state): result = list_address_neighbors(currency, address, direction, page_state) return (result.next_page, result.neighbors) return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( '{} neighbors of address {} ({}).csv' .format(direction, address, currency.upper())))
def list_block_txs_csv(currency, height): def query_function(_): result = list_block_txs(currency, height) txs = [tx.to_dict() for tx in result.txs] for tx in txs: tx['block_height'] = result.height return None, txs return Response(stream_with_context(to_csv(query_function)), mimetype="text/csv", headers=create_download_header( 'transactions of block {} ({}).csv'.format( height, currency.upper())))
def get(self, currency, entity): """ Returns attribution tags for a given entity as CSV """ check_inputs(currency=currency, entity=entity) def query_function(_): return (None, entitiesDAO.list_entity_tags(currency, int(entity))) return Response(to_csv(query_function), mimetype="text/csv", headers=create_download_header('tags of entity {} ' '({}).csv'.format( entity, currency.upper())))
def get(self, currency, address): """ Returns attribution tags for a given address as CSV """ check_inputs(address=address, currency=currency) # abort if fails def query_function(_): return (None, commonDAO.list_address_tags( currency, address)) return Response(to_csv(query_function), mimetype="text/csv", headers=create_download_header('tags of address {} ' '({}).csv' .format(address, currency .upper())))
def get(self, currency, entity): """ Returns an entities' neighbors in the entity graph as CSV """ # TODO: rather slow with 1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s args = neighbors_parser.parse_args() direction = args.get("direction") check_inputs(currency=currency, entity=entity) is_outgoing = "out" in direction def query_function(page_state): return entitiesDAO.list_entity_relations(currency, entity, is_outgoing, None, page_state) direction = "outgoing" if is_outgoing else "incoming" return Response(to_csv(query_function), mimetype="text/csv", headers=create_download_header( '{} neighbors of entity {} ({}).csv'.format( direction, entity, currency.upper())))