Files
inventree-website/.github/collect_plugin.py
T
Oliver dd7d563e79 Zensical Refactor (#300)
* refactor into zensical

* adjust nav layout

* more nav changes

* update features page

* open external hero links in new tab

* consolidate small pages

* add legacy page redirects

* tweak content

* further cleanup

* adjust netlify config

* disable redirect

* remove redirect script

* fix tag splitting for plugins

* Display plugin metadata on left-hand side

* revert icon changes

* move gallery to index page

* Add page deascriptions

* fix image size for carousel

* adjust theme
2026-11-22 22:40:17 +11:00

70 lines
1.7 KiB
Python

import json
import os
from pathlib import Path
from urllib.request import urlopen, Request
inp_project = os.environ.get('PROJECT').strip()
inp_author = os.environ.get('AUTHOR').strip()
file_name = Path(f'docs/plugins/{inp_project}.md')
crowdin_projet_id = 452300
print(f'Collecting {inp_project} with {inp_author}...')
def get_data(url, key=None, default=0, auth=None):
"""Fetches data from remote endpoint"""
httprequest = Request(url, headers={"Accept": "application/json"})
if auth:
httprequest.add_header("Authorization", f"Bearer {auth}")
with urlopen(httprequest) as response:
data = response.read().decode()
data = json.loads(data)
if key:
data = data.get(key, default)
return data
pypi_data = get_data(f'https://pypi.org/pypi/{inp_project}/json')
name = pypi_data['info']['name']
tagline = pypi_data['info']['summary']
author = inp_author or pypi_data['info']['author_email']
license = pypi_data['info']['license']
try:
version = pypi_data['info']['version']
stable = int(version.split('.')[0])>1
except:
stable = False
bugtracker = pypi_data['info']['bugtrack_url'] or pypi_data['info']['project_urls'].get('Bug Tracker') or ''
homepage = pypi_data['info']['home_page'] or pypi_data['info']['project_urls'].get('Homepage')
keywords = pypi_data['info']['keywords'] or ''
tags = ''.join(f'\n - {k.strip()}' for k in keywords.replace(',', ' ').split() if k.strip())
readme = pypi_data['info']['description']
# Write data
file_name.write_text(
f"""---
name: {name}
author: {author}
license: {license}
open_source: true
stable: {str(stable).lower()}
maintained: true
pypi: true
package_name: {name}
github: {homepage}
gitlab:
source:
issue_tracker: {bugtracker}
website:
categories:
tags:{tags}
---
{tagline}
{readme}
"""
)