<commit_before>import re
import urllib2
import traceback

try:
    import simplejson as json
except ImportError:
    import json

class Twitter(object):
    """Checks incoming messages for Twitter urls and calls the Twitter API to
    retrieve the tweet.

    TODO: 
        Implement commands for Twitter functionality

    """
    pattern = re.compile("http(s|)://(www\.|)twitter.com/#!/[^/]+/status/([0-9]+)")

    def __init__(self, *args, **kwargs):
        """Constructor."""
        pass

    def handle(self, match, **kwargs):
        try:
            data = self.fetch (match.group(3))
            return '\x02%s\x02 tweets "%s"' % (tweet['user']['name'], tweet['text'])
        except:
            print "Problem fetching tweet"
            print traceback.print_exc()


    def fetch(self, status_id):
        """Use Twitter's REST API to fetch a status."""

        api_url = 'http://api.twitter.com/1/statuses/show.json?id=%s&include_entities=true' % (status_id)

        req = urllib2.Request(api_url)
        response = urllib2.urlopen(req)
        page = response.read()

        decoded = json.loads(page)
        return decoded

<commit_msg>Updated variable name<commit_after>import re
import urllib2
import traceback

try:
    import simplejson as json
except ImportError:
    import json

class Twitter(object):
    """Checks incoming messages for Twitter urls and calls the Twitter API to
    retrieve the tweet.

    TODO: 
        Implement commands for Twitter functionality

    """
    pattern = re.compile("http(s|)://(www\.|)twitter.com/#!/[^/]+/status/([0-9]+)")

    def __init__(self, *args, **kwargs):
        """Constructor."""
        pass

    def handle(self, match, **kwargs):
        try:
            data = self.fetch (match.group(3))
            return '\x02%s\x02 tweets "%s"' % (data['user']['name'], data['text'])
        except:
            print "Problem fetching tweet"
            print traceback.print_exc()


    def fetch(self, status_id):
        """Use Twitter's REST API to fetch a status."""

        api_url = 'http://api.twitter.com/1/statuses/show.json?id=%s&include_entities=true' % (status_id)

        req = urllib2.Request(api_url)
        response = urllib2.urlopen(req)
        page = response.read()

        decoded = json.loads(page)
        return decoded


{'fraction_non_alphanumeric': 0.1368330464716007, 'fraction_numerical': 0.00946643717728055, 'mean_word_length': 2.506787330316742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '215452', 'n_tokens_mistral': 733, 'n_tokens_neox': 694, 'n_words': 184}