Domonic: CDN

To quickly use and reference external assets when prototyping use the CDN package.

Currently there are 3 types of CDN. .js, .css and .img

Their features will be added here.

To use features from CDN they must be imported.

from domonic.CDN import *

Or just class you need

from domonic.CDN import CDN_JS



currently constants exist for:

  • JQUERY_3_5_1
  • POPPER_1_16_1
  • D3_6_1_0
  • MODERNIZER_2_8_3
  • MOMENT_2_27_0
  • PIXI_5_3_3
  • SOCKET_1_4_5


classless_css = link(_rel="stylesheet", _href=CDN_CSS.WATER_LATEST)

currently constants exist for:

  • MARX
  • MVP
  • THREE_DOTS_0_2_0
  • MILLIGRAM_1_3_0
  • X3DOM
  • MDI_5_4_55


CDN_IMG has a placeholder service.

# to change it. do this...


# optional seperator if the site uses x instead of slash between dimensions

# there’s tons to pick from. (NOT ALL ARE HTTPS):


Refs to some useful .js and .css libs.

use for prototyping. wget anything in later and create your own local references once ur happy

TODO - integrity/cross origin/module?

WARNING/NOTE - dont use. this isn’t released or documented. just ideas atm…

class domonic.CDN.CDN_CSS[source]

Preferably use version numbers if available. user LATEST if it always gets the latest

class domonic.CDN.CDN_IMG[source]

CDN images

static PLACEHOLDER(width=100, height=100, HTTP='', seperator='/')[source]

to update do CDN_IMG.PLACEHOLDER_SERVICE = “” 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]

You will need to append the lib version number if you add any libs here # obvious candidates…


snippets etc

class domonic.utils.Utils[source]


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

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

static case_kebab(s: str)[source]

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

static case_snake(s: str)[source]

snake(‘camelCase’) # ‘camel_case’

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

chunk a list into batches

static chunks(iterable, size, format=<built-in function iter>)[source]

Iterate over any iterable (list, set, file, stream, strings, whatever), of ANY size

static clean(lst)[source]

[removes falsy values (False, None, 0 and “”) from a list ]

Parameters:lst ([type]) – [lst to operate on]
Returns:[a new list with falsy values removed]
Return type:[type]
static dictify(arr: str)[source]

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

Parameters:arr ([type]) – [list to change]
Returns:[a new dict where the list items are now the keys]
Return type:[type]
static escape(s: str)[source]

[escape a string]

Parameters:s ([str]) – [the string to escape]
Return type:[str]
static frequency(data)[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)[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='', timeout=5)[source]

[check if you have internet connection]

  • url (str, optional) – [the url to check]. Defaults to ‘’.
  • timeout (int, optional) – [the timeout]. Defaults to 5.


Return type:


static init_assets(dir: str = 'assets')[source]

[creates an assets directory with nested js/css/img dirs]

Parameters:dir (str, optional) – [default directory name]. Defaults to ‘assets’.
static merge_dictionaries(a, b)[source]

[merges 2 dicts]

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

[a new dict]

Return type:


static permutations(word: str)[source]

[provides all the possible permutations of a given word]

Parameters:word ([str]) – [the word to get permutations for]
Return type:[str]
static random_color(self)[source]

TODO - remove in 0.3 as we have color class.

static replace_between(content: str, match: str, replacement: str, start: int = 0, end: int = 0)[source]

[replace some text but only between certain indexes]

  • 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.


Return type:


static squash(the_list: list)[source]

[turns a 2d array into a flat one]

Parameters:the_list ([type]) – [a 2d array]
Returns:[a flattened 1d array]
Return type:[type]
static to_dictionary(keys, values)[source]

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

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

[a dictionary]

Return type:


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

[truncates a string and appends 3 dots]

  • text (str, optional) – [the text to truncate]. Defaults to ‘’.
  • length (int, optional) – [the max length]. Defaults to 0.


Return type:


static unescape(s: str)[source]

[unescape a string]

Parameters:s ([str]) – [the string to unescape]
Return type:[str]
static unique(some_arr)[source]

[removes duplicates from a list]

Parameters:some_arr ([type]) – [list containing duplicates]
Returns:[a list containing no duplicates]
Return type:[type]
static untitle(string: str)[source]

[the opposite of title]

Parameters:str ([type]) – [the string to change]
Returns:[a string with the first character set to lowercase]
Return type:[type]
static url2file(url: str)[source]

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

Parameters:url ([str]) – [the url to turn into a filename]
Return type:[str]


domonic.decorators.called(before=None, error=None)[source]

[calls before() passing the response as args to the decorated function. optional error handler. run the decorated function immediately.

WARNING: this is not for the regular decorating of a function its syntactical sugar for a callback i.e.

lambda: º.ajax(’’), lambda err: print(‘error:’, err))
def success(data=None):
print(“sweet!”) print(data)

logs entry and exit of a function


This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

domonic.decorators.el(element='div', string=False)[source]

[wraps the results of a function in an element]

domonic.decorators.instead(f, somethingelse)[source]

what to return if it fails

domonic.decorators.log(logger, level='info')[source]

@log(logging.getLogger(‘main’), level=’warning’)

domonic.decorators.silence(*args, **kwargs)[source]

stop a function from doing anything