mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-24 19:58:31 +01:00
0acbf687b5
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
69 lines
2.5 KiB
Python
69 lines
2.5 KiB
Python
#!/usr/bin/python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
import urllib3
|
|
from dataclasses import dataclass
|
|
|
|
from slpkg.configs import Configs
|
|
from slpkg.models.models import SBoTable
|
|
from slpkg.models.models import session as Session
|
|
|
|
|
|
@dataclass
|
|
class ViewPackage:
|
|
session: str = Session
|
|
colors: dict = Configs.colour
|
|
sbo_repo_url: str = Configs.sbo_repo_url
|
|
sbo_tar_suffix: str = Configs.sbo_tar_suffix
|
|
|
|
def package(self, packages):
|
|
http = urllib3.PoolManager()
|
|
color = self.colors()
|
|
GREEN = color['GREEN']
|
|
BLUE = color['BLUE']
|
|
YELLOW = color['YELLOW']
|
|
CYAN = color['CYAN']
|
|
ENDC = color['ENDC']
|
|
|
|
for package in packages:
|
|
info = self.session.query(
|
|
SBoTable.name,
|
|
SBoTable.version,
|
|
SBoTable.requires,
|
|
SBoTable.download,
|
|
SBoTable.download64,
|
|
SBoTable.md5sum,
|
|
SBoTable.md5sum64,
|
|
SBoTable.files,
|
|
SBoTable.short_description,
|
|
SBoTable.location
|
|
).filter(SBoTable.name == package).first()
|
|
|
|
readme = http.request(
|
|
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/README')
|
|
|
|
info_file = http.request(
|
|
'GET', f'{self.sbo_repo_url}/{info[9]}/{info[0]}/{info[0]}.info')
|
|
|
|
maintainer, email = '', ''
|
|
for line in info_file.data.decode().splitlines():
|
|
if line.startswith('MAINTAINER'):
|
|
maintainer = line[12:-1].strip()
|
|
if line.startswith('EMAIL'):
|
|
email = line[7:-1].strip()
|
|
|
|
print(f'Name: {GREEN}{info[0]}{ENDC}\n'
|
|
f'Version: {GREEN}{info[1]}{ENDC}\n'
|
|
f'Requires: {GREEN}{info[2]}{ENDC}\n'
|
|
f'Download SlackBuild: {BLUE}{self.sbo_repo_url}/{info[9]}/{info[0]}{self.sbo_tar_suffix}{ENDC}\n'
|
|
f'Download sources: {BLUE}{info[3]}{ENDC}\n'
|
|
f'Download_x86_64 sources: {BLUE}{info[4]}{ENDC}\n'
|
|
f'Md5sum: {YELLOW}{info[5]}{ENDC}\n'
|
|
f'Md5sum_x86_64: {YELLOW}{info[6]}{ENDC}\n'
|
|
f'Files: {GREEN}{info[7]}{ENDC}\n'
|
|
f'Description: {GREEN}{info[8]}{ENDC}\n'
|
|
f'SBo url: {BLUE}{self.sbo_repo_url}/{info[9]}/{info[0]}{ENDC}\n'
|
|
f'Maintainer: {YELLOW}{maintainer}{ENDC}\n'
|
|
f'Email: {YELLOW}{email}{ENDC}\n'
|
|
f'\nREADME: {CYAN}{readme.data.decode()}{ENDC}')
|