<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""This module allow to developers to get all some data about a given GitHub user.

Author: <NAME> @iblancasa
Original idea: https://github.com/JJ/github-city-rankings
License:

The MIT License (MIT)
    Copyright (c) 2015 <NAME> @iblancasa (http://iblancasa.com/)

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software
    and associated documentation files (the “Software”), to deal in the Software without
    restriction, including without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
    the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or
    substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
    FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    IN THE SOFTWARE.

"""
import time
from bs4 import BeautifulSoup
import urllib.request
from urllib.error import HTTPError, URLError
import datetime, dateutil.parser
import re

class GitHubUser:
    """Manager of a GitHub User

    Attributes:
        _name (str): Name of the user (private).
        _contributions (int): total contributions of a user in the last year (private).
        _followers (int): total number of followers of an user (private).
        _gists (int): total number of gists of an user (private).
        _longestStreak (int): maximum number of consecutive days with activity (private).
        _numRepos (int): number of repositories of an user (private).
    """

    def __init__(self, name):
        """Constructor of the class.
        Args:
            name (str): name (login) of an user in GitHub

        Returns:
            a new instance of GitHubUser class
        """
        self._name = name

    def getName(self):
        return self._name

    def getContributions(self):
        return self._contributions

    def getLongestStreak(self):
        return self._longestStreak

    def getCurrentStreak(self):
        return self._currentStreak

    def getLanguage(self):
        return self._language

    def getAvatar(self):
        return self._avatar

    def getFollowers(self):
        return self._followers

    def getLocation(self):
        return self._location

    def getJoin(self):
        return self._join

    def getOrganizations(self):
        return self._organizations

    def getNumberOfRepositories(self):
        return self._numRepos

    def getStars(self):
        return self._stars


    def getData(self):
        """Get data of a GitHub user.
        """

        url = "https://github.com/"+self._name

        data = self._getDataFromURL(url)
        web = BeautifulSoup(data,"lxml")

        #Contributions, longest streak and current streak
        contributions_raw = web.find_all('span',{'class':'contrib-number'})
        #self._contributions = int(contributions_raw[0].text.split(" ")[0].replace(",",""))
        #self._longestStreak = int(contributions_raw[1].text.split(" ")[0].replace(",",""))
        #self._currentStreak = int(contributions_raw[2].text.split(" ")[0].replace(",",""))

        #Language
        self._language = web.find("meta", {"name":"description"})['content'].split(" ")[6]
        if self._language[len(self._language)-1]==",":
            self._language = self._language[:-1]

        #Avatar
        self._avatar = web.find("img", {"class":"avatar"})['src'][:-10]

        #Followers
        vcard = web.find_all("strong", {"class":"vcard-stat-count"})
        #self._followers = int(vcard[0].text)

        #Location
        self._location = web.find("li", {"itemprop":"homeLocation"}).text

        #Date of creation
        self._join = dateutil.parser.parse(web.find("time",{"class":"join-date"})["datetime"])

        #Number of organizations
        self._organizations = len(web.find_all("a",{"class":"avatar-group-item"}))

        #Number of repos
        url +="?tab=repositories"<commit_msg>Solving #44<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""This module allow to developers to get all some data about a given GitHub user.

Author: <NAME> @iblancasa
Original idea: https://github.com/JJ/github-city-rankings
License:

The MIT License (MIT)
    Copyright (c) 2015 <NAME> @iblancasa (http://iblancasa.com/)

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software
    and associated documentation files (the “Software”), to deal in the Software without
    restriction, including without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
    the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or
    substantial portions of the Software.

    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
    PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
    FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
    ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
    IN THE SOFTWARE.

"""
import time
from bs4 import BeautifulSoup
import urllib.request
from urllib.error import HTTPError, URLError
import datetime, dateutil.parser
import re

class GitHubUser:
    """Manager of a GitHub User

    Attributes:
        _name (str): Name of the user (private).
        _contributions (int): total contributions of a user in the last year (private).
        _followers (int): total number of followers of an user (private).
        _gists (int): total number of gists of an user (private).
        _longestStreak (int): maximum number of consecutive days with activity (private).
        _numRepos (int): number of repositories of an user (private).
    """

    def __init__(self, name):
        """Constructor of the class.
        Args:
            name (str): name (login) of an user in GitHub

        Returns:
            a new instance of GitHubUser class
        """
        self._name = name

    def getName(self):
        return self._name

    def getContributions(self):
        return self._contributions

    def getLongestStreak(self):
        return self._longestStreak

    def getCurrentStreak(self):
        return self._currentStreak

    def getLanguage(self):
        return self._language

    def getAvatar(self):
        return self._avatar

    def getFollowers(self):
        return self._followers

    def getLocation(self):
        return self._location

    def getJoin(self):
        return self._join

    def getOrganizations(self):
        return self._organizations

    def getNumberOfRepositories(self):
        return self._numRepos

    def getStars(self):
        return self._stars


    def getData(self):
        """Get data of a GitHub user.
        """

        url = "https://github.com/"+self._name

        data = self._getDataFromURL(url)
        web = BeautifulSoup(data,"lxml")

        #Contributions, longest streak and current streak
        contributions_raw = web.find_all('span',{'class':'contrib-number'})
        self._contributions = int(contributions_raw[0].text.split(" ")[0].replace(",",""))
        self._longestStreak = int(contributions_raw[1].text.split(" ")[0].replace(",",""))
        self._currentStreak = int(contributions_raw[2].text.split(" ")[0].replace(",",""))

        #Language
        self._language = web.find("meta", {"name":"description"})['content'].split(" ")[6]
        if self._language[len(self._language)-1]==",":
            self._language = self._language[:-1]

        #Avatar
        self._avatar = web.find("img", {"class":"avatar"})['src'][:-10]

        #Followers
        vcard = web.find_all("strong", {"class":"vcard-stat-count"})
        if "k" in vcard[0].text:
            self._followers = int(float(vcard[0].text[:-1].replace('\.',','))*1000)
        else:
            self._followers = int(vcard[0].text)

        #Location
        self._location = web.find("li", {"itemprop":"homeLocation"}).text

        #Date of creation
        self._join = dateutil.parser.parse(web.find("time",{"class":"join-date"})["datetime"])

        #Number of organizations
        self._organizations = len(web.find_all("a",{"class":"avatar-group-item"}))

        #Number of repos
        url +="?tab=repositories"
{'fraction_non_alphanumeric': 0.1096986301369863, 'fraction_numerical': 0.004931506849315068, 'mean_word_length': 2.948939852877542, 'pattern_counts': {'":': 14, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2428527', 'n_tokens_mistral': 2617, 'n_tokens_neox': 2480, 'n_words': 857}