src/dirbs/api/common/imei.py
def is_in_registration_list(db_conn, cursor, imei_norm: str) -> bool:
    """
    Method to check if an IMEI exists in the Registration List.

    TODO: use either of "db_conn, cursor" in the function.

    Arguments:
        db_conn: PostgreSQL database connection object
        cursor: PostgreSQL connection cursor
        imei_norm: normalized IMEI
    Returns:
        is_in_registration_list: Boolean
    """
    cursor.execute(sql.SQL("""SELECT EXISTS(SELECT 1
                                              FROM registration_list
                                             WHERE imei_norm = %(imei_norm)s
                                               AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)
                                               AND {wl_status_filter}) AS in_registration_list""")  # noqa: Q449
                   .format(wl_status_filter=registration_list_status_filter_sql()), {'imei_norm': imei_norm})
    in_registration_list = cursor.fetchone().in_registration_list
    exempted_device_types = current_app.config['DIRBS_CONFIG'].region_config.exempted_device_types
    if not in_registration_list and len(exempted_device_types) > 0:
        imei_sql = str(cursor.mogrify("""SELECT %s::TEXT AS imei_norm""", [imei_norm]), db_conn.encoding)

        sql_query = filter_imei_list_sql_by_device_type(db_conn,
                                                        exempted_device_types,
                                                        imei_sql)
        cursor.execute(sql_query)
        # The IMEI is returned if it does not belong to an exempted device type.
        # As the IMEI was not in registration list and is not exempted,
        # the in_registration_list value would be set to False.
        in_registration_list = cursor.fetchone() is None
    return in_registration_list

    Method to check if an IMEI exists in the Registration List.

    TODO: use either of "db_conn, cursor" in the function.

    Arguments:
        db_conn: PostgreSQL database connection object
        cursor: PostgreSQL connection cursor
        imei_norm: normalized IMEI
    Returns:
        is_in_registration_list: Boolean
    
Method to check if an IMEI exists in the Registration List.
TODO: use either of "db_conn, cursor" in the function.
Method to check if an IMEI exists in the Registration List . TODO : use either of " db_conn cursor " in the function .
def is_in_registration_list(db_conn, cursor, imei_norm: str) -> bool:
    cursor.execute(sql.SQL("""SELECT EXISTS(SELECT 1
                                              FROM registration_list
                                             WHERE imei_norm = %(imei_norm)s
                                               AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)
                                               AND {wl_status_filter}) AS in_registration_list""")  
                   .format(wl_status_filter=registration_list_status_filter_sql()), {'imei_norm': imei_norm})
    in_registration_list = cursor.fetchone().in_registration_list
    exempted_device_types = current_app.config['DIRBS_CONFIG'].region_config.exempted_device_types
    if not in_registration_list and len(exempted_device_types) > 0:
        imei_sql = str(cursor.mogrify("""SELECT %s::TEXT AS imei_norm""", [imei_norm]), db_conn.encoding)
        sql_query = filter_imei_list_sql_by_device_type(db_conn,
                                                        exempted_device_types,
                                                        imei_sql)
        cursor.execute(sql_query)
        in_registration_list = cursor.fetchone() is None
    return in_registration_list
def is_in_registration_list ( db_conn , cursor , imei_norm : str ) -> bool : cursor . execute ( sql . SQL ( """SELECT EXISTS(SELECT 1
                                              FROM registration_list
                                             WHERE imei_norm = %(imei_norm)s
                                               AND virt_imei_shard = calc_virt_imei_shard(%(imei_norm)s)
                                               AND {wl_status_filter}) AS in_registration_list""" ) . format ( wl_status_filter = registration_list_status_filter_sql ( ) ) , { 'imei_norm' : imei_norm } ) in_registration_list = cursor . fetchone ( ) . in_registration_list exempted_device_types = current_app . config [ 'DIRBS_CONFIG' ] . region_config . exempted_device_types if not in_registration_list and len ( exempted_device_types ) > 0 : imei_sql = str ( cursor . mogrify ( """SELECT %s::TEXT AS imei_norm""" , [ imei_norm ] ) , db_conn . encoding ) sql_query = filter_imei_list_sql_by_device_type ( db_conn , exempted_device_types , imei_sql ) cursor . execute ( sql_query ) in_registration_list = cursor . fetchone ( ) is None return in_registration_list
Method to check if an IMEI exists in the Registration List.
Method to check if an IMEI exists in the Registration List .
"""
    Method to check if an IMEI exists in the Registration List.

    TODO: use either of "db_conn, cursor" in the function.

    Arguments:
        db_conn: PostgreSQL database connection object
        cursor: PostgreSQL connection cursor
        imei_norm: normalized IMEI
    Returns:
        is_in_registration_list: Boolean
    """ # noqa: Q449 # The IMEI is returned if it does not belong to an exempted device type. # As the IMEI was not in registration list and is not exempted, # the in_registration_list value would be set to False.
None
is_in_registration_list
db_conn
PostgreSQL database connection object
PostgreSQL database connection object
cursor
PostgreSQL connection cursor
PostgreSQL connection cursor
imei_norm
str
None