41 lines
929 B
Python
Raw Normal View History

2012-03-30 19:32:11 +00:00
# -*- coding: utf8 -*-
2012-01-28 14:52:09 +00:00
"""
2012-03-30 19:32:11 +00:00
.. module:: lesscpy.plib.variable
:synopsis: Variable declaration
2013-07-19 11:21:51 +02:00
2012-03-30 19:32:11 +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-03-30 19:32:11 +00:00
2013-07-19 11:21:51 +02:00
2012-02-19 20:38:19 +00:00
class Variable(Node):
2013-07-19 11:21:51 +02:00
2012-02-25 17:08:08 +00:00
def parse(self, scope):
2012-03-30 19:32:11 +00:00
""" Parse function
args:
scope (Scope): Scope object
returns:
self
2012-02-25 17:08:08 +00:00
"""
2012-04-08 13:17:22 +00:00
self.name, _, self.value = self.tokens
2013-07-19 11:21:51 +02:00
if isinstance(self.name, tuple):
2012-03-23 17:02:39 +00:00
if len(self.name) > 1:
self.name, pad = self.name
self.value.append(pad)
else:
self.name = self.name[0]
2012-04-08 13:17:22 +00:00
scope.add_variable(self)
return self
2013-07-19 11:21:51 +02:00
def copy(self):
2012-05-05 17:20:03 +00:00
""" Return a copy of self
Returns:
Variable object
"""
return Variable([t for t in self.tokens])
2013-07-19 11:21:51 +02:00
2012-04-08 13:17:22 +00:00
def fmt(self, fills):
return ''