本文整理汇总了Python中scss.Scss._at_options方法的典型用法代码示例。如果您正苦于以下问题:Python Scss._at_options方法的具体用法?Python Scss._at_options怎么用?Python Scss._at_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scss.Scss
的用法示例。
在下文中一共展示了Scss._at_options方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SassRepl
# 需要导入模块: from scss import Scss [as 别名]
# 或者: from scss.Scss import _at_options [as 别名]
class SassRepl(object):
def __init__(self, is_sass=False):
self.css = Scss()
self.namespace = self.css.root_namespace
self.options = self.css.scss_opts
self.source_file = SourceFile.from_string('', '<shell>', line_numbers=False, is_sass=is_sass)
self.calculator = Calculator(self.namespace)
def __call__(self, s):
from pprint import pformat
if s in ('exit', 'quit'):
raise KeyboardInterrupt
for s in s.split(';'):
s = self.source_file.prepare_source(s.strip())
if not s:
continue
elif s.startswith('@'):
scope = None
properties = []
children = deque()
rule = SassRule(self.source_file, namespace=self.namespace, options=self.options, properties=properties)
block = UnparsedBlock(rule, 1, s, None)
code, name = (s.split(None, 1) + [''])[:2]
if code == '@option':
self.css._at_options(self.calculator, rule, scope, block)
continue
elif code == '@import':
self.css._at_import(self.calculator, rule, scope, block)
continue
elif code == '@include':
final_cont = ''
self.css._at_include(self.calculator, rule, scope, block)
code = self.css._print_properties(properties).rstrip('\n')
if code:
final_cont += code
if children:
self.css.children.extendleft(children)
self.css.parse_children()
code = self.css._create_css(self.css.rules).rstrip('\n')
if code:
final_cont += code
yield final_cont
continue
elif s == 'ls' or s.startswith('show(') or s.startswith('show ') or s.startswith('ls(') or s.startswith('ls '):
m = re.match(r'(?:show|ls)(\()?\s*([^,/\\) ]*)(?:[,/\\ ]([^,/\\ )]+))*(?(1)\))', s, re.IGNORECASE)
if m:
name = m.group(2)
code = m.group(3)
name = name and name.strip().rstrip('s') # remove last 's' as in functions
code = code and code.strip()
ns = self.namespace
if not name:
yield pformat(sorted(['vars', 'options', 'mixins', 'functions']))
elif name in ('v', 'var', 'variable'):
variables = dict(ns._variables)
if code == '*':
pass
elif code:
variables = dict((k, v) for k, v in variables.items() if code in k)
else:
variables = dict((k, v) for k, v in variables.items() if not k.startswith('$--'))
yield pformat(variables)
elif name in ('o', 'opt', 'option'):
opts = self.options
if code == '*':
pass
elif code:
opts = dict((k, v) for k, v in opts.items() if code in k)
else:
opts = dict((k, v) for k, v in opts.items() if not k.startswith('@'))
yield pformat(opts)
elif name in ('m', 'mix', 'mixin', 'f', 'func', 'funct', 'function'):
if name.startswith('m'):
funcs = dict(ns._mixins)
elif name.startswith('f'):
funcs = dict(ns._functions)
if code == '*':
pass
elif code:
funcs = dict((k, v) for k, v in funcs.items() if code in k[0])
else:
pass
# TODO print source when possible
yield pformat(funcs)
continue
elif s.startswith('$') and (':' in s or '=' in s):
prop, value = [a.strip() for a in _prop_split_re.split(s, 1)]
prop = self.calculator.do_glob_math(prop)
value = self.calculator.calculate(value)
self.namespace.set_variable(prop, value)
continue
# TODO respect compress?
try:
yield(self.calculator.calculate(s).render())
except (SyntaxError, SassEvaluationError) as e:
#.........这里部分代码省略.........