Esempio n. 1
0
def get_data(github, selected_repos):
    """Generate json form thomasloven."""
    org = 'thomasloven'
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(github.get_user(org).get_repos()):
            repos.append(repo.name)
    for repo in repos:
        try:
            repo = github.get_repo(org + '/' + repo)
            if 'lovelace-' in repo.name:
                name = repo.name.replace('lovelace-', '')
                fullname = repo.name
                print("Generating json for:", "{}/{}".format(org, name))

                version = list(repo.get_commits())[0].sha[0:6]

                remote_location = REUSE.format(org, fullname, name)
                remote_location = remote_location + '.js'

                visit_repo = VISIT.format(org, fullname)

                changelog = VISIT.format(org, fullname)

                data[name] = {}
                data[name]['version'] = version
                data[name]['remote_location'] = remote_location
                data[name]['visit_repo'] = visit_repo
                data[name]['changelog'] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 2
0
def get_data(github, selected_repos):
    """Generate json form ciotlosm."""
    ciotlosm = github.get_repo("ciotlosm/custom-lovelace")
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(ciotlosm.get_dir_contents("")):
            if repo.path not in ["LICENSE", "README.md"]:
                repos.append(repo.path)
    for repo in repos:
        try:
            name = repo

            version = ciotlosm.get_file_contents(name + "/VERSION")
            version = version.decoded_content.decode()
            version = version.split()[0]

            # This line has to start here, due to the validation.
            print("Generating json for:", "{}/{}".format("ciotlosm", name))

            visit_repo = VISIT.format("ciotlosm", "custom-lovelace")
            visit_repo = visit_repo + "/tree/master/" + name

            changelog = visit_repo + "/changelog.md"

            remote_location = "https://raw.githubusercontent.com/ciotlosm/"
            remote_location = remote_location + "custom-lovelace/master/"
            remote_location = remote_location + name + "/" + name + ".js"

            data[name] = {}
            data[name]["version"] = version
            data[name]["remote_location"] = remote_location
            data[name]["visit_repo"] = visit_repo
            data[name]["changelog"] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 3
0
def get_data(github, selected_repos):
    """Generate json form ciotlosm."""
    ciotlosm = github.get_repo('ciotlosm/custom-lovelace')
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(ciotlosm.get_dir_contents('')):
            if repo.path not in ['LICENSE', 'README.md']:
                repos.append(repo.path)
    for repo in repos:
        try:
            name = repo

            version = ciotlosm.get_file_contents(name + '/VERSION')
            version = version.decoded_content.decode()
            version = version.split()[0]

            # This line has to start here, due to the validation.
            print("Generating json for:", "{}/{}".format('ciotlosm', name))

            visit_repo = VISIT.format('ciotlosm', 'custom-lovelace')
            visit_repo = visit_repo + '/tree/master/' + name

            changelog = visit_repo + '/changelog.md'

            remote_location = "https://raw.githubusercontent.com/ciotlosm/"
            remote_location = remote_location + "custom-lovelace/master/"
            remote_location = remote_location + name + '/' + name + '.js'

            data[name] = {}
            data[name]['version'] = version
            data[name]['remote_location'] = remote_location
            data[name]['visit_repo'] = visit_repo
            data[name]['changelog'] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 4
0
def get_data(github, selected_repos):
    """Generate json form maykar."""
    org = "maykar"
    data = {}
    repos = []
    all_repos = ["compact-custom-header"]
    if selected_repos:
        for repo in selected_repos:
            if repo in all_repos:
                repos.append(repo)
    else:
        repos = all_repos
    for repo in repos:
        try:
            repo = github.get_repo(org + "/" + repo)
            name = repo.name
            print("Generating json for:", "{}/{}".format(org, name))

            release = list(repo.get_releases())[0]

            version = release.tag_name

            remote_location = REUSE_TAG.format(org, name, version, name)
            remote_location = remote_location + ".js"

            visit_repo = VISIT.format(org, name)

            changelog = release.html_url

            data[name] = {}
            data[name]["version"] = version
            data[name]["remote_location"] = remote_location
            data[name]["visit_repo"] = visit_repo
            data[name]["changelog"] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 5
