<commit_before>import os
import glob
import re
from flask import Flask, request, jsonify, abort, json

data_dir_root = os.environ.get('DATADIR')

app = Flask(__name__)
app.debug = True


@app.route('/addresses')
def addresses():
  currency_id = request.args.get('currency_id')
  response = []
  addr_glob = glob.glob(data_dir_root + '/addr/*.json')

  for address_file in addr_glob:
    with open(address_file, 'r') as f:
      addr = json.load(f)
      res = {
          'address': addr['address']
      }

      if currency_id == '0':
        btc_balance = [x['value'] for x in addr['balance'] if x['symbol'] == 'BTC'][0]
        res['balance'] = float(btc_balance)
        response.append(res)
      else:
        adjust_currency_id = currency_id
        if currency_id == '1' or currency_id == '2':
          adjust_currency_id = str(int(currency_id) - 1) # Mastercoin-tools is off by one on currency id from the spec

        if adjust_currency_id in addr:
          res['balance'] = float(addr[adjust_currency_id]['balance'])
          response.append(res)

  json_response = json.dumps(response)
  return json_response


@app.route('/transactions/<address>')
def transactions(address=None):
  currency_id = request.args.get('currency_id')

  print address, currency_id

  if address == None:
    abort(400)

  if not exists(address):
    abort(404)

  addr = read(address)
  transactions = []
  tx_lists = ['accept_transactions', 'bought_transactions', 'exodus_transactions', 'offer_transactions', 'received_transactions', 'sent_transactions', 'sold_transactions']
<commit_msg>Clenaed up output formatting in verification API to allow easier consensus comparisons.<commit_after>import os
import glob
import re
from flask import Flask, request, jsonify, abort, json

data_dir_root = os.environ.get('DATADIR')

app = Flask(__name__)
app.debug = True


@app.route('/addresses')
def addresses():
  currency_id = request.args.get('currency_id')
  response = []
  addr_glob = glob.glob(data_dir_root + '/addr/*.json')

  for address_file in addr_glob:
    with open(address_file, 'r') as f:
      addr = json.load(f)
      res = {
          'address': addr['address']
      }

      if currency_id == '0':
        btc_balance = [x['value'] for x in addr['balance'] if x['symbol'] == 'BTC'][0]
        res['balance'] = ('%.8f' % float(btc_balance)).rstrip('0').rstrip('.')
        response.append(res)
      else:
        adjust_currency_id = currency_id
        if currency_id == '1' or currency_id == '2':
          adjust_currency_id = str(int(currency_id) - 1) # Mastercoin-tools is off by one on currency id from the spec

        if adjust_currency_id in addr:
          res['balance'] = ('%.8f' % float(addr[adjust_currency_id]['balance'])).rstrip('0').rstrip('.')
          response.append(res)

  json_response = json.dumps(response)
  return json_response


@app.route('/transactions/<address>')
def transactions(address=None):
  currency_id = request.args.get('currency_id')

  print address, currency_id

  if address == None:
    abort(400)

  if not exists(address):
    abort(404)

  addr = read(address)
  transactions = []
  tx_lists = ['accept_transactions', 'bought_transactions', 'exodus_transactions', 'offer_transactions', 'received_transactions', 'sent_transactions', 'sold_transactions']

{'fraction_non_alphanumeric': 0.13677536231884058, 'fraction_numerical': 0.00785024154589372, 'mean_word_length': 3.685997171145686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4405590', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1052, 'n_words': 251}