Menu

[r1]: / CommentRule.py  Maximize  Restore  History

Download this file

61 lines (29 with data), 1.3 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
from Translator import *
import Object
import ValueList
class SSSCommentRule(Object.SSSObject):
_comment = ''
def __init__(self, sourceText = ''):
super(SSSCommentRule, self).__init__()
addLogMessage(get_class(self) + ' creating SSSCommentRule.')
addLogMessage("SSSCommentRule __init__: sourceText = " + sourceText)
if (sourceText != ''):
self._parse(sourceText)
def _parse(self, sourceText):
addLogMessage("SSSCommentRule _parse: Parsing sourceText = " + sourceText)
matches = preg_match('@comment\s+([\"|\'][.|\w|\W]*[\"|\'])\s{0,};?$', trim(sourceText))
if (matches):
self._comment = trim(matches[0])
def __set(self, var, value):
if (var == 'cssText'):
self._parse(value)
def get_cssText(self):
return self.__str__()
cssText = property(get_cssText)
def get(self, var):
if (var == 'type'): return SSSObject.COMMENT_RULE
if (var == 'cssText'): return self.__str__()
if (var == 'comment'): return self._comment
return super(SSSCommentRule, self).get(var)
def __str__(self):
return self.createCommentText(self._comment) + "\n\n"