File tree Expand file tree Collapse file tree 4 files changed +15
-10
lines changed
Expand file tree Collapse file tree 4 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 1+ API_TOKEN = 62ce13fb948ae0551c0512e14059000ffa35be64
Original file line number Diff line number Diff line change 1212
1313Перед началом работы установите необходимые библиотеки:
1414
15- ``` pip install pyforgejo ```
15+ ``` pip install -r requirements.txt ```
1616
1717## Настройка API-токена
1818
19- В файл ` token ` запишите в файл API-ключ в формате:
19+ Создайте .env файл с токеном pyforgejo в рабочей папке скрипта. Пример находится в папке с клиентом.
2020
21- ` token your_api_key_here `
21+ ```
22+ API_TOKEN=62ce13fb948ae0551c0512e14059000ffa35be64
23+ ```
2224
2325## Запуск скрипта
2426
Original file line number Diff line number Diff line change 1+ from dotenv import dotenv_values
12from pyforgejo import PyforgejoApi
23
3- with open ('token' ) as file :
4- API_KEY = file .read ()
5- if not API_KEY :
6- print ("API_KEY not found" )
7- exit (1 )
4+ config = dotenv_values (".env" )
85
9- client = PyforgejoApi (base_url = "https://codeberg.org/api/v1" , api_key = API_KEY )
6+ if not "API_TOKEN" in config :
7+ print ("Cannot find API_TOKEN in .env file. Check if it exists and has correct token. Aborting..." )
8+ exit (1 )
9+ client = PyforgejoApi (base_url = "https://codeberg.org/api/v1" , api_key = config ["API_TOKEN" ])
1010
1111repo = client .repository .repo_get (owner = "harabat" , repo = "pyforgejo" )
1212
1313
1414print (f"Название: { repo .name } " )
15- print (f"Описание: { repo .description } " )
15+ print (f"Описание: { repo .description } " )
Original file line number Diff line number Diff line change 1+ pyforgejo == 2.0.0
2+ python-dotenv == 1.0.1
You can’t perform that action at this time.
0 commit comments