<commit_before>import urllib, urllib2
import json
from FbBase import FbBase

class FbUserInfo(FbBase):
    def getMyName(self):
        uri = urllib.basejoin(self.graphUri, '/me')
        uri += '?{0}'.format(urllib.urlencode({
            'access_token': self.accessToken,
        }))
        try:
            conn = urllib2.urlopen(uri, timeout=self._timeout)
            resp = json.loads(conn.read())
        except urllib2.URLError as e:
            self.logger.error('Unable to get data from Facebook. e[{0}]'.format(e))
            return None
        except ValueError as e:
            self.logger.error('Unable to parse returned data. e[{0}]'.format(e))
            return None
        if 'name' not in resp:
            self.logger.error('Unable to get name attribute from returned data. resp[{0}]'.format(json.dumps(resp)))
            return None
        return resp['name']

    def getMyEmail(self):
        uri = urllib.basejoin(self.graphUri, '/me')
        uri += '?{0}'.format(urllib.urlencode({
            'access_token': self.accessToken,
        }))
        try:
            conn = urllib2.urlopen(uri, timeout=self._timeout)
            resp = json.loads(conn.read())
        except urllib2.URLError as e:
            self.logger.error('Unable to get data from Facebook. e[{0}]'.format(e))
            return None
        except ValueError as e:
            self.logger.error('Unable to parse returned data. e[{0}]'.format(e))
            return None
        if 'email' not in resp:
            self.logger.error('Unable to get email attribute from returned data. resp[{0}]'.format(json.dumps(resp)))
            return None
        return resp['email']

    def getMyAvatar(self, type='square'):
        """
            Get Avatar link

            Note of type:
            You can specify the picture size you want with the type argument, 
            which should be one of square (50x50), small (50 pixels wide, variable height), 
            normal (100 pixels wide, variable height), 
            and large (about 200 pixels wide, variable height) 
        """
        uri = urllib.basejoin(self.graphUri, '/me/picture')
        uri += '?{0}'.format(urllib.urlencode({
            'access_token': self.accessToken,
            'type': type,
        }))
        try:
            conn = urllib2.urlopen(uri, timeout=self._timeout)
            imgUri = conn.geturl() # Facebook will trigger redirect and we need the uri not the data
        except urllib2.URLError as e:<commit_msg>Performance enhancement<commit_after>import urllib, urllib2
import json
from FbBase import FbBase

class FbUserInfo(FbBase):
    def __init__(self, *args, **kwargs):
        """
        Constructor of FbUserInfo
        """
        FbBase.__init__(self, *args, **kwargs)
        self.name, self.email = self._cacheMyInfo()

    def _cacheMyInfo(self):
        uri = urllib.basejoin(self.graphUri, '/me')
        uri += '?{0}'.format(urllib.urlencode({
            'access_token': self.accessToken,
        }))
        try:
            conn = urllib2.urlopen(uri, timeout=self._timeout)
            resp = json.loads(conn.read())
        except urllib2.URLError as e:
            self.logger.error('Unable to get data from Facebook. e[{0}]'.format(e))
            return None, None
        except ValueError as e:
            self.logger.error('Unable to parse returned data. e[{0}]'.format(e))
            return None, None
        if 'name' not in resp or 'email' not in resp:
            self.logger.error('Unable to get name or email attribute from returned data. resp[{0}]'.format(json.dumps(resp)))
            return None, None
        return resp['name'], resp['email']

    def getMyName(self):
        return self.name

    def getMyEmail(self):
        return self.email

    def getMyAvatar(self, type='square'):
        """
            Get Avatar link

            Note of type:
            You can specify the picture size you want with the type argument, 
            which should be one of square (50x50), small (50 pixels wide, variable height), 
            normal (100 pixels wide, variable height), 
            and large (about 200 pixels wide, variable height) 
        """
        uri = urllib.basejoin(self.graphUri, '/me/picture')
        uri += '?{0}'.format(urllib.urlencode({
            'access_token': self.accessToken,
            'type': type,
        }))
        try:
            conn = urllib2.urlopen(uri, timeout=self._timeout)
            imgUri = conn.geturl() # Facebook will trigger redirect and we need the uri not the data
        except urllib2.URLError as e:
{'fraction_non_alphanumeric': 0.11342441986553893, 'fraction_numerical': 0.010843634786380394, 'mean_word_length': 2.0870147255689426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '859448', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1309, 'n_words': 386}