Menu

[r1]: / ConstantRule.py  Maximize  Restore  History

Download this file

66 lines (35 with data), 1.7 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, ValueList
class SSSConstantRule(Object.SSSObject):
def __init__(self, rule = ''):
self._name = '' #I moved these to make them instance variables,
self._valueList = None #rather than class variables
super(SSSConstantRule, self).__init__()
if (rule):
self._parse(rule)
def _parse(self, sourceText):
sourceText = sourceText.strip()
#matches = preg_match(r'@constant', sourceText)
if '@constant' in sourceText:
#this pretty little mess of code is custom hacked
#because the previous re wasn't working...
self._name = sourceText[sourceText.find('@constant '):sourceText.find(':')].replace('@constant', '').strip()
self._valueList = ValueList.SSSValueList(sourceText[sourceText.find(':')+1:sourceText.find(';')].strip(), self)
self._declareConstant()
def _declareConstant(self):
if (self.parentStyleSheet):
self.parentStyleSheet.declareConstant(self._name, self.value)
def get_value(self):
return self._valueList.cssText
value = property(get_value)
def get_cssText(self):
return self.__str__()
cssText = property(get_cssText, _parse)
def get_type(self):
return Object.SSSObject.CONSTANT_RULE
type = property(get_type)
def __str__(self):
string = "constant " + self._name + ": " + self._valueList.cssText
if (self.parentStyleSheet):
return self.parentStyleSheet.createCommentText(string) + "\n\n"
return string
MongoDB Logo MongoDB