Beispiel #1
0
def to_lower_case(string):
    expect_type(string, String)

    return String(string.value.lower(), quotes=string.quotes)


# ------------------------------------------------------------------------------
# Number functions

@ns.declare
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit='%')


ns.set_function('abs', 1, Number.wrap_python_function(abs))
ns.set_function('round', 1, Number.wrap_python_function(round))
ns.set_function('ceil', 1, Number.wrap_python_function(math.ceil))
ns.set_function('floor', 1, Number.wrap_python_function(math.floor))


# ------------------------------------------------------------------------------
# List functions

def __parse_separator(separator, default_from=None):
    if separator is None:
        separator = 'auto'
    separator = String.unquoted(separator).value

    if separator == 'comma':
        return True
Beispiel #2
0
def to_lower_case(string):
    expect_type(string, String)

    return String(string.value.lower(), quotes=string.quotes)


# ------------------------------------------------------------------------------
# Number functions

@ns.declare
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit='%')


ns.set_function('abs', 1, Number.wrap_python_function(abs))
ns.set_function('round', 1, Number.wrap_python_function(round))
ns.set_function('ceil', 1, Number.wrap_python_function(math.ceil))
ns.set_function('floor', 1, Number.wrap_python_function(math.floor))


# ------------------------------------------------------------------------------
# List functions

def __parse_separator(separator, default_from=None):
    if separator is None:
        separator = 'auto'
    separator = String.unquoted(separator).value

    if separator == 'comma':
        return True
Beispiel #3
0
@register('to-lower-case', 1)
def to_lower_case(string):
    expect_type(string, String)

    return String(string.value.lower(), quotes=string.quotes)


# ------------------------------------------------------------------------------
# Number functions

@register('percentage', 1)
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit='%')

CORE_LIBRARY.add(Number.wrap_python_function(abs), 'abs', 1)
CORE_LIBRARY.add(Number.wrap_python_function(round), 'round', 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.ceil), 'ceil', 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.floor), 'floor', 1)


# ------------------------------------------------------------------------------
# List functions

def __parse_separator(separator, default_from=None):
    if separator is None:
        separator = 'auto'
    separator = String.unquoted(separator).value

    if separator == 'comma':
        return True
Beispiel #4
0
    expect_type(string, String)

    return String(string.value.lower(), quotes=string.quotes)


# ------------------------------------------------------------------------------
# Number functions


@register('percentage', 1)
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit='%')


CORE_LIBRARY.add(Number.wrap_python_function(abs), 'abs', 1)
CORE_LIBRARY.add(Number.wrap_python_function(round), 'round', 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.ceil), 'ceil', 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.floor), 'floor', 1)

# ------------------------------------------------------------------------------
# List functions


def __parse_separator(separator, default_from=None):
    if separator is None:
        separator = 'auto'
    separator = String.unquoted(separator).value

    if separator == 'comma':
        return True
Beispiel #5
0
        raise ValueError("Expected unitless number, got %r" % (base,))

    if base is None:
        ret = math.log(number.value)
    else:
        ret = math.log(number.value, base.value)

    return Number(ret)


@register('pow', 2)
def pow(number, exponent):
    return number ** exponent


COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.sqrt), 'sqrt', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.sin), 'sin', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.cos), 'cos', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.tan), 'tan', 1)


# ------------------------------------------------------------------------------
# Fonts

def _fonts_root():
    return config.STATIC_ROOT if config.FONTS_ROOT is None else config.FONTS_ROOT


def _font_url(path, only_path=False, cache_buster=True, inline=False):
    filepath = String.unquoted(path).value
    file = None
Beispiel #6
0
        raise ValueError("Expected unitless number, got %r" % (base,))

    if base is None:
        ret = math.log(number.value)
    else:
        ret = math.log(number.value, base.value)

    return Number(ret)


@ns.declare
def pow(number, exponent):
    return number ** exponent


ns.set_function('sqrt', 1, Number.wrap_python_function(math.sqrt))
ns.set_function('sin', 1, Number.wrap_python_function(math.sin))
ns.set_function('cos', 1, Number.wrap_python_function(math.cos))
ns.set_function('tan', 1, Number.wrap_python_function(math.tan))


# ------------------------------------------------------------------------------
# Fonts

def _fonts_root():
    return config.STATIC_ROOT if config.FONTS_ROOT is None else config.FONTS_ROOT


def _font_url(path, only_path=False, cache_buster=True, inline=False):
    filepath = String.unquoted(path).value
    file = None
Beispiel #7
0
        raise ValueError("Expected unitless number, got %r" % (base, ))

    if base is None:
        ret = math.log(number.value)
    else:
        ret = math.log(number.value, base.value)

    return Number(ret)


@ns.declare
def pow(number, exponent):
    return number**exponent


ns.set_function('sqrt', 1, Number.wrap_python_function(math.sqrt))
ns.set_function('sin', 1, Number.wrap_python_function(math.sin))
ns.set_function('cos', 1, Number.wrap_python_function(math.cos))
ns.set_function('tan', 1, Number.wrap_python_function(math.tan))

# ------------------------------------------------------------------------------
# Fonts


def _fonts_root():
    return config.STATIC_ROOT if config.FONTS_ROOT is None else config.FONTS_ROOT


def _font_url(path, only_path=False, cache_buster=True, inline=False):
    filepath = String.unquoted(path).value
    file = None
Beispiel #8
0
        raise ValueError("Expected unitless number, got %r" % (base, ))

    if base is None:
        ret = math.log(number.value)
    else:
        ret = math.log(number.value, base.value)

    return Number(ret)


@register('pow', 2)
def pow(number, exponent):
    return number**exponent


COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.sqrt), 'sqrt', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.sin), 'sin', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.cos), 'cos', 1)
COMPASS_HELPERS_LIBRARY.add(Number.wrap_python_function(math.tan), 'tan', 1)

# ------------------------------------------------------------------------------
# Fonts


def _fonts_root():
    return config.STATIC_ROOT if config.FONTS_ROOT is None else config.FONTS_ROOT


def _font_url(path, only_path=False, cache_buster=True, inline=False):
    filepath = String.unquoted(path).value
    file = None
Beispiel #9
0
    expect_type(string, String)

    return String(string.value.lower(), quotes=string.quotes)


# ------------------------------------------------------------------------------
# Number functions


@ns.declare
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit="%")


ns.set_function("abs", 1, Number.wrap_python_function(abs))
ns.set_function("round", 1, Number.wrap_python_function(round))
ns.set_function("ceil", 1, Number.wrap_python_function(math.ceil))
ns.set_function("floor", 1, Number.wrap_python_function(math.floor))


# ------------------------------------------------------------------------------
# List functions


def __parse_separator(separator, default_from=None):
    if separator is None:
        separator = "auto"
    separator = String.unquoted(separator).value

    if separator == "comma":
Beispiel #10
0
        return String(arg.value, quotes='"')
    else:
        return String(arg.render(), quotes='"')


# ------------------------------------------------------------------------------
# Number functions


@register("percentage", 1)
def percentage(value):
    expect_type(value, Number, unit=None)
    return value * Number(100, unit="%")


CORE_LIBRARY.add(Number.wrap_python_function(abs), "abs", 1)
CORE_LIBRARY.add(Number.wrap_python_function(round), "round", 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.ceil), "ceil", 1)
CORE_LIBRARY.add(Number.wrap_python_function(math.floor), "floor", 1)


# ------------------------------------------------------------------------------
# List functions


def __parse_separator(separator, default_from=None):
    if separator is None:
        return None
    separator = String.unquoted(separator).value
    if separator == "comma":
        return True