Update __init__.py implement gitlab:

Implement gitlab:

def _rewrite_url(url, branch=None):
    if not branch:
        branch = "HEAD"
    if url.startswith("github:"):
        url = url[7:].split("/")
        url = (
            "https://raw.githubusercontent.com/"
            + url[0]
            + "/"
            + url[1]
            + "/"
            + branch
            + "/"
            + "/".join(url[2:])
        )
    if url.startswith("gitlab:"):
        url = url[7:].split("/")
        url = (
            "https://gitlab.com/"
            + url[0]
            + "/"
            + url[1]
            + "/-/raw/"
            + branch
            + "/"
            + "/".join(url[2:])
        )
    return url

#...


def _install_package(package, index, target, version, mpy):
    if (
        package.startswith("http://")
        or package.startswith("https://")
        or package.startswith("github:")
        or package.startswith("gitlab:")
    ):
#...
pull/815/head
Olivier Lenoir 2024-02-29 18:35:10 +01:00 zatwierdzone przez GitHub
rodzic ffb07dbce5
commit ef7610b762
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -1,5 +1,6 @@
# MicroPython package installer
# MIT license; Copyright (c) 2022 Jim Mussared
# Implement gitlab, Copyrigh (c) 2024 Olivier Lenoir
from micropython import const
import requests
@ -73,6 +74,18 @@ def _rewrite_url(url, branch=None):
+ "/"
+ "/".join(url[2:])
)
if url.startswith("gitlab:"):
url = url[7:].split("/")
url = (
"https://gitlab.com/"
+ url[0]
+ "/"
+ url[1]
+ "/-/raw/"
+ branch
+ "/"
+ "/".join(url[2:])
)
return url
@ -128,6 +141,7 @@ def _install_package(package, index, target, version, mpy):
package.startswith("http://")
or package.startswith("https://")
or package.startswith("github:")
or package.startswith("gitlab:")
):
if package.endswith(".py") or package.endswith(".mpy"):
print("Downloading {} to {}".format(package, target))