0
def get_isabellaalstrom(github, selected_repos):
    """Generate json form isabellaalstrom."""
    org = "isabellaalstrom"
    data = {}
    repos = []
    all_repos = ["krisinfo-card", "pollenkoll-card"]
    if selected_repos:
        for repo in selected_repos:
            if repo in all_repos:
                repos.append(repo)
    else:
        repos = all_repos
    for repo in repos:
        try:
            repo = github.get_repo(org + "/" + repo)
            name = repo.name
            print("Generating json for:", "{}/{}".format(org, name))

            content = repo.get_file_contents("VERSION")
            content = content.decoded_content.decode()
            version = content.split()[0]

            remote_location = REUSE.format(org, name, name)
            remote_location = remote_location + ".js"

            visit_repo = VISIT.format(org, name)

            changelog = visit_repo

            data[name] = {}
            data[name]["version"] = version
            data[name]["remote_location"] = remote_location
            data[name]["visit_repo"] = visit_repo
            data[name]["changelog"] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 6
0
def get_isabellaalstrom(github, selected_repos):
    """Generate json form isabellaalstrom."""
    org = 'isabellaalstrom'
    data = {}
    repos = []
    all_repos = ['krisinfo-card']
    if selected_repos:
        for repo in selected_repos:
            if repo in all_repos:
                repos.append(repo)
    else:
        repos = all_repos
    for repo in repos:
        try:
            repo = github.get_repo(org + '/' + repo)
            name = repo.name
            print("Generating json for:", "{}/{}".format(org, name))

            content = repo.get_file_contents('VERSION')
            content = content.decoded_content.decode()
            version = content.split()[0]

            remote_location = REUSE.format(org, name, name)
            remote_location = remote_location + '.js'

            visit_repo = VISIT.format(org, name)

            changelog = visit_repo

            data[name] = {}
            data[name]['version'] = version
            data[name]['remote_location'] = remote_location
            data[name]['visit_repo'] = visit_repo
            data[name]['changelog'] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 7
