Exemplo n.º 1
0
def count_comment(repository_endpoint):
    token = Token()
    token.repository_endpoint = repository_endpoint
    repo = token.get_repository()
    contents = repo.get_contents("")

    # Counter
    javascript = 0
    python = 0
    java = 0
    php = 0

    while contents:
        file_content = contents.pop(0)
        if file_content.type == 'dir':
            contents.extend(repo.get_contents(file_content.path))
        else:
            fileName = file_content.name
            file = File(fileName)
            if file.is_python() or file.is_java() or file.is_php() or file.is_javascript():
                decoded_content = file_content.decoded_content
                inside_content = decoded_content.decode('utf-8')
                length = len(re.findall(r'/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/', inside_content))

                if length > 0:
                    if file.is_javascript():  # Javascript
                        javascript += length
                    elif file.is_python():  # Python
                        python += length
                    elif file.is_java():  # Java
                        java += length
                    elif file.is_php():  # PHP
                        php += length

    return generate_dates(javascript, java, python, php)
Exemplo n.º 2
0
def count_testing(repository_endpoint):
    token = Token()
    token.repository_endpoint = repository_endpoint
    repo = token.get_repository()
    contents = repo.get_contents("")

    # Counter
    javascript = 0
    python = 0
    java = 0
    php = 0

    while contents:
        file_content = contents.pop(0)
        if file_content.type == 'dir':
            contents.extend(repo.get_contents(file_content.path))
        else:
            fileName = file_content.name
            file = File(fileName)
            if file.is_python() or file.is_java() or file.is_php() or file.is_javascript():
                decoded_content = file_content.decoded_content
                inside_content = decoded_content.decode('utf-8')

                if inside_content.find('org.junit.jupiter.api.Test') > -1 or inside_content.find(
                        'import unittest') > -1 or inside_content.find('assert') > -1:
                    if file.is_javascript():  # Javascript
                        javascript += 1
                    elif file.is_python():  # Python
                        python += 1
                    elif file.is_java():  # Java
                        java += 1
                    elif file.is_php():  # PHP
                        php += 1

    return generate_dates(javascript, java, python, php)
Exemplo n.º 3
0
def count_file_and_folder(repository_endpoint):
    # Getting data from GitHub API
    token = Token()
    token.repository_endpoint = repository_endpoint
    repo = token.get_repository()

    listFile = []
    listDir = []
    contents = repo.get_contents("")
    while contents:
        file_content = contents.pop(0)
        if file_content.type == "dir":
            listDir.append(file_content)
            contents.extend(repo.get_contents(file_content.path))
        else:
            listFile.append(file_content)

    return generate_dates_file_and_folder(len(listFile), len(listDir))
Exemplo n.º 4
0
    def get_contents(self):
        token = Token()
        token.repository_endpoint = self.repository_endpoint
        repo = token.get_repository()
        contents = repo.get_contents("")
        folders = []
        files = []
        while contents:
            file_content = contents.pop(0)
            if file_content.type == 'dir':
                folders.append(file_content)
                contents.extend(repo.get_contents(file_content.path))
            else:
                files.append(file_content)

        self.contents = {
            'folders': folders,
            'files': files,
        }

        return self
Exemplo n.º 5
0
def count_library(repository_endpoint):
    token = Token()
    token.repository_endpoint = repository_endpoint
    repo = token.get_repository()
    contents = repo.get_contents("")

    # Counter
    javascript = 0
    python = 0
    java = 0
    php = 0

    while contents:
        file_content = contents.pop(0)
        if file_content.type == 'dir':
            contents.extend(repo.get_contents(file_content.path))
        else:
            fileName = file_content.name
            library = Library(fileName)
            if library.is_python() or library.is_java() or library.is_php() or library.is_javascript():
                decoded_content = file_content.decoded_content
                inside_content = decoded_content.decode('utf-8')

                if library.is_python():
                    python = len(inside_content.split('\n'))
                elif library.is_javascript():
                    contentDict = json.loads(inside_content)
                    javascript = len(contentDict["devDependencies"]) + len(contentDict["dependencies"])
                elif library.is_java():
                    contentDict = inside_content.split()
                    java = contentDict.count('<dependency>')
                elif library.is_php():
                    contentDict = json.loads(inside_content)
                    php = len(contentDict["require"]) + len(contentDict["require-dev"])

    return generate_dates(javascript, java, python, php)