Commit 1550b228 authored by guillecxb's avatar guillecxb
Browse files

format

parent 51c5955e
Loading
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -35,8 +35,6 @@ class InternalServiceOps(Resource):
            allowed_invocations_per_second = 0
            time_range_days = 0

        

        res = mycol.find_one(
            {"service_id": service_id, "aef_id": aef_id}, {"_id": 0})

+6 −6
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ def validate_snake_case_keys(obj, path="root"):
            
def get_nested_value(config, path):
    """
    Obtiene un valor dentro de un diccionario anidado siguiendo una ruta de claves separadas por puntos.
    Gets a value within a nested dictionary by following a path of keys separated by periods.
    """
    keys = path.split('.')
    for key in keys:
@@ -48,28 +48,28 @@ def get_nested_value(config, path):

def convert_value_to_original_type(new_value, current_value):
    """
    Convierte new_value al tipo de current_value si es posible.
    Convert new_value to the type of current_value.
    """
    if isinstance(current_value, int):
        try:
            return int(new_value)
        except ValueError:
            return jsonify(message=f"Valor inválido: {new_value} no es un entero"), 400
            return jsonify(message=f"Invalid value: {new_value} is not an integer"), 400
    elif isinstance(current_value, float):
        try:
            return float(new_value)
        except ValueError:
            return jsonify(message=f"Valor inválido: {new_value} no es un flotante"), 400
            return jsonify(message=f"Invalid value: {new_value} is not a float"), 400
    elif isinstance(current_value, bool):
        if isinstance(new_value, str) and new_value.lower() in ["true", "false"]:
            return new_value.lower() == "true"
        elif not isinstance(new_value, bool):
            return jsonify(message=f"Valor inválido: {new_value} no es un booleano"), 400
            return jsonify(message=f"Invalid value: {new_value} is not a boolean"), 400
    return new_value

def convert_nested_values(new_data, reference_data):
    """
    Recorre recursivamente new_data y convierte los valores al tipo original basado en reference_data.
    Recursively traverses new_data and converts values ​​back to the original type based on reference_data.
    """
    if isinstance(new_data, dict) and isinstance(reference_data, dict):
        for key, value in new_data.items():