Cat Feeder  1.0.0
The Cat feeder project
Loading...
Searching...
No Matches
backend.src.libs.favicon.favicon_helpers Namespace Reference

Functions

HttpDataTypes reducer_type_to_data_type (IR_CONST.FileFormat reducer_type, *, Disp disp=FAVICON_HELPER_DISP)
 
str generate_image_path (str filename, str file_id)
 
List[Dict[str, Any]] list_from_table ("SQL" sql, str table, *, str title="_list_from_table", Disp disp=FAVICON_HELPER_DISP)
 
Dict[str, Any] extract_line_from_id (List[Dict[str, Any]] data_list, Optional[Union[int, str]] entry_id, *, Disp disp=FAVICON_HELPER_DISP)
 
Dict[str, Any] get_from_table ("SQL" sql, str table, Union[int, str] item_id, *, str title="get_from_table", Disp disp=FAVICON_HELPER_DISP)
 
bool is_hex_colour_valid (str colour)
 
str pad_hex_colour (str colour, bool with_alpha=True)
 
str unpad_hex_colour (str colour)
 

Variables

Disp FAVICON_HELPER_DISP
 

Detailed Description

# +==== BEGIN CatFeeder =================+
# LOGO:
# ..............(..../\
# ...............)..(.')
# ..............(../..)
# ...............\‍(__)|
# Inspired by Joan Stark
# source https://www.asciiart.eu/
# animals/cats
# /STOP
# PROJECT: CatFeeder
# FILE: favicon_helpers.py
# CREATION DATE: 12-01-2026
# LAST Modified: 22:17:14 12-01-2026
# DESCRIPTION:
# This is the backend server in charge of making the actual website work.
# /STOP
# COPYRIGHT: (c) Cat Feeder
# PURPOSE: File in charge of containing the functions that will help the favicon classes in the different processes.
# // AR
# +==== END CatFeeder =================+

Function Documentation

◆ extract_line_from_id()

Dict[str, Any] backend.src.libs.favicon.favicon_helpers.extract_line_from_id ( List[Dict[str, Any]] data_list,
Optional[Union[int, str]] entry_id,
* ,
Disp disp = FAVICON_HELPER_DISP )
Extract a line from a list of dictionaries based on the 'id' key.

Args:
    data_list (List[Dict[str, Any]]): The list of dictionaries to search.
    entry_id (Union[int,str]): The id to search for.
    disp (Disp, optional): The display logger to use.

Returns:
    Dict[str, Any]: The dictionary with the matching id. If no matching
    entry is found the function returns a dictionary containing only the
    `'id'` key with the original `entry_id` value (e.g. `{'id': entry_id}`).

Definition at line 122 of file favicon_helpers.py.

◆ generate_image_path()

str backend.src.libs.favicon.favicon_helpers.generate_image_path ( str filename,
str file_id )
Generate the full image path for a favicon in the bucket.

Args:
    filename (str): The filename of the image.
    file_id (str): The unique identifier for the favicon.

Returns:
    str: The full path to the image in the bucket.

Definition at line 69 of file favicon_helpers.py.

◆ get_from_table()

Dict[str, Any] backend.src.libs.favicon.favicon_helpers.get_from_table ( "SQL" sql,
str table,
Union[int, str] item_id,
* ,
str title = "get_from_table",
Disp disp = FAVICON_HELPER_DISP )
Retrieve a single row by id from `table`.

Args:
    sql (SQL): SQL helper instance.
    table (str): Table name to query.
    item_id (Union[int, str]): The id value to look up.
    title (str): Optional logging title.
    disp (Disp): Optional display logger.

Returns:
    Dict[str, Any]: The found row as a dictionary. If the SQL call fails
    the function returns a dict with `{'id': id}`. If the query succeeds
    but no rows are found it returns an empty dict.

Definition at line 156 of file favicon_helpers.py.

◆ is_hex_colour_valid()

bool backend.src.libs.favicon.favicon_helpers.is_hex_colour_valid ( str colour)
Check if a string is a valid hex colour code.

Args:
    colour (str): The colour string to validate.
Returns:
    bool: True if valid hex colour, False otherwise.

Definition at line 199 of file favicon_helpers.py.

◆ list_from_table()

List[Dict[str, Any]] backend.src.libs.favicon.favicon_helpers.list_from_table ( "SQL" sql,
str table,
* ,
str title = "_list_from_table",
Disp disp = FAVICON_HELPER_DISP )
Retrieve all rows from `table` using the provided SQL helper.

This wraps the low-level SQL `get_data_from_table` call and returns a
list of dictionaries. On SQL failure the function logs the error and
returns an empty list.

Args:
    sql (SQL): SQL helper instance with `get_data_from_table`.
    table (str): Table name to query.
    title (str): Optional logging title.
    disp (Disp): Optional display logger.

Returns:
    List[Dict[str, Any]]: The list of rows (possibly empty on error).

Definition at line 85 of file favicon_helpers.py.

◆ pad_hex_colour()

str backend.src.libs.favicon.favicon_helpers.pad_hex_colour ( str colour,
bool with_alpha = True )
Normalize a hex colour to full form.

- #RGB      → #RRGGBB
- #RGBA     → #RRGGBBAA
- #RRGGBB   → #RRGGBB or #RRGGBBFF
- #RRGGBBAA → unchanged

Args:
    colour (str): Hex colour
    with_alpha (bool): If True, ensure alpha channel exists

Returns:
    str: Normalized hex colour

Definition at line 212 of file favicon_helpers.py.

◆ reducer_type_to_data_type()

HttpDataTypes backend.src.libs.favicon.favicon_helpers.reducer_type_to_data_type ( IR_CONST.FileFormat reducer_type,
* ,
Disp disp = FAVICON_HELPER_DISP )
Convert an ImageReducer FileFormat to an HttpDataTypes value.

Args:
    reducer_type (IR_CONST.FileFormat): The image reducer file format.

Returns:
    HttpDataTypes: The corresponding HTTP data type.

Definition at line 41 of file favicon_helpers.py.

◆ unpad_hex_colour()

str backend.src.libs.favicon.favicon_helpers.unpad_hex_colour ( str colour)
Compress a hex colour to shorthand when safe.

- #RRGGBB   → #RGB
- #RRGGBBAA → #RGBA
- Otherwise unchanged

Definition at line 243 of file favicon_helpers.py.

Variable Documentation

◆ FAVICON_HELPER_DISP

Disp backend.src.libs.favicon.favicon_helpers.FAVICON_HELPER_DISP
Initial value:
1= initialise_logger(
2 class_name="FaviconHelperDisp", debug=EnvLoader().debug
3)

Definition at line 36 of file favicon_helpers.py.