--- a/utils/pylit/pylit.py +++ b/utils/pylit/pylit.py @@ -476,10 +476,10 @@ marker = self.code_block_marker if marker == '::': # the default marker may occur at the end of a text line - self.marker_regexp = re.compile('^( *(?!\.\.).*)(::)([ \n]*)$') + self.marker_regexp = re.compile(r'^( *(?!\.\.).*)(::)([ \n]*)$') else: # marker must be on a separate line - self.marker_regexp = re.compile('^( *)(%s)(.*\n?)$' % marker) + self.marker_regexp = re.compile(r'^( *)(%s)(.*\n?)$' % marker) # .. _TextCodeConverter.__iter__: # @@ -1589,7 +1589,7 @@ # :: firstlines = ' '.join(docstring.splitlines()[:2]) - match = re.search('coding[=:]\s*([-\w.]+)', firstlines) + match = re.search(r'coding[=:]\s*([-\w.]+)', firstlines) if match: docencoding = match.group(1) docstring = docstring.decode(docencoding) --- a/bench/plot.py +++ b/bench/plot.py @@ -57,7 +57,7 @@ lines = open(benchlog, 'r').readlines() benchmarks = {} -pattern = "\((.*)\)\s+(.*)\s+(.*)\s+\"(.*)\"" +pattern = r"\((.*)\)\s+(.*)\s+(.*)\s+\"(.*)\"" # Extract data from logfile print("Parsing %s..." % benchlog) --- a/cmake/scripts/copy-test-demo-data.py +++ b/cmake/scripts/copy-test-demo-data.py @@ -31,7 +31,7 @@ "xml", "xml.gz", "off", "inp", "msh", "supp", "rst", "py.rst", "ele", "node", "grid", "edge", "sh"] -suffix_pattern = re.compile("(%s)," % ("|".join("[\w-]+\.%s" % pattern +suffix_pattern = re.compile("(%s)," % ("|".join(r"[\w-]+\.%s" % pattern for pattern in suffix_patterns))) script_rel_path = os.sep.join(__file__.split(os.sep)[:-1]) --- a/python/dolfin_utils/meshconvert/meshconvert.py +++ b/python/dolfin_utils/meshconvert/meshconvert.py @@ -506,7 +506,7 @@ if state == 10: print("Conversion done") else: - _error("Missing data, unable to convert \n\ Did you use version 2.0 of the gmsh file format?") + _error("Missing data, unable to convert. Did you use version 2.0 of the gmsh file format?") # Close files ifile.close() @@ -862,7 +862,7 @@ for i in range(num_vertices): line = ifile.readline() m = re.match(r"^.*\(\s*(.*)\s*\).*\](.*)$", line) - x = list(map(float, re.split("[\s,]+", m.group(1)))) + x = list(map(float, re.split(r"[\s,]+", m.group(1)))) xml_writer.write_vertex(ofile, i, *x) markers = list(map(int, m.group(2).split())) vertex_markers.append(markers) @@ -1184,11 +1184,11 @@ if not line: _error("Empty file") if re.search(r"num_dim.*=", line): - dim = int(re.match(".*\s=\s(\d+)\s;",line).group(1)) + dim = int(re.match(r".*\s=\s(\d+)\s;",line).group(1)) if re.search(r"num_nodes.*=", line): - num_vertices = int(re.match(".*\s=\s(\d+)\s;",line).group(1)) + num_vertices = int(re.match(r".*\s=\s(\d+)\s;",line).group(1)) if re.search(r"num_elem.*=", line): - num_cells = int(re.match(".*\s=\s(\d+)\s;",line).group(1)) + num_cells = int(re.match(r".*\s=\s(\d+)\s;",line).group(1)) if re.search(r"connect1 =",line): break @@ -1215,7 +1215,7 @@ line = ifile.readline() if not line: break - connect=re.split("[,;]",line) + connect=re.split(r"[,;]",line) if num_dims == 2: n0 = int(connect[0])-1 n1 = int(connect[1])-1