Paquete Debian
This commit is contained in:
parent
d8cdd2df53
commit
76d9a5996a
11
pip_busqueda_deb/DEBIAN/control
Normal file
11
pip_busqueda_deb/DEBIAN/control
Normal file
@ -0,0 +1,11 @@
|
||||
Package: pipbusqueda
|
||||
Version: 1.6
|
||||
Architecture: all
|
||||
Maintainer: luisgulo <luisgulo@soloconlinux.org.es>
|
||||
Depends: python3
|
||||
Section: devel
|
||||
Priority: optional
|
||||
Homepage: https://soloconlinux.org.es
|
||||
Description: Conjunto de scripts que permiten buscar modulos python e información sobre ellos.
|
||||
Contiene los programas pip_busca y pip_info, escritos en python y bash respectivamente.
|
||||
|
49
pip_busqueda_deb/usr/local/bin/pip_busca
Normal file
49
pip_busqueda_deb/usr/local/bin/pip_busca
Normal file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
'''
|
||||
Author: LuisGuLo
|
||||
Release: v1.6
|
||||
ChangeLog:
|
||||
v1.6: Peticion simple y extraccion
|
||||
v1.5: browsers de consola y dumps
|
||||
v1.4: Uso de requests-html
|
||||
v1.3: Modulos y venv
|
||||
v1.2: Peticion con user-agent
|
||||
v1.1: Peticion web mediante query
|
||||
v1.0: PoC inicial bash. Cambio a python.
|
||||
'''
|
||||
import sys
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
def mostrar_ayuda():
|
||||
print("══════════════════════════════════════════════════════════════")
|
||||
print("Uso: ./pip_busca <cadena_busqueda>")
|
||||
print("\nBusca paquetes en PyPI cuyo nombre contenga la cadena indicada")
|
||||
print("Ejemplo: ./pip_busca ansi")
|
||||
print("══════════════════════════════════════════════════════════════")
|
||||
|
||||
if len(sys.argv) < 2 or sys.argv[1] in ["--help", "-h"]:
|
||||
mostrar_ayuda()
|
||||
sys.exit(0)
|
||||
|
||||
busqueda = sys.argv[1].lower()
|
||||
url = "https://pypi.org/simple/"
|
||||
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
print(f"❌ Error al conectar con PyPI: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
paquetes = [a.text for a in soup.find_all("a")]
|
||||
coincidentes = [p for p in paquetes if busqueda in p.lower()]
|
||||
|
||||
print(f"\n🔍 Paquetes que contienen '{busqueda}':\n")
|
||||
if not coincidentes:
|
||||
print("❌ No se encontraron coincidencias.")
|
||||
else:
|
||||
for nombre in coincidentes:
|
||||
print(f"📦 {nombre}")
|
||||
|
90
pip_busqueda_deb/usr/local/bin/pip_info
Normal file
90
pip_busqueda_deb/usr/local/bin/pip_info
Normal file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
: ' ---
|
||||
Author: Luis GuLo
|
||||
Release: 1.3
|
||||
Changelog:
|
||||
1.3: Mostrar version Python requerida
|
||||
1.2: Ayuda + Mostrar por defecto 10 ultimas versiones disponibles, con opcion a todas
|
||||
1.1: Compactar salida de todas las versiones disponibles
|
||||
1.0: Localizar paquete y mostrar ultima version + disponibles
|
||||
---'
|
||||
|
||||
mostrar_ayuda() {
|
||||
echo "════════════════════════════════════════════════════════════════════════════════"
|
||||
echo "Uso: $0 <nombre_paquete> [--all]"
|
||||
echo ""
|
||||
echo "Opciones:"
|
||||
echo " --all Muestra todas las versiones disponibles (incluye alphas, betas, etc.)"
|
||||
echo ""
|
||||
echo "Por defecto, se muestran las últimas 10 versiones estables."
|
||||
echo "Nota: Se indica entre paréntesis la version de Python requerida"
|
||||
echo "════════════════════════════════════════════════════════════════════════════════"
|
||||
}
|
||||
|
||||
# Verifica si se pidió ayuda
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
mostrar_ayuda
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Verifica que se haya pasado un nombre de paquete
|
||||
if [ -z "$1" ]; then
|
||||
echo "❌ Error: Debe indicar el nombre del paquete."
|
||||
mostrar_ayuda
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PAQUETE="$1"
|
||||
# Verificar orden: paquete + opcion
|
||||
if [ "$PAQUETE" == "--all" ] ; then
|
||||
echo "❌ Error: Orden en sintaxis obligatoria."
|
||||
mostrar_ayuda
|
||||
exit 0
|
||||
fi
|
||||
|
||||
URL="https://pypi.org/pypi/$PAQUETE/json"
|
||||
RESPUESTA=$(curl -s "$URL")
|
||||
|
||||
# Verifica si la respuesta contiene información válida
|
||||
if echo "$RESPUESTA" | grep -q '"info"'; then
|
||||
NOMBRE=$(echo "$RESPUESTA" | jq -r '.info.name')
|
||||
VERSION=$(echo "$RESPUESTA" | jq -r '.info.version')
|
||||
DESCRIPCION=$(echo "$RESPUESTA" | jq -r '.info.summary')
|
||||
echo "📦 Paquete: $NOMBRE"
|
||||
echo "🔢 Última versión: $VERSION"
|
||||
echo "📝 Descripción: $DESCRIPCION"
|
||||
|
||||
# echo -e "\n📚 Versiones disponibles:"
|
||||
|
||||
mostrar_versiones() {
|
||||
echo "$RESPUESTA" | jq -r '.releases | to_entries[] | "\(.key) \(.value[0].requires_python // "N/A")"' \
|
||||
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+ ' \
|
||||
| sort -k1 -V -r \
|
||||
| head -n 10 \
|
||||
| awk '{printf "%s (%s) ", $1, $2}'
|
||||
echo
|
||||
}
|
||||
|
||||
mostrar_todas_versiones() {
|
||||
echo "$RESPUESTA" | jq -r '.releases | to_entries[] | "\(.key) \(.value[0].requires_python // "N/A")"' \
|
||||
| sort -k1 -V -r \
|
||||
| awk '{printf "%s (%s) ", $1, $2}'
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ "$2" == "--all" ]]; then
|
||||
echo -e "\n📚 Versiones disponibles:"
|
||||
#echo "$RESPUESTA" | jq -r '.releases | keys[]' | sort -V -r | xargs
|
||||
mostrar_todas_versiones
|
||||
else
|
||||
echo -e "\n📚 Ultimas 10 Versiones estables disponibles:"
|
||||
#echo "$RESPUESTA" | jq -r '.releases | keys[]' \
|
||||
# | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
|
||||
# | sort -V -r \
|
||||
# | head -n 10 \
|
||||
# | xargs
|
||||
mostrar_versiones
|
||||
fi
|
||||
else
|
||||
echo "❌ No se encontró información para el paquete '$PAQUETE'"
|
||||
fi
|
BIN
pipbusqueda.deb
Normal file
BIN
pipbusqueda.deb
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user