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):

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 acronym(sentence: str) str[source]

[pass a sentence, returns the acronym]

Parameters:

sentence ([str]) – [typically 3 words]

Returns:

[a TLA (three letter acronym)]

Return type:

[str]

static case_camel(s: str) str[source]

case_camel(‘camel-case’) > ‘camelCase’

static case_kebab(s: str) str[source]

kebab(‘camelCase’) # ‘camel-case’

static case_snake(s: str) str[source]

snake(‘camelCase’) # ‘camel_case’

static chunk(values: Sequence[T], size: int) list[Sequence[T]][source]

chunk a list into batches

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 ]

Parameters:

lst ([list]) – [lst to operate on]

Returns:

[a new list with falsy values removed]

Return type:

[list]

static dictify(arr: Iterable[T]) dict[T, int][source]

[turns a list into a dictionary where the list items are the keys]

Parameters:

arr ([list]) – [list to change]

Returns:

[a new dict where the list items are now the keys]

Return type:

[dict]

static digits(text: str = '') str[source]

[takes a string of mix of digits and letters and returns a string of digits]

Parameters:

text (str, optional) – [the text to change]. Defaults to ‘’.

Returns:

[a string of digits]

Return type:

[str]

static escape(s: str) str[source]

[escape a string]

Parameters:

s ([str]) – [the string to escape]

Returns:

[the escaped string]

Return type:

[str]

static frequency(data: Iterable[T]) dict[T, int][source]

[check the frequency of elements in the data]

Parameters:

data ([type]) – [the data to check]

Returns:

[a dict of elements and their frequency]

Return type:

[dict]

static get_vowels(string: str) list[str][source]

[get a list of vowels from the word]

Parameters:

string ([str]) – [the word to check]

Returns:

[a list of vowels]

Return type:

[list]

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]

Parameters:
  • a ([dict]) – [dict a]

  • b ([dict]) – [dict b]

Returns:

[a new dict]

Return type:

[dict]

static permutations(word: str) list[source]

[provides all the possible permutations of a given word]

Parameters:

word ([str]) – [the word to get permutations for]

Returns:

[a list of permutations]

Return type:

[list]

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:
  • content (str) – [the content whos text you will be replacing]

  • match (str) – [the string to find]

  • replacement (str) – [the string to replace it with]

  • start (int, optional) – [start index]. Defaults to 0.

  • end (int, optional) – [end index]. Defaults to 0.

Returns:

[the new string]

Return type:

[str]

static squash(the_list: Iterable[Iterable[T]]) list[T][source]

[turns a 2d array into a flat one]

Parameters:

the_list ([list]) – [a 2d array]

Returns:

[a flattened 1d array]

Return type:

[list]

static to_dictionary(keys: Iterable[T], values: Iterable[Any]) dict[T, Any][source]

[take a list of keys and values and returns a dict]

Parameters:
  • keys ([list]) – [a list of keys]

  • values ([list]) – [a list of value]

Returns:

[a dictionary]

Return type:

[dict]

static truncate(text: str = '', length: int = 0) str[source]

[truncates a string and appends 3 dots]

Parameters:
  • text (str, optional) – [the text to truncate]. Defaults to ‘’.

  • length (int, optional) – [the max length]. Defaults to 0.

Returns:

[the truncated string]

Return type:

[str]

static unescape(s: str) str[source]

[unescape a string]

Parameters:

s ([str]) – [the string to unescape]

Returns:

[the unescaped string]

Return type:

[str]

static unique(some_arr: Iterable[T]) list[T][source]

[removes duplicates from a list]

Parameters:

some_arr ([list]) – [list containing duplicates]

Returns:

[a list containing no duplicates]

Return type:

[list]

static untitle(string: str) str[source]

[the opposite of title]

Parameters:

str ([str]) – [the string to change]

Returns:

[a string with the first character set to lowercase]

Return type:

[str]

static url2file(url: str) str[source]

[gen a safe filename from a url. by replacing ‘/’ for ‘_’ and ‘:’ for ‘__’ ]

Parameters:

url ([str]) – [the url to turn into a filename]

Returns:

[description]

Return type:

[str]

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 @silence and @silence().