Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] SyntaxWarning: invalid escape sequence #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions sparkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def render(self):
output = self.root.render()

# Indent by whatever the input is indented with
indent = re.findall("^[\r\n]*(\s*)", self.str)[0]
indent = re.findall(r"^[\r\n]*(\s*)", self.str)[0]
output = indent + output.replace("\n", "\n" + indent)

# Strip newline if not needed
Expand Down Expand Up @@ -446,7 +446,7 @@ def _tokenize(self):
str = str[:-len(match[0])]

# Split by the element separators
for token in re.split('(<|>|\+(?!\\s*\+|$))', str):
for token in re.split(r'(<|>|\+(?!\\s*\+|$))', str):
if token.strip() != '':
self.tokens.append(Token(token, parser=self))

Expand Down Expand Up @@ -904,7 +904,7 @@ def _init_element(self):
"""

# Get the tag name. Default to DIV if none given.
name = re.findall('^([\w\-:]*)', self.str)[0]
name = re.findall(r'^([\w\-:]*)', self.str)[0]
if self.parser.options.options['namespaced-elements'] == True:
name = name.replace('-', ':')

Expand All @@ -928,7 +928,7 @@ def _init_element(self):

# Look for attributes
attribs = []
for attrib in re.findall('\[([^\]]*)\]', self.str):
for attrib in re.findall(r'\[([^\]]*)\]', self.str):
attribs.append(attrib)
self.str = self.str.replace("[" + attrib + "]", "")
if len(attribs) > 0:
Expand All @@ -939,14 +939,14 @@ def _init_element(self):

# Try looking for text
text = None
for text in re.findall('\{(.*?)\}(?!\})', self.str):
for text in re.findall(r'\{(.*?)\}(?!\})', self.str):
self.str = self.str.replace("{" + text + "}", "")
if text is not None:
self.text = text

# Get the class names
classes = []
for classname in re.findall('\.([\$a-zA-Z0-9_\-\&]+)', self.str):
for classname in re.findall(r'\.([\$a-zA-Z0-9_\-\&]+)', self.str):
classes.append(classname)
if len(classes) > 0:
try: self.attributes['class']
Expand All @@ -956,19 +956,19 @@ def _init_element(self):

# Get the ID
id = None
for id in re.findall('#([\$a-zA-Z0-9_\-\&]+)', self.str): pass
for id in re.findall(r'#([\$a-zA-Z0-9_\-\&]+)', self.str): pass
if id is not None:
self.attributes['id'] = id

# See if there's a multiplier (e.g., "li*3")
multiplier = None
for multiplier in re.findall('\*\s*([0-9]+)', self.str): pass
for multiplier in re.findall(r'\*\s*([0-9]+)', self.str): pass
if multiplier is not None:
self.multiplier = int(multiplier)

# Populate flag (e.g., ul+)
flags = None
for flags in re.findall('[\+\!]+$', self.str): pass
for flags in re.findall(r'[\+\!]+$', self.str): pass
if flags is not None:
if '+' in flags: self.populate = True
if '!' in flags: self.expand = True
Expand Down