本文整理汇总了Python中scss.types.Number.wrap_python_function方法的典型用法代码示例。如果您正苦于以下问题:Python Number.wrap_python_function方法的具体用法?Python Number.wrap_python_function怎么用?Python Number.wrap_python_function使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scss.types.Number
的用法示例。
在下文中一共展示了Number.wrap_python_function方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_lower_case
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
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
示例2: to_lower_case
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
@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
示例3: ValueError
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
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
示例4: ValueError
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
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
示例5: expect_type
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
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":
示例6: String
# 需要导入模块: from scss.types import Number [as 别名]
# 或者: from scss.types.Number import wrap_python_function [as 别名]
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