From 8a8e08aa580ea667b2eb4cc3c144de763c28c76f Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Wed, 18 Nov 2015 18:56:37 +0300 Subject: [PATCH] Fixed processing of declaration without conditions --- src/mapcss/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mapcss/__init__.py b/src/mapcss/__init__.py index 0d3650e..41149f6 100644 --- a/src/mapcss/__init__.py +++ b/src/mapcss/__init__.py @@ -64,6 +64,7 @@ SET_TAG = re.compile(r'^ \s* set \s+(\S+)\s* = \s* (.+?) \s* SET_TAG_TRUE = re.compile(r'^ \s* set \s+(\S+)\s* $', re.I | re.S | re.X) EXIT = re.compile(r'^ \s* exit \s* $', re.I | re.S | re.X) +oNONE = 0 oZOOM = 2 oGROUP = 3 oCONDITION = 4 @@ -200,7 +201,7 @@ class MapCSS(): self.choosers = [] log = logging.getLogger('mapcss.parser') - previous = 0 # what was the previous CSS word? + previous = oNONE # what was the previous CSS word? sc = StyleChooser(self.scalepair) # currently being assembled stck = [] # filename, original, remained @@ -282,6 +283,8 @@ class MapCSS(): # Declaration - {...} elif DECLARATION.match(css): + if previous == oDECLARATION or previous == oNONE: + raise Exception("Declaration without conditions") decl = DECLARATION.match(css).groups()[0] log.debug("declaration found: %s" % (decl)) sc.addStyles(self.subst_variables(parseDeclaration(decl)))