2012-02-12 11:50:57 +00:00
|
|
|
"""
|
|
|
|
"""
|
|
|
|
class Scope(list):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
|
|
|
|
def push(self):
|
|
|
|
self.append({
|
|
|
|
'__variables__' : {},
|
|
|
|
'__blocks__': [],
|
|
|
|
'__mixins__': {},
|
|
|
|
'__current__': None
|
|
|
|
})
|
|
|
|
|
2012-02-12 12:00:56 +00:00
|
|
|
@property
|
2012-02-12 11:50:57 +00:00
|
|
|
def current(self):
|
|
|
|
return self[-1]['__current__']
|
|
|
|
|
2012-02-12 12:00:56 +00:00
|
|
|
@current.setter
|
|
|
|
def current(self, value):
|
|
|
|
self[-1]['__current__'] = value
|
|
|
|
|
2012-02-12 11:50:57 +00:00
|
|
|
def mixin(self, mixin):
|
|
|
|
"""
|
|
|
|
"""
|
2012-02-12 12:00:56 +00:00
|
|
|
return self[0]['__mixins__'][mixin] if mixin in self[0]['__mixins__'] else False
|
|
|
|
|
|
|
|
def in_mixin(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return any([s for s in self
|
|
|
|
if s['__current__'] == '__mixin__'])
|