Core utilities
Most common function which are needed everywhere. These function are exported in gws
and can be used as gws.function().
Class | cached |
Decorator for a cached property. |
Function | action |
Undocumented |
Function | app |
Undocumented |
Function | collect |
Undocumented |
Function | compact |
Remove all None values from a collection. |
Function | deep |
Deeply merge dicts/Datas into a nested dict/Data. Latter vales overwrite former ones unless None. |
Function | delete |
Undocumented |
Function | dirname |
Undocumented |
Function | ensure |
Check if a (possibly nested) directory exists and create if it does not. |
Function | ensure |
Undocumented |
Function | exit |
Exit the application. |
Function | first |
Undocumented |
Function | format |
Undocumented |
Function | get |
Get a nested value/attribute from a structure. |
Function | get |
Undocumented |
Function | get |
Undocumented |
Function | get |
Undocumented |
Function | has |
True if a nested value/attribute exists in a structure. |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | is |
Check if the value is empty (None, empty list/dict/object). |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | join |
Undocumented |
Function | merge |
Create a new dict/Data object by merging values from dicts/Datas or kwargs. Latter vales overwrite former ones unless None. |
Function | omit |
Undocumented |
Function | parse |
Parse an ACL config into an ACL. |
Function | pick |
Undocumented |
Function | pop |
Undocumented |
Function | printtemp |
Return a transient path name in the print directory. |
Function | random |
Generate a random string of length size . |
Function | read |
Undocumented |
Function | read |
Undocumented |
Function | serialize |
Undocumented |
Function | server |
Undocumented |
Function | set |
Undocumented |
Function | sha256 |
Undocumented |
Function | split |
Undocumented |
Function | strip |
Strip all strings and remove empty values from a collection. |
Function | to |
Convert a value to bytes by converting it to string and encoding. |
Function | to |
Convert a value to a Data. If the argument is a Data object, return it. |
Function | to |
Convert a value to a dict. If the argument is an object, return its dict . |
Function | to |
Convert a value to a float or 0.0 if this fails. |
Function | to |
Convert a value to an int or 0 if this fails. |
Function | to |
Convert a multiline string into a list of strings. |
Function | to |
Convert a value to a list. |
Function | to |
Undocumented |
Function | to |
Round and convert a value to an int or 0 if this fails. |
Function | to |
Convert a value to a string. |
Function | to |
Convert a value to an uid (alphanumeric string). |
Function | to |
Undocumented |
Function | uniq |
Remove duplicate elements from a collection. |
Function | unserialize |
Undocumented |
Function | write |
Undocumented |
Function | write |
Undocumented |
Constant | UID |
Undocumented |
Class | _ |
Undocumented |
Class | _ |
Undocumented |
Function | _chown |
Undocumented |
Function | _get |
Undocumented |
Constant | _UID |
Undocumented |
Variable | _app |
Undocumented |
Variable | _app |
Undocumented |
Variable | _server |
Undocumented |
Deeply merge dicts/Datas into a nested dict/Data. Latter vales overwrite former ones unless None.
Parameters | |
x | dict or Data. |
y | dict or Data. |
concat | if true, list will be concatenated, otherwise merged |
Returns | |
A new object (dict or Data). |
str
, base_dir: str
= None, mode: int
= 493, user: int
= None, group: int
= None) -> str
:
(source)
¶
Check if a (possibly nested) directory exists and create if it does not.
Parameters | |
dirstr | Path to a directory. |
basestr | Base directory. |
mode:int | Directory creation mode. |
user:int | Directory user (defaults to gws.UID) |
group:int | Directory group (defaults to gws.GID) |
Returns | |
str | The absolute path to the directory. |
Get a nested value/attribute from a structure.
Parameters | |
x | A dict, list or Data. |
key | A list or a dot separated string of nested keys. |
default | The default value. |
Returns | |
The value if it exists and the default otherwise. |
True if a nested value/attribute exists in a structure.
Parameters | |
x | A dict, list or Data. |
key | A list or a dot separated string of nested keys. |
Returns | |
bool | True if a key exists |
Create a new dict/Data object by merging values from dicts/Datas or kwargs. Latter vales overwrite former ones unless None.
Parameters | |
*args | dicts or Datas. |
**kwargs | Keyword args. |
Returns | |
dict|Data | A new object (dict or Data). |
Parse an ACL config into an ACL.
Parameters | |
acl | an ACL config. Can be given as a string allow X, allow Y, deny Z, or as a list of dicts { role X type allow }, { role Y type deny }, or it can already be an ACL [1 X], [0 Y], or it can be None. |
Returns | |
types.Acl | Access list. |
Convert a multiline string into a list of strings.
Strip each line, skip empty lines, if comment
is given, also remove lines starting with it.
Convert a value to a list.
Parameters | |
x | A value. Is it's a string, split it by the delimiter |
delimiter:str | |
Returns | |
list | A list. |
Convert a value to a string.
Parameters | |
x | Value. |
encodings:list[ | A list of acceptable encodings. If the value is bytes, try each encoding, and return the first one which passes without errors. |
Returns | |
str | A string. |