add func parm type
This commit is contained in:
@@ -8,14 +8,14 @@ from itertools import islice
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def get_data(cfg: object, id: int, pool) -> tuple:
|
||||
async def get_data(cfg: object, id: int, pool: object) -> tuple:
|
||||
"""
|
||||
Retrieves unit name, tool name, and tool data for a given record ID from the database.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object containing database table name.
|
||||
id (int): The ID of the record to retrieve.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
tuple: A tuple containing unit_name, tool_name, and tool_data.
|
||||
"""
|
||||
@@ -26,14 +26,14 @@ async def get_data(cfg: object, id: int, pool) -> tuple:
|
||||
|
||||
return unit_name, tool_name, tool_data
|
||||
|
||||
async def make_pipe_sep_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_pipe_sep_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes pipe-separated data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
@@ -58,14 +58,14 @@ async def make_pipe_sep_matrix(cfg: object, id: int, pool) -> list:
|
||||
|
||||
return matrice_valori
|
||||
|
||||
async def make_ain_din_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_ain_din_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes analog and digital input data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
@@ -92,14 +92,14 @@ async def make_ain_din_matrix(cfg: object, id: int, pool) -> list:
|
||||
|
||||
return matrice_valori
|
||||
|
||||
async def make_channels_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_channels_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes channel-based data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
@@ -120,14 +120,14 @@ async def make_channels_matrix(cfg: object, id: int, pool) -> list:
|
||||
|
||||
return matrice_valori
|
||||
|
||||
async def make_musa_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_musa_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes 'Musa' specific data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
@@ -153,14 +153,14 @@ async def make_musa_matrix(cfg: object, id: int, pool) -> list:
|
||||
return matrice_valori
|
||||
|
||||
|
||||
async def make_tlp_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_tlp_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes 'TLP' specific data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
@@ -180,14 +180,14 @@ async def make_tlp_matrix(cfg: object, id: int, pool) -> list:
|
||||
|
||||
|
||||
|
||||
async def make_gd_matrix(cfg: object, id: int, pool) -> list:
|
||||
async def make_gd_matrix(cfg: object, id: int, pool: object) -> list:
|
||||
"""
|
||||
Processes 'GD' specific data from a CSV record into a structured matrix.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
Returns:
|
||||
list: A list of lists, where each inner list represents a row in the matrix.
|
||||
"""
|
||||
|
||||
@@ -6,14 +6,14 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def main_loader(cfg: object, id: int, pool, action: str) -> None:
|
||||
async def main_loader(cfg: object, id: int, pool: object, action: str) -> None:
|
||||
"""
|
||||
Main loader function to process CSV data based on the specified action.
|
||||
|
||||
Args:
|
||||
cfg (object): Configuration object.
|
||||
id (int): The ID of the CSV record to process.
|
||||
pool: The database connection pool.
|
||||
pool (object): The database connection pool.
|
||||
action (str): The type of data processing to perform (e.g., "pipe_separator", "analogic_digital").
|
||||
"""
|
||||
type_matrix_mapping = {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import re
|
||||
|
||||
def extract_value(patterns: list, primary_source: str, secondary_source: str, default='Not Defined') -> str:
|
||||
"""Extracts the first match for a list of patterns from the primary source.
|
||||
Falls back to the secondary source if no match is found.
|
||||
"""
|
||||
|
||||
for source in (primary_source, secondary_source):
|
||||
for pattern in patterns:
|
||||
matches = re.findall(pattern, source, re.IGNORECASE)
|
||||
|
||||
Reference in New Issue
Block a user