本文整理汇总了Python中scss.Scss.calculate方法的典型用法代码示例。如果您正苦于以下问题:Python Scss.calculate方法的具体用法?Python Scss.calculate怎么用?Python Scss.calculate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scss.Scss
的用法示例。
在下文中一共展示了Scss.calculate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scss import Scss [as 别名]
# 或者: from scss.Scss import calculate [as 别名]
#.........这里部分代码省略.........
pprint(d)
elif code:
d = dict((k, v) for k, v in options.items() if code in k)
pprint(d)
else:
d = dict((k, v) for k, v in options.items() if not k.startswith('@'))
pprint(d)
elif name in ('m', 'mix', 'mixin', 'f', 'func', 'funct', 'function'):
if name.startswith('m'):
name = 'mixin'
elif name.startswith('f'):
name = 'function'
if code == '*':
d = dict((k[len(name) + 2:], v) for k, v in options.items() if k.startswith('@' + name + ' '))
pprint(sorted(d))
elif code:
d = dict((k, v) for k, v in options.items() if k.startswith('@' + name + ' ') and code in k)
seen = set()
for k, mixin in d.items():
mixin = getattr(mixin, 'mixin', mixin)
fn_name, _, _ = k.partition(':')
if fn_name not in seen:
seen.add(fn_name)
print fn_name + '(' + ', '.join(p + (': ' + mixin[1].get(p) if p in mixin[1] else '') for p in mixin[0]) + ') {'
print ' ' + '\n '.join(l for l in mixin[2].split('\n'))
print '}'
else:
d = dict((k[len(name) + 2:].split(':')[0], v) for k, v in options.items() if k.startswith('@' + name + ' '))
pprint(sorted(d))
continue
elif s.startswith('$') and (':' in s or '=' in s):
prop, value = [a.strip() for a in _prop_split_re.split(s, 1)]
prop = css.do_glob_math(prop, context, options, rule, True)
value = css.calculate(value, context, options, rule)
context[prop] = value
continue
s = to_str(css.calculate(s, context, options, rule))
s = css.post_process(s)
print s
print "Bye!"
elif options.watch:
import time
try:
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler
except ImportError:
sys.stderr.write("Using watch functionality requires the `watchdog` library: http://pypi.python.org/pypi/watchdog/")
sys.exit(1)
if options.output and not os.path.isdir(options.output):
sys.stderr.write("watch file output directory is invalid: '%s'" % (options.output))
sys.exit(2)
class ScssEventHandler(PatternMatchingEventHandler):
def __init__(self, *args, **kwargs):
super(ScssEventHandler, self).__init__(*args, **kwargs)
self.css = Scss(scss_opts={
'compress': options.compress,
'debug_info': options.debug_info,
})
self.output = options.output
self.suffix = options.suffix
def is_valid(self, path):
return os.path.isfile(path) and path.endswith(".scss") and not os.path.basename(path).startswith("_")
def process(self, path):