The source code you can found here. It is available as part of my AlexBerUtils s project.
You can install AlexBerUtils from PyPi:
python -m pip install -U alex-ber-utils
See here for more details explanation on how to install.
def issetdescriptor(object: Any) -> bool
This function check if object is set descriptor. The object should not be a class, method, or function, and type
of the object (__class__
) should has “__set__”
.
def ismethod(object: Any) -> bool:
This function check if object
is method. It is done my checking whether object.ismethod()
or whether object
is bound function
.
def has_method(cls: Type, methodName: str) -> bool:
First it check if there is methodName
attribute on cls.
If yes, inspect.isroutine()
is called to do the job.
def update_function_defaults(func: Callable, new_defaults: Optional[Dict[str, Any]] = None,
remove_defaults: Optional[List[str]] = None, is_forced: bool = False)
It merges args and kwargs, taking into account default values from func.
func is the function which default params we want effectively to update.
It is done by creating wrapper function, that changes arguments passed to func a moment before the call happens.
There are 2 different modes that this function operates on. If is_forced
is False
(default), only func
’s params that do have default value will be updated. If True
, all func
’s params will be updated that are mentioned by name in new_defaults and remove_defaults.
It iterates over inspect.signature(func)
and checks:
in default
mode:
- If
param
’s has default parameters and is found innew_defaults,
new param will be generated with default value fromnew_defaults.
- If
param
’s has default parameters and is found inremove_defaults,
new param will be generated with no default.
in forced mode
:
- If
param
’s is found innew_defaults,
new param will be generated with default value fromnew_defaults
(regardless whetherparam
has default value or not). - If
param
’s is found inremove_defaults,
new param will be generated with no default (regardless whetherparam
has default value or not).
See also:
importer
module or How to write easily customizable code?fixabscwd()
function inmains
module or Making relative path to file to work.fix_retry_env()
function inmains
module or Make path to file on Windows works on Linux.- parser module or Description of one the oldest AlexBerUtils project.
- ymlparsers module or Description of low-level API module for another modules.
- init_app_conf module, or My major init_app_con module.
- deploys module, or My deploys module.
- emails module,or My emails module.
- processinvokes module, or My processinvokes module.
- stdLogging module, or My stdLogging Module.
- inspect module, or My inspect module.
- pprint module, or My pprint module.
- in_memory_similarity_search module or in memory similarity search.