xqute.utils
Utilities for xqute
DuplicateFilter
— Filter instances are used to perform arbitrary filtering of LogRecords.</>
a_mkdir
(
path
,*args
,**kwargs
)
— Make a directory asyncly</>a_read_text
(
path
)
(str) — Read the text from a file asyncly</>a_write_text
(
path
,content
)
— Write the text to a file asyncly</>asyncify
(
func
)
(Callable) — Turn a sync function into a Coroutine, can be used as a decorator</>replace_with_leading_space
(
s
,old
,new
)
(str) — Replace a substring with leading spaces and keep the original spaces</>
xqute.utils.
a_read_text
(
path
)
Read the text from a file asyncly
path
(PathLike) — The path of the file
The content of the file
xqute.utils.
a_write_text
(
path
, content
)
Write the text to a file asyncly
path
(PathLike) — The path to the filecontent
(str) — The content to be written to the file
xqute.utils.
asyncify
(
func
)
Turn a sync function into a Coroutine, can be used as a decorator
func
(Callable) — The sync function
The Coroutine
xqute.utils.
a_mkdir
(
path
, *args
, **kwargs
)
Make a directory asyncly
path
(PathLike) — The path to the directory to be made*args
— args forPath(path).mkdir(...)
**kwargs
— kwargs forPath(path).mkdir(...)
xqute.utils.
replace_with_leading_space
(
s
, old
, new
)
→ str
Replace a substring with leading spaces and keep the original spaces
Example:
~~~python
replace_with_leading_space("a
, "x
'a ~~~
Args: s: The string old: The old substring new: The new substring
Returns: The new string
xqute.utils.
DuplicateFilter
(
)
Filter instances are used to perform arbitrary filtering of LogRecords.
Loggers and Handlers can optionally use Filter instances to filter records as desired. The base filter class only allows events which are below a certain point in the logger hierarchy. For example, a filter initialized with "A.B" will allow events logged by loggers "A.B", "A.B.C", "A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If initialized with the empty string, all events are passed.
filter
(
record
)
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.