0
def get_isabellaalstrom(github, selected_repos):
    """Generate json form isabellaalstrom."""
    org = "isabellaalstrom"
    data = {}
    repos = []
    all_repos = ["sensor.krisinformation"]
    if selected_repos:
        for repo in selected_repos:
            if repo in all_repos:
                repos.append(repo)
    else:
        repos = all_repos
    for repo in repos:
        try:
            repo = github.get_repo(org + "/" + repo)
            print("Generating json for:", "{}/{}".format(org, repo.name))
            name = repo.name
            resources = []
            updated_at = repo.updated_at.isoformat().split("T")[0]
            locationformat = "custom_components/{}/{}.py"
            location = locationformat.format(name.split(".")[0], name.split(".")[1])
            embedded_path = locationformat.format(
                name.split(".")[1], name.split(".")[0]
            )

            try:
                repo.get_file_contents(embedded_path)
                embedded = True
            except Exception:  # pylint: disable=W0703
                embedded = False

            version = None  # reset
            try:
                if embedded:
                    path = embedded_path
                else:
                    path = location
                content = repo.get_file_contents(path)
                content = content.decoded_content.decode().split("\n")
                for line in content:
                    if "__version__" in line:
                        version = line.split(" = ")[1].replace("'", "")
                        break
            except Exception:  # pylint: disable=W0703
                version = None

            try:
                repo.get_file_contents("example.png")
                image_link = REUSE.format(org, name, "example.png")
            except Exception:  # pylint: disable=W0703
                image_link = ""

            updated_at = updated_at
            version = version
            description = repo.description
            local_location = "/{}".format(location)
            remote_location = REUSE.format(org, name, location)
            visit_repo = VISIT.format(org, name)
            changelog = visit_repo

            author = {}
            author["login"] = "******"
            author["html_url"] = "https://github.com/isabellaalstrom"

            data[name] = {}
            data[name]["author"] = author
            data[name]["updated_at"] = updated_at
            data[name]["description"] = description
            data[name]["image_link"] = image_link
            data[name]["version"] = version
            data[name]["local_location"] = local_location
            data[name]["remote_location"] = remote_location
            data[name]["visit_repo"] = visit_repo
            data[name]["changelog"] = changelog
            data[name]["resources"] = resources
            data[name]["embedded"] = embedded
            data[name]["embedded_path"] = "/{}".format(embedded_path)
            data[name]["embedded_path_remote"] = REUSE.format(org, name, embedded_path)
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 8
0
def get_data(github, selected_repos):
    """Generate json form custom-cards org."""
    org = 'custom-cards'
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(github.get_user(org).get_repos()):
            repos.append(repo.name)
    for repo in repos:
        try:
            repo = github.get_repo(org + '/' + repo)
            if repo.name not in BLACKLIST and not repo.archived:
                print("Generating json for:", "{}/{}".format(org, repo.name))

                try:
                    release = list(repo.get_releases())[0]
                except Exception:  # pylint: disable=W0703
                    release = None

                name = repo.name

                version = None
                try:
                    if release and release.tag_name is not None:
                        version = release.tag_name
                    else:
                        content = repo.get_file_contents('VERSION')
                        content = content.decoded_content.decode()
                        version = content.split()[0]
                except Exception:  # pylint: disable=W0703
                    version = None

                if release:
                    remote_location = REUSE_TAG.format(org, name, version,
                                                       name)
                else:
                    remote_location = REUSE.format(org, name, name)

                remote_location = remote_location + '.js'
                testfile = requests.get(remote_location)

                if testfile.status_code != 200:
                    remote_location = remote_location.split(name + '.js')[0]
                    remote_location = remote_location + 'dist/' + name + '.js'
                    testfile = requests.get(remote_location)

                if testfile.status_code != 200:
                    remote_location = remote_location.split('dist/' + name +
                                                            '.js')[0]
                    remote_location = remote_location + 'src/' + name + '.js'
                    testfile = requests.get(remote_location)

                if testfile.status_code != 200:
                    continue

                visit_repo = VISIT.format(org, name)

                try:
                    changelog = list(repo.get_releases())[0].html_url
                    if 'untagged' in list(repo.get_releases())[0].name:
                        changelog = None
                except Exception:  # pylint: disable=W0703
                    changelog = None

                if changelog is None:
                    changelog = VISIT.format(org, name)

                data[name] = {}
                data[name]['version'] = version
                data[name]['remote_location'] = remote_location
                data[name]['visit_repo'] = visit_repo
                data[name]['changelog'] = changelog
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 9
0
def get_data(github, selected_repos):
    """Generate json form custom-components org."""
    org = 'custom-components'
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(github.get_user(org).get_repos()):
            repos.append(repo.name)
    for repo in repos:
        try:
            repo = github.get_repo(org + '/' + repo)
            if repo.name not in BLACKLIST and not repo.archived:
                print("Generating json for:", "{}/{}".format(org, repo.name))
                name = repo.name
                resources = []
                updated_at = repo.updated_at.isoformat().split('T')[0]
                if '.' in name:
                    locationformat = 'custom_components/{}/{}.py'
                    location = locationformat.format(
                        name.split('.')[0],
                        name.split('.')[1])
                    embedded_path = locationformat.format(
                        name.split('.')[1],
                        name.split('.')[0])

                    try:
                        repo.get_file_contents(embedded_path)
                        embedded = True
                    except Exception:  # pylint: disable=W0703
                        embedded = False

                else:
                    location = 'custom_components/{}.py'.format(name)
                    embedded_path = location
                    embedded = True
                    try:
                        repo.get_file_contents(location)
                    except Exception:  # pylint: disable=W0703
                        location = 'custom_components/{}/__init__.py'
                        location = location.format(name)
                        embedded_path = location

                version = None  # reset
                try:
                    if embedded:
                        path = embedded_path
                    else:
                        path = location
                    content = repo.get_file_contents(path)
                    content = content.decoded_content.decode().split('\n')
                    for line in content:
                        if '_version_' in line or 'VERSION' in line:
                            version = line.split(' = ')[1].replace("'", "")
                            break
                except Exception:  # pylint: disable=W0703
                    version = None

                try:
                    releases = list(repo.get_releases())
                    changelog = releases[0].html_url
                    if 'untagged' in changelog:
                        changelog = releases[1].html_url
                    if 'untagged' in changelog:
                        changelog = VISIT.format(org, name)
                except Exception:  # pylint: disable=W0703
                    changelog = VISIT.format(org, name)

                try:
                    repo.get_file_contents('example.png')
                    image_link = REUSE.format(org, name, 'example.png')
                except Exception:  # pylint: disable=W0703
                    image_link = ''

                updated_at = updated_at
                version = version
                description = repo.description
                local_location = '/{}'.format(location)
                remote_location = REUSE.format(org, name, location)
                embedded_path_remote = REUSE.format(org, name, embedded_path)
                visit_repo = VISIT.format(org, name)
                changelog = changelog

                authordata = list(repo.get_contributors())[0]
                author = {}
                author['login'] = authordata.login
                author['html_url'] = authordata.html_url

                data[name] = {}
                data[name]['author'] = author
                data[name]['updated_at'] = updated_at
                data[name]['version'] = version
                data[name]['description'] = description
                data[name]['image_link'] = image_link
                data[name]['local_location'] = local_location
                data[name]['remote_location'] = remote_location
                data[name]['visit_repo'] = visit_repo
                data[name]['changelog'] = changelog
                data[name]['resources'] = resources
                data[name]['embedded'] = embedded
                data[name]['embedded_path'] = '/{}'.format(embedded_path)
                data[name]['embedded_path_remote'] = embedded_path_remote
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 10
0
def get_isabellaalstrom(github, selected_repos):
    """Generate json form isabellaalstrom."""
    org = 'isabellaalstrom'
    data = {}
    repos = []
    all_repos = ['sensor.krisinformation']
    if selected_repos:
        for repo in selected_repos:
            if repo in all_repos:
                repos.append(repo)
    else:
        repos = all_repos
    for repo in repos:
        try:
            repo = github.get_repo(org + '/' + repo)
            print("Generating json for:", "{}/{}".format(org, repo.name))
            name = repo.name
            resources = []
            updated_at = repo.updated_at.isoformat().split('T')[0]
            locationformat = 'custom_components/{}/{}.py'
            location = locationformat.format(name.split('.')[0],
                                             name.split('.')[1])
            embedded_path = locationformat.format(name.split('.')[1],
                                                  name.split('.')[0])

            try:
                repo.get_file_contents(embedded_path)
                embedded = True
            except Exception:  # pylint: disable=W0703
                embedded = False

            version = None  # reset
            try:
                if embedded:
                    path = embedded_path
                else:
                    path = location
                content = repo.get_file_contents(path)
                content = content.decoded_content.decode().split('\n')
                for line in content:
                    if '__version__' in line:
                        version = line.split(' = ')[1].replace("'", "")
                        break
            except Exception:  # pylint: disable=W0703
                version = None

            try:
                repo.get_file_contents('example.png')
                image_link = REUSE.format(org, name, 'example.png')
            except Exception:  # pylint: disable=W0703
                image_link = ''

            updated_at = updated_at
            version = version
            description = repo.description
            local_location = '/{}'.format(location)
            remote_location = REUSE.format(org, name, location)
            visit_repo = VISIT.format(org, name)
            changelog = visit_repo

            author = {}
            author['login'] = '******'
            author['html_url'] = 'https://github.com/isabellaalstrom'

            data[name] = {}
            data[name]['author'] = author
            data[name]['updated_at'] = updated_at
            data[name]['description'] = description
            data[name]['image_link'] = image_link
            data[name]['version'] = version
            data[name]['local_location'] = local_location
            data[name]['remote_location'] = remote_location
            data[name]['visit_repo'] = visit_repo
            data[name]['changelog'] = changelog
            data[name]['resources'] = resources
            data[name]['embedded'] = embedded
            data[name]['embedded_path'] = '/{}'.format(embedded_path)
            data[name]['embedded_path_remote'] = REUSE.format(org, name,
                                                              embedded_path)
        except Exception:  # pylint: disable=W0703
            pass
    return data
