/usr/lib/python3/dist-packages/lesscpy/plib/property.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 84 85 86 87 88 89 90 91 92 93 94 | # -*- coding: utf8 -*-
"""
.. module:: lesscpy.plib.property
:synopsis: Property node.
Copyright (c)
See LICENSE for details.
.. moduleauthor:: Johann T. Mariusson <jtm@robot.is>
"""
import re
from .node import Node
class Property(Node):
"""Represents CSS property declaration.
"""
def parse(self, scope):
"""Parse node
args:
scope (Scope): current scope
raises:
SyntaxError
returns:
self
"""
if not self.parsed:
if len(self.tokens) > 2:
property, style, _ = self.tokens
self.important = True
else:
property, style = self.tokens
self.important = False
self.property = ''.join(property)
self.parsed = []
if style:
style = self.preprocess(style)
self.parsed = self.process(style, scope)
return self
def preprocess(self, style):
"""Hackish preprocessing from font shorthand tags.
Skips expression parse on certain tags.
args:
style (list): .
returns:
list
"""
if self.property == 'font':
style = [''.join(u.expression())
if hasattr(u, 'expression')
else u
for u in style]
else:
style = [(u, ' ')
if hasattr(u, 'expression')
else u
for u in style]
return style
def fmt(self, fills):
""" Format node
args:
fills (dict): replacements
returns:
str
"""
f = "%(tab)s%(property)s:%(ws)s%(style)s%(important)s;%(nl)s"
imp = ' !important' if self.important else ''
if fills['nl']:
self.parsed = [',%s' % fills['ws']
if p == ','
else p
for p in self.parsed]
style = ''.join([p.fmt(fills)
if hasattr(p, 'fmt')
else str(p)
for p in self.parsed])
# IE cannot handle no space after url()
style = re.sub("(url\([^\)]*\))([^\s,])", "\\1 \\2", style)
fills.update({
'property': self.property,
'style': style.strip(),
'important': imp
})
return f % fills
def copy(self):
""" Return a full copy of self
Returns:
Property object
"""
return Property([t for t in self.tokens], 0)
|