Menu

[r5]: / IncludeRule.py  Maximize  Restore  History

Download this file

66 lines (41 with data), 1.8 kB

 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
from Translator import *
import Object, StyleSheet, ValueList, PrimitiveValue, pdb
class SSSIncludeRule(Object.SSSObject):
def __init__(self, rule = None):
super(SSSIncludeRule, self).__init__()
self._values = None
self._parse_only = False
if rule: self._parse(rule);
def _parse(self, rule):
matches = preg_match('@include\s*([^\;]*)\;?$', rule.strip())
if matches:
self._values = ValueList.SSSValueList(matches[0], self)
for i in xrange(self._values.length):
#pdb.set_trace()
item = self._values.item(i)
if item.valueType == PrimitiveValue.SSSPrimitiveValue.CSS_URI:
self.href = item.value
if item.valueType == PrimitiveValue.SSSPrimitiveValue.CSS_STRING and item.value == 'parse-only':
self._parse_only = True
def getPropertyCSSValue(self,val):
return self._styleSheet.getPropertyCSSValue(val)
def get_href(self):
self._styleSheet.href
def set_href(self, value):
self._styleSheet = StyleSheet.SSSStyleSheet()
self._styleSheet._setParentObject(self)
self._styleSheet.href = value
href = property(get_href, set_href)
def set_cssText(self, rule):
return self._parse(rule)
def get_cssText(self):
return self.__str__()
cssText = property(get_cssText, set_cssText)
def get_type(self):
return Object.SSSObject.INCLUDE_RULE
type = property(get_type)
def __str__(self):
string = self.createCommentText('@include ' + self._styleSheet.href) + '\n'
if not self._parse_only:
string += self._styleSheet.cssText
return string
MongoDB Logo MongoDB