<commit_before>import re
import requests


yql = "select * from yahoo.finance.quotes where symbol = \"{0}\""
message = "{name} ({symbol}) {last_price} {change} ({change_percent}) {market_cap}"

def run(data, settings):
    match_re = re.compile(r'^stock (?P<symbol>\w{,4})$').match
    match = match_re(data['payload'])
    if match:
        symbol = match.groupdict()['symbol']
        response = requests.get('http://query.yahooapis.com/v1/public/yql', params={
            "q":yql.format(symbol),
            "env": "http://datatables.org/alltables.env",
            "format":"json"
        }).json()

        quote = response["query"]["results"]["quote"]
        if quote["ErrorIndicationreturnedforsymbolchangedinvalid"]:
            return

        return message.format(**{
            "name": quote["Name"],
            "symbol": quote["symbol"],
            "last_price": quote["LastTradePriceOnly"],
            "change": quote["ChangeRealtime"],
            "change_percent": quote["ChangeinPercent"],
            "market_cap": quote["MarketCapitalization"]
        })<commit_msg>consistency<commit_after>import re
import requests


yql = 'select * from yahoo.finance.quotes where symbol = \'{0}\''
yql_url = 'http://query.yahooapis.com/v1/public/yql'
message = '{name} ({symbol}) {last_price} {change} ({change_percent}) {market_cap}'

def run(data, settings):
    match_re = re.compile(r'^stock (?P<symbol>\w{,4})$').match
    match = match_re(data['payload'])
    if match:
        symbol = match.groupdict()['symbol']
        response = requests.get(yql_url, params={
            'q': yql.format(symbol),
            'env': 'http://datatables.org/alltables.env',
            'format':'json'
        }).json()

        quote = response['query']['results']['quote']
        if quote['ErrorIndicationreturnedforsymbolchangedinvalid']:
            return

        return message.format(**{
            'name': quote['Name'],
            'symbol': quote['symbol'],
            'last_price': quote['LastTradePriceOnly'],
            'change': quote['ChangeRealtime'],
            'change_percent': quote['ChangeinPercent'],
            'market_cap': quote['MarketCapitalization']
        })
{'fraction_non_alphanumeric': 0.17326057298772168, 'fraction_numerical': 0.002728512960436562, 'mean_word_length': 2.852889667250438, 'pattern_counts': {'":': 9, '<': 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': '2959410', 'n_tokens_mistral': 657, 'n_tokens_neox': 642, 'n_words': 117}