Skip to main content

Библиотека для работы с GitHub API.

Project description

LibraryGitHub (LGH)

LGH - это библиотека для работы с GitHub API. Позволяет искать репозитории, связанные с основным репозиторием, и скачивать файлы.

Особенности

  • Поиск репозиториев, связанных с основным репозиторием (по ссылке в описании)
  • Получение информации о файлах в корне репозитория
  • Получение ссылки на последний релиз с ZIP-ассетом
  • Интеграция с LibraryHttp (LH)
  • Интеграция с LibraryLogSystem (LLS)

Установка

from LGH import Github

Использование

Поиск связанных репозиториев

Поиск репозиториев, связанных с основным

from LGH import Github

repos = Github.search('https://github.com/owner/main-repo')

# Поиск с ограничением количества
repos = Github.search('https://github.com/owner/main-repo', per_page=50)

Скачивание файлов из репозитория

from LGH import Github

# Скачивание файла из корня репозитория
file_content = Github.download('owner', 'repo', 'manifest.json')

if file_content:
    with open('manifest.json', 'wb') as f:
        f.write(file_content)

Получение информации о файлах

from LGH import Github

repos = Github.search('https://github.com/owner/main-repo')

for name, info in repos.items():
    print(f"Репозиторий: {name}")
    print(f"Разработчик: {info['DEV']}")
    print(f"Ссылка: {info['LINK']}")
    
    if info['FILES']:
        print("Файлы:")
        for key, value in info['FILES'].items():
            print(f"  {key}: {value}")
    
    if info['RELEASE']:
        print(f"Релиз: {info['RELEASE']}")

API

Github.search()

Github.search(main_repo=None, per_page=100)

Ищет репозитории, связанные с основным репозиторием.

Параметры:

- main_repo (str): URL основного репозитория (по умолчанию: None)
- per_page (int): Количество результатов на страницу (по умолчанию: 100)

Возвращает:

- dict: Словарь с информацией о найденных репозиториях

Исключения:

- GithubError: Ошибка при поиске или загрузке

Github.download()

Github.download(owner, repo, filename)

Скачивает файл из корня репозитория.

Параметры:

- owner (str): Владелец репозитория
- repo (str): Название репозитория
- filename (str): Имя файла

Возвращает:

- bytes: Содержимое файла или None если файл не найден

Формат возвращаемых данных

{
    "NameOfRepo": {
        "DEV": ["Developer 1", "Developer 2"],
        "LINK": "https://github.com/owner/NameOfRepo",
        "FILES": {
            "EXE": "main.exe",
            "MAN": "manifest.json",
            "ICO": "icon.ico"
        },
        "RELEASE": "https://github.com/owner/NameOfRepo/releases/download/v1.0/asset.zip"
    }
}

Логирование

Все операции логируются через LLS в logs/GitHub/:

[25.07.2026 21:59:18] [INFO] [repository.py] [search] [45] -> Найдено репозиториев, связанных с [owner/main-repo]: 5.
[25.07.2026 21:59:18] [ERROR] [repository.py] [search] [30] -> Не удалось найти репозитории: 404 Not Found

Структура логов

logs/
└── GitHub/
    ├── debug/
    ├── info/
    │   └── 21.59.18_25.07.2026.log
    ├── warnings/
    ├── errors/
    │   └── 21.59.18_25.07.2026.log
    └── critical/

Зависимости

LibraryHttp (LH) LibraryLogSystem (LLS)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eof_413_lgh-1.0.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eof_413_lgh-1.0.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file eof_413_lgh-1.0.0.tar.gz.

File metadata

  • Download URL: eof_413_lgh-1.0.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for eof_413_lgh-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7a6b02204cc091a37a8c3559a064896ba6c001ef61f0a206ded6f39bbf62b4ca
MD5 58d08984dfe768a9fc655ba0ede5edc6
BLAKE2b-256 1ebddc2100dba86874b84b311f392b638969ffc02d55f81ecb24592fcd8757ad

See more details on using hashes here.

File details

Details for the file eof_413_lgh-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: eof_413_lgh-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for eof_413_lgh-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 358e602a7cfa7ba8a17c640f1b8325ca12d4cef875dfad8a3ca03f1220feaf96
MD5 08db8a2a48420582954ae517072e9232
BLAKE2b-256 e6b8d9ce33b9ca355baea348c5540248975395e0022f0ccd2f11c405cbf68730

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page