/usr/lib/python3/dist-packages/lesscpy/plib/node.py is in python3-lesscpy 0.13.0+ds-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # -*- coding: utf8 -*-
"""
.. module:: lesscpy.plib.node
:synopsis: Base Node
Copyright (c)
See LICENSE for details.
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
"""
from lesscpy.lessc import utility
class Node(object):
def __init__(self, tokens, lineno=0):
""" Base Node
args:
tokens (list): tokenlist
lineno (int): Line number of node
"""
self.tokens = tokens
self.lineno = lineno
self.parsed = False
def parse(self, scope):
""" Base parse function
args:
scope (Scope): Current scope
returns:
self
"""
return self
def process(self, tokens, scope):
""" Process tokenslist, flattening and parsing it
args:
tokens (list): tokenlist
scope (Scope): Current scope
returns:
list
"""
while True:
tokens = list(utility.flatten(tokens))
done = True
if any(t for t in tokens if hasattr(t, 'parse')):
tokens = [t.parse(scope)
if hasattr(t, 'parse')
else t
for t in tokens]
done = False
if any(t for t in tokens if (utility.is_variable(t)) or str(type(t)) == "<class 'lesscpy.plib.variable.Variable'>"):
tokens = self.replace_variables(tokens, scope)
done = False
if done:
break
return tokens
def replace_variables(self, tokens, scope):
""" Replace variables in tokenlist
args:
tokens (list): tokenlist
scope (Scope): Current scope
returns:
list
"""
list = []
for t in tokens:
if utility.is_variable(t):
list.append(scope.swap(t))
elif str(type(t)) == "<class 'lesscpy.plib.variable.Variable'>":
list.append(scope.swap(t.name))
else:
list.append(t)
return list
def fmt(self, fills):
""" Format node
args:
fills (dict): replacements
returns:
str
"""
raise ValueError('No defined format')
|