absfuyu.core.baseclass module
Absfuyu: Core
Bases for other features
Version: 5.1.0 Date updated: 10/03/2025 (dd/mm/yyyy)
- class absfuyu.core.baseclass.CLITextColor[source]
Bases:
object
Color code for text in terminal
- WHITE = '\x1b[37m'
- BLACK = '\x1b[30m'
- BLUE = '\x1b[34m'
- GRAY = '\x1b[90m'
- GREEN = '\x1b[32m'
- RED = '\x1b[91m'
- DARK_RED = '\x1b[31m'
- MAGENTA = '\x1b[35m'
- YELLOW = '\x1b[33m'
- RESET = '\x1b[39m'
- class absfuyu.core.baseclass.MethodNPropertyList(methods: list[str], classmethods: list[str], staticmethods: list[str], properties: list[str])[source]
Bases:
NamedTuple
Contains lists of methods, classmethods, staticmethods, and properties of a class.
- Parameters:
methods (list[str]) – List contains method names of a class.
classmethods (list[str]) – List contains classmethod names of a class.
staticmethods (list[str]) – List contains staticmethod names of a class.
properties (list[str]) – List contains property names of a class.
- methods: list[str]
Alias for field number 0
- classmethods: list[str]
Alias for field number 1
- staticmethods: list[str]
Alias for field number 2
- properties: list[str]
Alias for field number 3
- is_empty() bool [source]
Checks if all lists (methods, classmethods, staticmethods, properties) are empty.
- pack(include_method: bool = True, include_classmethod: bool = True, classmethod_indicator: str = '<classmethod>', include_staticmethod: bool = True, staticmethod_indicator: str = '<staticmethod>') Self [source]
Combines methods, classmethods, and staticmethods into one list.
- Parameters:
include_method (bool, optional) – Whether to include methods in the output, by default
True
include_classmethod (bool, optional) – Whether to include classmethods in the output, by default
True
classmethod_indicator (str, optional) – A string used to mark classmethod in the output. This string is appended to the name of each classmethod to visually differentiate it from regular instance methods, by default
"<classmethod>"
include_staticmethod (bool, optional) – Whether to include staticmethods in the output, by default
True
staticmethod_indicator (str, optional) – A string used to mark staticmethod in the output. This string is appended to the name of each staticmethod to visually differentiate it from regular instance methods, by default
"<staticmethod>"
- Returns:
MethodNPropertyList (combined methods lists)
- Return type:
Self
Example:
>>> test = MethodNPropertyList(["a"], ["b"], ["c"], ["d"]) >>> test.pack() MethodNPropertyList(methods=['a', 'b <classmethod>', 'c <staticmethod>'], properties=['d'])
- class absfuyu.core.baseclass.MethodNPropertyResult[source]
Bases:
dict
[str
,MethodNPropertyList
]All methods and properties of a class and its parent classes.
Sorted in ascending order.
- flatten_value() MethodNPropertyList [source]
Merge all attributes of
dict
’s values into oneMethodNPropertyList
.- Returns:
Flattened value
- Return type:
Example:
>>> test = MethodNPropertyResult( ... ABC=MethodNPropertyList(["a"], ["b"], ["c"], ["d"]), ... DEF=MethodNPropertyList(["e"], ["f"], ["g"], ["h"]), ... ) >>> test.flatten_value() MethodNPropertyList(methods=["a", "e"], classmethods=["b", "f"], staticmethods=["c", "g"], properties=["d", "h"])
- pack_value(include_method: bool = True, include_classmethod: bool = True, classmethod_indicator: str = '<classmethod>', include_staticmethod: bool = True, staticmethod_indicator: str = '<staticmethod>') Self [source]
Join method, classmethod, staticmethod into one list for each value.
- Parameters:
include_method (bool, optional) – Whether to include method in the output, by default
True
include_classmethod (bool, optional) – Whether to include classmethod in the output, by default
True
classmethod_indicator (str, optional) – A string used to mark classmethod in the output. This string is appended to the name of each classmethod to visually differentiate it from regular instance methods, by default
"<classmethod>"
include_staticmethod (bool, optional) – Whether to include staticmethod in the output, by default
True
staticmethod_indicator (str, optional) – A string used to mark staticmethod in the output. This string is appended to the name of each staticmethod to visually differentiate it from regular instance methods, by default
"<staticmethod>"
- Returns:
MethodNPropertyResult with packed value.
- Return type:
Self
Example:
>>> test = MethodNPropertyResult( ... ABC=MethodNPropertyList(["a"], ["b"], ["c"], ["d"]), ... DEF=MethodNPropertyList(["e"], ["f"], ["g"], ["h"]), ... ) >>> test.pack_value() { "ABC": MethodNPropertyList( methods=["a", "b <classmethod>", "c <staticmethod>"], properties=["d"] ), "DEF": MethodNPropertyList( methods=["e", "f <classmethod>", "g <staticmethod>"], properties=["h"] ), }
- prioritize_value(value_name: Literal['methods', 'classmethods', 'staticmethods', 'properties'] = 'methods') dict[str, list[str]] [source]
Prioritize which field of value to show.
- Parameters:
value_name (Literal["methods", "classmethods", "staticmethods", "properties"], optional) – The type of value to prioritize, by default
"methods"
- Returns:
A dictionary with prioritized values.
- Return type:
dict[str, list[str]]
Example:
>>> test = MethodNPropertyResult( ... ABC=MethodNPropertyList(["a"], ["b"], ["c"], ["d"]), ... DEF=MethodNPropertyList(["e"], ["f"], ["g"], ["h"]), ... ) >>> test.prioritize_value("methods") {'ABC': ['a'], 'DEF': ['e']} >>> test.prioritize_value("classmethods") {'ABC': ['b'], 'DEF': ['f']} >>> test.prioritize_value("staticmethods") {'ABC': ['c'], 'DEF': ['g']} >>> test.prioritize_value("properties") {'ABC': ['d'], 'DEF': ['h']}
- print_output(where_to_print: Literal['methods', 'properties'] = 'methods', print_in_one_column: bool = False) None [source]
Beautifully print the result.
- Parameters:
where_to_print (Literal["methods", "properties"], optional) – Whether to print
self.methods
orself.properties
, by default"methods"
print_in_one_column (bool, optional) – Whether to print in one column, by default
False
- class absfuyu.core.baseclass.ShowAllMethodsMixin[source]
Bases:
object
Show all methods of the class and its parent class minus
object
classThis class is meant to be used with other class
Example:
>>> class TestClass(ShowAllMethodsMixin): ... def method1(self): ... >>> TestClass._get_methods_and_properties() { "ShowAllMethodsMixin": MethodNPropertyList( classmethods=[ "_get_methods_and_properties", "show_all_methods", "show_all_properties", ] ), "TestClass": MethodNPropertyList( methods=["method1"] ), }
- classmethod show_all_methods(print_result: bool = False, include_classmethod: bool = True, classmethod_indicator: str = '<classmethod>', include_staticmethod: bool = True, staticmethod_indicator: str = '<staticmethod>', include_private_method: bool = False) dict[str, list[str]] [source]
Class method to display all methods of the class and its parent classes, including the class in which they are defined in alphabetical order.
- Parameters:
print_result (bool, optional) – Beautifully print the output, by default
False
include_classmethod (bool, optional) – Whether to include classmethod in the output, by default
True
classmethod_indicator (str, optional) – A string used to mark classmethod in the output. This string is appended to the name of each classmethod to visually differentiate it from regular instance methods, by default
"<classmethod>"
include_staticmethod (bool, optional) – Whether to include staticmethod in the output, by default
True
staticmethod_indicator (str, optional) – A string used to mark staticmethod in the output. This string is appended to the name of each staticmethod to visually differentiate it from regular instance methods, by default
"<staticmethod>"
include_private_method (bool, optional) – Whether to include private method in the output, by default
False
- Returns:
A dictionary where keys are class names and values are lists of method names.
- Return type:
dict[str, list[str]]
- classmethod show_all_properties(print_result: bool = False) dict[str, list[str]] [source]
Class method to display all properties of the class and its parent classes, including the class in which they are defined in alphabetical order.
- Parameters:
print_result (bool, optional) – Beautifully print the output, by default
False
- Returns:
A dictionary where keys are class names and values are lists of property names.
- Return type:
dict[str, list[str]]
- class absfuyu.core.baseclass.AutoREPRMixin[source]
Bases:
object
Generate
repr()
output as<class(param1=any, param2=any, ...)>
This class is meant to be used with other class
Example:
>>> class Test(AutoREPRMixin): ... def __init__(self, param): ... self.param = param >>> print(repr(Test(1))) Test(param=1)
- class absfuyu.core.baseclass.BaseClass[source]
Bases:
ShowAllMethodsMixin
,AutoREPRMixin
Base class