43 lines
964 B
Python
Raw Permalink Normal View History

2012-04-03 13:36:08 +00:00
# -*- coding: utf8 -*-
2012-01-28 14:52:09 +00:00
"""
2012-04-03 13:36:08 +00:00
.. module:: lesscpy.plib.statement
:synopsis: Statement node.
2013-07-19 11:21:51 +02:00
2012-04-03 13:36:08 +00:00
Copyright (c)
See LICENSE for details.
2012-07-18 17:28:04 -04:00
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
2012-01-28 14:52:09 +00:00
"""
2012-02-19 20:38:19 +00:00
from .node import Node
2012-02-26 13:20:35 +00:00
from lesscpy.lessc import utility
2013-07-19 11:21:51 +02:00
2012-02-19 20:38:19 +00:00
class Statement(Node):
2013-07-19 11:21:51 +02:00
2012-04-03 13:36:08 +00:00
"""Represents CSS statement (@import, @charset...)
"""
2013-07-19 11:21:51 +02:00
2012-02-26 13:20:35 +00:00
def parse(self, scope):
2012-04-03 13:36:08 +00:00
"""Parse node
args:
scope (Scope): current scope
raises:
SyntaxError
returns:
self
2012-02-26 13:20:35 +00:00
"""
self.parsed = list(utility.flatten(self.tokens))
if self.parsed[0] == '@import':
if len(self.parsed) > 4:
# Media @import
self.parsed.insert(3, ' ')
2012-04-03 13:36:08 +00:00
return self
2013-07-19 11:21:51 +02:00
2012-03-03 09:58:47 +00:00
def fmt(self, fills):
2012-04-03 13:36:08 +00:00
""" Format node
args:
fills (dict): replacements
returns:
str
2012-02-26 13:20:35 +00:00
"""
2012-04-03 13:36:08 +00:00
return ''.join(self.parsed) + fills['eb']