🐍 Python API

Builder

The CI/CD builder script.

class confirm.ci.builder.Builder(image, names, templates_dir, build_dir)

The corporate identity / corporate design builder.

Parameters:
  • image (str) – The image path

  • names (str) – The family names

build()

Build all colour assets.

build_ase()

Build the ASE file.

The “ASE” file is an “Adobe Swatch Exchange” file, thus the name. Unfortunately, the ASE file is a binary file which is using the big-endian format. Therefor we need to build the file manually.

build_clr()

Build the CLR file.

The “CLR” file is an “Apple Color List” file. To create it, we need the self-compiled / written json2clr binary.

build_css()

Build the CSS.

The CSS file can be used to implement the colours in a website.

build_json()

Build the JSON file.

JSON files can be dumped via Python built-ins.

build_rest()

Build the reStructuredText files.

The reST files describe all colours.

build_svg()

Build the SVG.

While an SVG is basically a vector image format, it still uses normal a normal ASCII / XML format. Thus, we can render them via Jinja2 template engine.

build_txt()

Build the text files.

Since these are simple text files, we can render them via Jinja2 template engine.

copy_static_files()

Copy the static files.

classmethod get_file_items(path)

Get items from a text file, separated by newline characters. All white spaces are stripped.

Parameters:

path (str) – The path to a file

Returns:

The items

Return type:

list

render_template(template)

Load a Jinja2 template, render it and dump the file to the build directory, relatively based on the template name.

Parameters:

template (str) – The filename of the template

Colour

The colour classes.

class confirm.ci.colour.Colour(index, brightness, red, green, blue)

A single colour.

Parameters:
  • index (int) – The colour index

  • brightness (int) – The colour brightness

  • red (int) – The red colour amount

  • green (int) – The green colour amount

  • blue (int) – The blue colour amount

asdict()

The dict version of the colour, including all required informations.

Returns:

The dict version

Return type:

dict

property css_name

The CSS variable name of the colour.

Returns:

The CSS class name

Return type:

str

property name

The name of the colour.

Returns:

The name

Return type:

str

property rgb_dec

The RGB decimal format of the colour.

Returns:

The decimal RGB colour

Return type:

str

property rgb_hex

The RGB hex format of the colour.

Returns:

The HEX RGB colour

Return type:

str

class confirm.ci.colour.ColourFamily(index, name)

A colour family which holds multiple colours.

Parameters:

name (str) – The colour family name

add_colour(colour)

Add a colour to the colour family.

Parameters:

colour (Colour) – The colour

Image

The image module.

class confirm.ci.image.Image(path, family_names)

The image class.

Parameters:

path (str) – The image path

detect_colours_per_family()

Detect the total colours per family.

Hint

This is achieved by cropping the first horizontal line of pixels and counting the amount of different colours found.

Returns:

The colours per family

Return type:

int

detect_tile_size_and_brightness_step()

Detect the tile size & brightness step.

Hint

Returns:

The tile size & brightness step

Return type:

tuple(int, int)

property height

The height of the image.

Returns:

The height

Return type:

int

parse()

Parse the image and fetch all colours / colour families from it.

property width

The width of the image.

Returns:

The width

Return type:

int

ASE

The ASE file class.

class confirm.ci.ase.ASE(path)

The class to create an ASE - Adobe Swatch Exchange file.

Parameters:

path (str) – The file path

add_colour(name, red, green, blue)

Add a colour.

Hint

A colour ASE block includes:

  • Header of create_named_block()

  • Colour space: 4 bytes

  • RGB values: 4 bytes per value

  • Colour type: 2 bytes

Parameters:
  • name (str) – The colour name

  • red (int) – The red value (0-255)

  • green (int) – The green value (0-255)

  • blue (int) – The blue value (0-255)

begin_group(name)

Begin a group.

Important

Remember to call end_group() when the group is finished.

Parameters:

name (str) – The group name

create_block(block_type, data=None)

Create an ASE bytes block.

Hint

An ASE block includes:

  • Block Type: 2 bytes

  • Block Length: 4 bytes

  • Block Data: variable length

Parameters:
  • block_type (int) – The block type

  • data (bytes) – Additional data

Returns:

The ASE block

Return type:

bytes

create_named_block(block_type, name, data=None)

Create a named ASE bytes block.

Hint

An named ASE block includes:

  • Header of create_block()

  • Name length: 2 bytes

  • Name: 2 bytes per character

  • Block Data: variable length

Parameters:
  • block_type (int) – The block type

  • name (str) – The name of the block

  • data (bytes) – Additional data

Returns:

The ASE block

Return type:

bytes

end_group()

End a group.

init_ase()

Init the ASE file.

write()

Write the ASE file.