justunits

Module Attributes

BaseUnit

The immutable, minimum unit definition consisting of the unit’s symbol, its name and the quantity this units stands for.

PREFIX_FOR_ONE

This is the (non existing prefix) placeholder for 1.

DEFAULT_ATTRIBUTE_UNIT_SEPARATOR

The style separating attributes/values from units.

DEFAULT_ALLOWED_SEPARATORS

By default only 5 of 7 supported attribute unit separator are taken into account as the absolute certain separation of an single underline or whitespace separated unit is ambiguous, without limiting the results to the content of the unit library.

DEFAULT_POWER_STYLE

The default style how powers are represented.

DEFAULT_DIVIDING_STYLE

The default style how unit fractions are represented.

DEFAULT_SEPARATION_STYLE

The default style by which character units are separated.

DEFAULT_UNIT_STYLE

The default unit style composed of power-, dividing- and separation-style.

Functions

create_unit(symbol, name, quantity[, prefix])

Creates a basic unit of your liking.

from_string(unit_text)

param unit_text

join_unit(attribute, unit[, target_format])

Joins attribute and unit using one of six separators.

prefix_base_unit(base_unit, supported_prefixes)

param base_unit

reformat_unit(text[, target_format, converter])

Reformats a attribute/value-unit pair to a targeted format.

register_unit(unit)

reset_unit_library()

Resets the unit library to the default definition.

set_default_attribute_unit_separator(separator)

Sets the default separator in between attribute/value and unit.

set_default_unit_style(unit_style)

Sets the default unit style.

split_attribute_unit(text[, allowed_separators])

param text

split_number_and_unit(text)

Explicitly splits a numeric text followed by an unit.

split_unit(text[, allowed_separators, converter])

Splits an attribute/value with a trailing unit.

split_unit_text(text[, allowed_separators])

Splits an attribute/value with a trailing unit text.

to_string(unit[, unit_style])

Creates a string represenation of units.

Classes

AUnit(raw_unit, prefix, power, float] = 1)

A unit represents just a single unit like meter ‘m’ and second ‘s’.

AnyUnit(*sub_units)

param *sub_units

AttributeUnitSeparators(value)

An enumeration.

BareUnit(symbol, name, quantity)

param symbol

BaseSiUnits()

BaseUnit

The immutable, minimum unit definition consisting of the unit’s symbol, its name and the quantity this units stands for.

DerivedUnit(*sub_units)

param *sub_units

Prefix(symbol, name, decimal)

Create new instance of Prefix(symbol, name, decimal)

SiPrefixes()

SiUnits()

UnitDividingStyle(value)

An enumeration.

UnitPowerStyle(value)

An enumeration.

UnitSeparationStyle(value)

An enumeration.

UnitStyle(value)

An enumeration.

UnknownUnit(unit_text, switch_power, …)

The unknown unit appears for cases in which text could not be resolved to units known by the current runtime library.