CDN¶
For quick reference when prototyping you can use the CDN package.
To use a CDN class it must be imported.
from domonic.CDN import *
Or just classes you need…
from domonic.CDN import CDN_JS, CDN_CSS
CDN_JS¶
script(_src=CDN_JS.JQUERY)
CDN_CSS¶
classless_css = link(_rel="stylesheet", _href=CDN_CSS.WATER)
Current CSS constants include:
BOOTSTRAP
MARX
MVP
WATER
BALLOON
THREE_DOTS
MILLIGRAM
X3DOM
FONTAWESOME
MDI
TAILWIND
SIMPLE
Current JavaScript constants include:
JQUERY
JQUERY_UI
UNDERSCORE
BOOTSTRAP
POPPER
D3
MODERNIZER
MOMENT
PIXI
SOCKET
X3DOM
AFRAME
BRYTHON
MATHML
HTMX
LODASH
AXIOS
DAY_JS
CHART_JS
ANIME_JS
VALIDATOR_JS
CDN_IMG¶
CDN_IMG has a placeholder service.
# to change it. do this...
CDN_IMG.PLACEHOLDER_SERVICE = "placebear.com/g"
img(_src=CDN_IMG.PLACEHOLDER(300,100))
# optional seperator if the site uses x instead of slash between dimensions
img(_src=CDN_IMG.PLACEHOLDER(300,100,'x'))
# there’s tons to pick from. (NOT ALL ARE HTTPS):
https://dummyimage.com/420x320/ff7f7f/333333.png&text=Sample
https://fakeimg.pl/420x320/ff0000,128/333333,255/?text=Sample&font=lobster
https://via.placeholder.com/420x320/ff7f7f/333333?text=Sample
domonic.CDN¶
For quick reference when prototyping
- class domonic.CDN.CDN_CSS[source]
CSS Libraries
- class domonic.CDN.CDN_IMG[source]
CDN images
- static PLACEHOLDER(width: int = 100, height: int = 100, HTTP: str = '', seperator: str = '/') str[source]
to update do CDN_IMG.PLACEHOLDER_SERVICE = “placebear.com/g” usage : img(_src=CDN_IMG.PLACEHOLDER(300,100)) default HTTP is none, to let the browser decide # use optional seperator if the site uses x instead of slash img(_src=CDN_IMG.PLACEHOLDER(300,100,’x’))
- class domonic.CDN.CDN_JS[source]
JavaScript libraries
domonic.utils¶
snippets etc
- class domonic.utils.Utils[source]
-
- static chunks(iterable: ~typing.Iterable[~domonic.utils.T], size: int, format: ~typing.Any = <built-in function iter>) Iterator[Any][source]
Iterate over any iterable (list, set, file, stream, strings, whatever), of ANY size
- static clean(lst: Iterable[T]) list[T][source]
[removes falsy values (False, None, 0 and “”) from a list ]
- static dictify(arr: Iterable[T]) dict[T, int][source]
[turns a list into a dictionary where the list items are the keys]
- static digits(text: str = '') str[source]
[takes a string of mix of digits and letters and returns a string of digits]
- static frequency(data: Iterable[T]) dict[T, int][source]
[check the frequency of elements in the data]
- static has_internet(url: str = 'http://www.google.com/', timeout: int = 5) bool[source]
[check if you have internet connection]
- Parameters:
url (str, optional) – [the url to check]. Defaults to ‘http://www.google.com/’.
timeout (int, optional) – [the timeout]. Defaults to 5.
- Returns:
[True if you have internet]
- Return type:
[bool]
- static init_assets(dir: str = 'assets') None[source]
[creates an assets directory with nested js/css/img dirs]
- Parameters:
dir (str, optional) – [default directory name]. Defaults to ‘assets’.
- static is_linux() bool[source]
[check if the system is a linux]
- Returns:
[description]
- Return type:
[bool]
- static is_mac() bool[source]
[check if the system is a mac]
- Returns:
[True if the system is a mac]
- Return type:
[bool]
- static is_nix() bool[source]
[check if the system is a nix based system]
- Returns:
[True if it is a nix based system]
- Return type:
[bool]
- static is_windows() bool[source]
[check if the system is a windows]
- Returns:
[True if windows]
- Return type:
[bool]
- static merge_dictionaries(a: dict[Any, Any], b: dict[Any, Any]) dict[Any, Any][source]
[merges 2 dicts]
- static permutations(word: str) list[source]
[provides all the possible permutations of a given word]
- static replace_between(content: str, match: str, replacement: str, start: int = 0, end: int = 0)[source]
[replace some text but only between certain indexes]
- Parameters:
- Returns:
[the new string]
- Return type:
[str]
- static to_dictionary(keys: Iterable[T], values: Iterable[Any]) dict[T, Any][source]
[take a list of keys and values and returns a dict]
- static truncate(text: str = '', length: int = 0) str[source]
[truncates a string and appends 3 dots]
domonic.decorators¶
- domonic.decorators.as_json(func)[source]
decorate any function to return json instead of a python obj note - used by JSON.py
- domonic.decorators.called(before=None, error: Callable[[Exception], None] = None)[source]
Call a hook before a function runs, with light support for legacy callback sugar.
- domonic.decorators.check(f)[source]
Log entry and exit around a function call.
- domonic.decorators.deprecated(func)[source]
marks a function as deprecated.
- domonic.decorators.el(element='div', string: bool = False)[source]
[wraps the results of a function in an element]
- domonic.decorators.iife(before=None, error: Callable[[Exception], None] = None)
Call a hook before a function runs, with light support for legacy callback sugar.
- domonic.decorators.instead(somethingelse)[source]
Return a fallback value when the wrapped function raises.
- domonic.decorators.log(logger, level='info')[source]
@log(logging.getLogger(‘main’), level=’warning’)
- domonic.decorators.silence(*args, **kwargs)[source]
Suppress stdout for the wrapped function.
Supports both
@silenceand@silence().