decorators module

decorators.ignore(exceptions='*')

This Function Acts As A Decorator For Ignoring Some Exceptions That You Define. For Example You Can Set That If Running A Function Have ZeroDivisionError, Function Ignore The Problem And Not Make Exception.

Agrs : * exceptions That Should Be A List Of Exceptions You Want To Ignore Or ‘*’ Character * That Means All Of Exceptions Must Ignore.

class decorators.interface(target_class)

Bases: object

You Can Make Interfaces ( Inspired From PHP ! ) . In Fact You Can Define An Structure That All Of Classes That Extends That Interface Must Have This Structure That You Defined.

You Can Use It Like Decorator. For Example :

``` @interface class UserStructure:

name = None family = None username = None password = None

@interface(UserStructure) class SpecialUsers:

name = None family = None username = None password = None

@interface(UserStructure) class Users:

name = None family = None username = None password = None

```

has_attr(attr)

Checks If This Class Has Specific Attribute Or Not. ( Checks For Every Attribute Like Methods,Variables,… )

instances: dict = {}
is_allowed_structure()

Checks If Has Allowed Structure Or Not.

decorators.once(func)

This Function Acts As A Decorator For Process Initialization. Every Function That Has This Decorator Will Be Called Before The Main Function Once. Important Thing Is That Function Must Not Have Any Arguments Or Kwarguments To Be Called.

Important Thing : * This Function Will Be Called Before The Main Function. * Function Must Not Have Any Arguments Or Kwarguments To Be Called.

decorators.retry(count, exceptions='*')

This Function Acts As A Decorator For Retring On Some Exceptions That You Define. For Example You Can Set That If Running A Function Have HTTPConnectionError, Function Retries And Run Again. You Can Define Count Of Retries Too.

Agrs : * count : Count Of Retries For Target Function * exceptions : a list contains all exceptions that should retry on them or ‘*’ character

means all of exceptions should be retried.

decorators.timer(string)

This Function Acts As A Decorator For Check Spent Time On Executing Functions. Args: Gets One Argument For Printing Format. For Example : ```

@time(“Spent Time Was _T_”) def test():

return True

``` And Output Of This Code After Calling test() Will Be Something Like That :

`Spent Time Was 0:00:00.100404`

Important Parameters : * _T_ : Will Be Replaced With [Hour]:[Minute]:[Second].[MiliSecond] * _H_ : Will Be Replaced With [Hour] * _M_ : Will Be Replaced With [Minute] * _S_ : Will Be Replaced With [Second] * _MS_ : Will Be Replaced With [MiliSecond]

Important : You Can Escape All Of This Parameters With ()