Esempio n. 11
0
def get_data(github, selected_repos):
    """Generate json form custom-components org."""
    org = "custom-components"
    data = {}
    repos = []
    if selected_repos:
        for repo in selected_repos:
            repos.append(repo)
    else:
        for repo in list(github.get_user(org).get_repos()):
            repos.append(repo.name)
    for repo in repos:
        try:
            repo = github.get_repo(org + "/" + repo)
            if repo.name not in BLACKLIST and not repo.archived:
                print("Generating json for:", "{}/{}".format(org, repo.name))
                name = repo.name

                resources = []
                updated_at = repo.updated_at.isoformat().split("T")[0]
                if "." in name:
                    locationformat = "custom_components/{}/{}.py"
                    location = locationformat.format(
                        name.split(".")[0], name.split(".")[1]
                    )
                    embedded_path = locationformat.format(
                        name.split(".")[1], name.split(".")[0]
                    )

                    try:
                        repo.get_file_contents(embedded_path)
                        embedded = True
                    except Exception:  # pylint: disable=W0703
                        embedded = False

                else:
                    location = "custom_components/{}.py".format(name)
                    embedded_path = location
                    embedded = True
                    try:
                        repo.get_file_contents(location)
                    except Exception:  # pylint: disable=W0703
                        location = "custom_components/{}/__init__.py"
                        location = location.format(name)
                        embedded_path = location

                try:
                    release = list(repo.get_releases())[0]
                except Exception:  # pylint: disable=W0703
                    release = None

                version = None

                try:
                    resources = json.loads(
                        repo.get_file_contents(
                            "resources.json"
                        ).decoded_content.decode()
                    )
                except Exception:  # pylint: disable=W0703
                    pass

                try:
                    if embedded:
                        path = embedded_path
                    else:
                        path = location
                    content = repo.get_file_contents(path)
                    content = content.decoded_content.decode().split("\n")
                    for line in content:
                        if "_version_" in line or "VERSION" in line:
                            version = line.split(" = ")[1].replace("'", "")
                            break
                except Exception:  # pylint: disable=W0703
                    version = None

                if version is None:
                    try:
                        if release and release.tag_name is not None:
                            version = release.tag_name
                        else:
                            version = None
                    except Exception:  # pylint: disable=W0703
                        version = None

                try:
                    releases = list(repo.get_releases())
                    changelog = releases[0].html_url
                    if "untagged" in changelog:
                        changelog = releases[1].html_url
                    if "untagged" in changelog:
                        changelog = VISIT.format(org, name)
                except Exception:  # pylint: disable=W0703
                    changelog = VISIT.format(org, name)

                try:
                    repo.get_file_contents("example.png")
                    image_link = REUSE.format(org, name, "example.png")
                except Exception:  # pylint: disable=W0703
                    image_link = ""

                updated_at = updated_at
                version = version
                description = repo.description
                local_location = "/{}".format(location)
                remote_location = REUSE.format(org, name, location)
                embedded_path_remote = REUSE.format(org, name, embedded_path)
                visit_repo = VISIT.format(org, name)
                changelog = changelog

                authordata = list(repo.get_contributors())[0]
                author = {}
                author["login"] = authordata.login
                author["html_url"] = authordata.html_url

                data[name] = {}
                data[name]["author"] = author
                data[name]["updated_at"] = updated_at
                data[name]["version"] = version
                data[name]["description"] = description
                data[name]["image_link"] = image_link
                data[name]["local_location"] = local_location
                data[name]["remote_location"] = remote_location
                data[name]["visit_repo"] = visit_repo
                data[name]["changelog"] = changelog
                data[name]["resources"] = resources
                data[name]["embedded"] = embedded
                data[name]["embedded_path"] = "/{}".format(embedded_path)
                data[name]["embedded_path_remote"] = embedded_path_remote
        except Exception:  # pylint: disable=W0703
            pass
    return data