consulta-amigable 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ from consulta_amigable.constants import buttons as BTN
2
+ from consulta_amigable.steps.click import ClickBtn, Rows, Search
3
+
4
+ from .scraper import MEFScraper
5
+
6
+ __all__ = ["BTN", "ClickBtn", "Rows", "Search", "MEFScraper"]
@@ -0,0 +1,3 @@
1
+ from . import buttons as BTN
2
+
3
+ __all__ = ["BTN"]
@@ -0,0 +1,32 @@
1
+ """ID de los botones de la plataforma de consulta amigable"""
2
+
3
+ NIVEL_GOBIERNO = "ctl00$CPH1$BtnTipoGobierno"
4
+ SECTOR = "ctl00$CPH1$BtnSector"
5
+ PLIEGO = "ctl00$CPH1$BtnPliego"
6
+ EJECUTORA = "ctl00$CPH1$BtnEjecutora"
7
+ GENERICA = "ctl00$CPH1$BtnGenerica"
8
+ SUB_GENERICA = "ctl00$CPH1$BtnSubGenerica"
9
+ DETALLE_SUB_GENERICA = "ctl00$CPH1$BtnSubGenericaDetalle"
10
+ ESPECIFICA = "ctl00$CPH1$BtnEspecifica"
11
+ DETALLE_ESPECIFICA = "ctl00$CPH1$BtnEspecificaDetalle"
12
+ MES = "ctl00$CPH1$BtnMes"
13
+ DEPARTAMENTO = "ctl00$CPH1$BtnDepartamento"
14
+ DEPARTAMENTO_META = "ctl00$CPH1$BtnDepartamentoMeta"
15
+ MUNICIPALIDAD = "ctl00$CPH1$BtnMunicipalidad"
16
+ PROVINCIA = "ctl00$CPH1$BtnProvincia"
17
+ FUNCION = "ctl00$CPH1$BtnFuncion"
18
+ FUENTE = "ctl00$CPH1$BtnFuenteAgregada"
19
+ RUBRO = "ctl00$CPH1$BtnRubro"
20
+ PROGRAMA_PARTICIPATIVO = "ctl00$CPH1$BtnProgramaPpto"
21
+ PROGRAMA_PPTO = "ctl00$CPH1$BtnProgramaPpto"
22
+ ACTIVIDAD_PROYECTO = "ctl00$CPH1$BtnActProy"
23
+ PROGRAMA = "ctl00$CPH1$BtnPrograma"
24
+ SUB_PROGRAMA = "ctl00$CPH1$BtnSubPrograma"
25
+ TRIMESTRE = "ctl00$CPH1$BtnTrimestre"
26
+
27
+ # adicionales
28
+ SUB_TIPO_GOBIERNO = "ctl00$CPH1$BtnSubTipoGobierno"
29
+ GOB_LOCALES_MANCOMUNIDADES = "ctl00$CPH1$BtnSubTipoGobierno"
30
+ CATEGORIA_PRESUPUESTAL = "ctl00$CPH1$BtnProgramaPpto"
31
+ PRODUCTO_PROYECTO = "ctl00$CPH1$BtnProdProy"
32
+ ACTIVIDAD_ACCION = "ctl00$CPH1$BtnAAO"
@@ -0,0 +1,52 @@
1
+ "generales"
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Literal
5
+
6
+ from .reference import (
7
+ GASTO_URL_V4,
8
+ GASTO_URL_V5,
9
+ GASTO_URL_V6,
10
+ GASTO_URL_V7,
11
+ INGRESO_URL_V4,
12
+ INGRESO_URL_V5,
13
+ INGRESO_URL_V6,
14
+ )
15
+ from .tables import COLUMNS_GASTO_V4, COLUMNS_GASTO_V5, COLUMNS_INGRESO
16
+
17
+
18
+ @dataclass(frozen=True)
19
+ class Config:
20
+ years: range
21
+ url: str
22
+ columns: list[str]
23
+
24
+
25
+ CONFIG_GASTO = {
26
+ "v4": Config(range(2009, 2012), GASTO_URL_V4, COLUMNS_GASTO_V4),
27
+ "v5": Config(range(2012, 2016), GASTO_URL_V5, COLUMNS_GASTO_V5),
28
+ "v6": Config(range(2016, 2024), GASTO_URL_V6, COLUMNS_GASTO_V5),
29
+ "v7": Config(range(2024, 2027), GASTO_URL_V7, COLUMNS_GASTO_V5),
30
+ }
31
+
32
+ CONFIG_INGRESO = {
33
+ "v4": Config(range(2009, 2012), INGRESO_URL_V4, COLUMNS_INGRESO),
34
+ "v5": Config(range(2012, 2016), INGRESO_URL_V5, COLUMNS_INGRESO),
35
+ "v6": Config(range(2016, 2027), INGRESO_URL_V6, COLUMNS_INGRESO),
36
+ }
37
+
38
+
39
+ # ============================================
40
+ # FUNCIONES DE DETECCIÓN DE VERSIÓN
41
+ # ============================================
42
+
43
+
44
+ def get_config(year: int, tipo: Literal["gasto", "ingreso"] = "gasto") -> Config:
45
+ configs = CONFIG_GASTO if tipo == "gasto" else CONFIG_INGRESO
46
+
47
+ for version, config in configs.items():
48
+ # print(config)
49
+ if year in config.years:
50
+ return config
51
+
52
+ raise ValueError(f"Año {year} no soportado para tipo '{tipo}'")
@@ -0,0 +1,35 @@
1
+ "referencia de url para la consulta de gasto e ingresos"
2
+
3
+ # Gastos
4
+ GASTO_URL_V4 = (
5
+ "https://apps5.mineco.gob.pe/transparencia/mensual/Navegar_4.aspx?y={year}&ap={ap}"
6
+ )
7
+ GASTO_URL_V5 = (
8
+ "https://apps5.mineco.gob.pe/transparencia/mensual/Navegar_5.aspx?y={year}&ap={ap}"
9
+ )
10
+ GASTO_URL_V6 = (
11
+ "https://apps5.mineco.gob.pe/transparencia/mensual/Navegar_6.aspx?y={year}&ap={ap}"
12
+ )
13
+ GASTO_URL_V7 = "https://apps5.mineco.gob.pe/transparencia/Navegador/Navegar_7.aspx?y={year}&ap={ap}"
14
+
15
+ # Ingresos
16
+ INGRESO_URL_V4 = "https://apps5.mineco.gob.pe/transparenciaingresos/Navegador/Navegar_4.aspx?y={year}"
17
+ INGRESO_URL_V5 = "https://apps5.mineco.gob.pe/transparenciaingresos/Navegador/Navegar_5.aspx?y={year}"
18
+ INGRESO_URL_V6 = "https://apps5.mineco.gob.pe/transparenciaingresos/Navegador/Navegar_6.aspx?y={year}"
19
+
20
+
21
+ # ============================================
22
+ # HEADERS HTTP
23
+ # ============================================
24
+
25
+ DEFAULT_HEADERS = {
26
+ "User-Agent": "Mozilla/5.0",
27
+ "Content-Type": "application/x-www-form-urlencoded",
28
+ }
29
+
30
+
31
+ # ============================================
32
+ # COLORES PARA PROGRESO
33
+ # ============================================
34
+
35
+ COLORS_PROGRESS = ["bold white", "bold cyan", "yellow", "cyan", "blue"]
@@ -0,0 +1,35 @@
1
+ "columnas presentes para distintsa version del apx"
2
+
3
+ # Gastos
4
+ COLUMNS_GASTO_V4 = [
5
+ "codigo_grp",
6
+ "concepto_region",
7
+ "pia",
8
+ "pim",
9
+ "compromiso",
10
+ "devengado",
11
+ "girado",
12
+ "avance_p",
13
+ ]
14
+
15
+ COLUMNS_GASTO_V5 = [
16
+ "codigo_grp",
17
+ "concepto_region",
18
+ "pia",
19
+ "pim",
20
+ "certificacion",
21
+ "compromiso_anual",
22
+ "atencion_de_compromiso_mensual",
23
+ "devengado",
24
+ "girado",
25
+ "avance_p",
26
+ ]
27
+
28
+ # Ingresos (igual para todas las versiones)
29
+ COLUMNS_INGRESO = [
30
+ "codigo_grp",
31
+ "concepto_region",
32
+ "pia",
33
+ "pim",
34
+ "recaudado",
35
+ ]