Exemplo n.º 1
0
    return _position(False, p)


@register('opposite-position')
def opposite_position(p):
    return _position(True, p)


# ------------------------------------------------------------------------------
# Math

@register('pi', 0)
def pi():
    return NumberValue(math.pi)

COMPASS_HELPERS_LIBRARY.add(Value._wrap(math.sin), 'sin', 1)
COMPASS_HELPERS_LIBRARY.add(Value._wrap(math.cos), 'cos', 1)
COMPASS_HELPERS_LIBRARY.add(Value._wrap(math.tan), 'tan', 1)


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

def _font_url(path, only_path=False, cache_buster=True, inline=False):
    filepath = StringValue(path).value
    path = None
    if callable(config.STATIC_ROOT):
        try:
            _file, _storage = list(config.STATIC_ROOT(filepath))[0]
            d_obj = _storage.modified_time(_file)
            filetime = int(time.mktime(d_obj.timetuple()))
Exemplo n.º 2
0
Arquivo: core.py Projeto: eevee/pyScss
@register('quote')
def quote(*args):
    return QuotedStringValue(' '.join([StringValue(s).value for s in args]))


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

@register('percentage', 1)
def percentage(value):
    value = NumberValue(value)
    value.units = {'%': _units_weights.get('%', 1), '_': '%'}
    return value

CORE_LIBRARY.add(Value._wrap(abs), 'abs', 1)
CORE_LIBRARY.add(Value._wrap(round), 'round', 1)
CORE_LIBRARY.add(Value._wrap(math.ceil), 'ceil', 1)
CORE_LIBRARY.add(Value._wrap(math.floor), 'floor', 1)


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

# TODO get the compass bit outta here
@register('-compass-list-size')
@register('length')
def _length(*lst):
    if len(lst) == 1 and isinstance(lst[0], (list, tuple, ListValue)):
        lst = ListValue(lst[0]).values()
    lst = ListValue(lst)