Use raw strings for all regexps.

No exceptions please.
This commit is contained in:
Matthias Urlichs committed 2019-01-28 14:14:23 +01:00
1 parent bba95e9000
commit f3fdac7e5a
11 files changed
+88 -87

No files matched your search

+1 -1
View File
@@ -450,7 +450,7 @@ class LocalFileStorage(StorageInterface):
This storage type implements :func:`path_on_disk`.
"""
_UNICODE_VARIATIONS = re.compile(u"[\uFE00-\uFE0F]")
_UNICODE_VARIATIONS = re.compile(u"[\uFE00-\uFE0F]", re.U)
@classmethod
def _no_unicode_variations(cls, text):
+5 -5
View File
@@ -354,12 +354,12 @@ G90 ;absolute positioning
class Profile(object):
regex_extruder_offset = re.compile("extruder_offset_([xy])(\d)")
regex_filament_diameter = re.compile("filament_diameter(\d?)")
regex_print_temperature = re.compile("print_temperature(\d?)")
regex_strip_comments = re.compile(";.*$", flags=re.MULTILINE)
regex_extruder_offset = re.compile(r"extruder_offset_([xy])(\d)")
regex_filament_diameter = re.compile(r"filament_diameter(\d?)")
regex_print_temperature = re.compile(r"print_temperature(\d?)")
regex_strip_comments = re.compile(r";.*$", flags=re.MULTILINE)
regex_broken_replacements = re.compile("\?([a-zA-Z0-9_]*)\?")
regex_broken_replacements = re.compile(r"\?([a-zA-Z0-9_]*)\?")
@classmethod
def from_cura_ini(cls, path):
@@ -23,16 +23,16 @@ from octoprint.plugin import plugin_manager
from octoprint.util import RepeatedTimer
class VirtualPrinter(object):
command_regex = re.compile("^([GMTF])(\d+)")
sleep_regex = re.compile("sleep (\d+)")
sleep_after_regex = re.compile("sleep_after ([GMTF]\d+) (\d+)")
sleep_after_next_regex = re.compile("sleep_after_next ([GMTF]\d+) (\d+)")
custom_action_regex = re.compile("action_custom ([a-zA-Z0-9_]+)(\s+.*)?")
prepare_ok_regex = re.compile("prepare_ok (.*)")
send_regex = re.compile("send (.*)")
set_ambient_regex = re.compile("set_ambient ([-+]?[0-9]*\.?[0-9]+)")
start_sd_regex = re.compile("start_sd (.*)")
select_sd_regex = re.compile("select_sd (.*)")
command_regex = re.compile(r"^([GMTF])(\d+)")
sleep_regex = re.compile(r"sleep (\d+)")
sleep_after_regex = re.compile(r"sleep_after ([GMTF]\d+) (\d+)")
sleep_after_next_regex = re.compile(r"sleep_after_next ([GMTF]\d+) (\d+)")
custom_action_regex = re.compile(r"action_custom ([a-zA-Z0-9_]+)(\s+.*)?")
prepare_ok_regex = re.compile(r"prepare_ok (.*)")
send_regex = re.compile(r"send (.*)")
set_ambient_regex = re.compile(r"set_ambient ([-+]?[0-9]*\.?[0-9]+)")
start_sd_regex = re.compile(r"start_sd (.*)")
select_sd_regex = re.compile(r"select_sd (.*)")
def __init__(self, seriallog_handler=None, read_timeout=5.0, write_timeout=10.0):
import logging
@@ -317,7 +317,7 @@ class VirtualPrinter(object):
# track N = N + 1
if data.startswith("N") and "M110" in data:
linenumber = int(re.search("N([0-9]+)", data).group(1))
linenumber = int(re.search(r"N([0-9]+)", data).group(1))
self.lastN = linenumber
self.currentLine = linenumber
@@ -327,7 +327,7 @@ class VirtualPrinter(object):
self._sendOk()
continue
elif data.startswith("N"):
linenumber = int(re.search("N([0-9]+)", data).group(1))
linenumber = int(re.search(r"N([0-9]+)", data).group(1))
expected = self.lastN + 1
if linenumber != expected:
self._triggerResend(actual=linenumber)
@@ -491,7 +491,7 @@ class VirtualPrinter(object):
def _gcode_M26(self, data):
if self._sdCardReady:
pos = int(re.search("S([0-9]+)", data).group(1))
pos = int(re.search(r"S([0-9]+)", data).group(1))
self._setSdPos(pos)
def _gcode_M27(self, data):
@@ -499,7 +499,7 @@ class VirtualPrinter(object):
if self._sdCardReady:
self._reportSdStatus()
match = re.search("S([0-9]+)", data)
match = re.search(r"S([0-9]+)", data)
if match:
interval = int(match.group(1))
if self._sdstatus_reporter is not None:
@@ -528,7 +528,7 @@ class VirtualPrinter(object):
self._deleteSdFile(filename)
def _gcode_M113(self, data):
interval = int(re.search("S([0-9]+)", data).group(1))
interval = int(re.search(r"S([0-9]+)", data).group(1))
if 0 <= interval <= 60:
self._busyInterval = interval
@@ -564,10 +564,10 @@ class VirtualPrinter(object):
def _gcode_M117(self, data):
# we'll just use this to echo a message, to allow playing around with pause triggers
if self._echoOnM117:
self._send("echo:%s" % re.search("M117\s+(.*)", data).group(1))
self._send("echo:%s" % re.search(r"M117\s+(.*)", data).group(1))
def _gcode_M155(self, data):
interval = int(re.search("S([0-9]+)", data).group(1))
interval = int(re.search(r"S([0-9]+)", data).group(1))
if self._temperature_reporter is not None:
self._temperature_reporter.cancel()
@@ -578,10 +578,10 @@ class VirtualPrinter(object):
self._temperature_reporter = None
def _gcode_M220(self, data):
self._feedrate_multiplier = float(re.search('S([0-9]+)', data).group(1))
self._feedrate_multiplier = float(re.search(r'S([0-9]+)', data).group(1))
def _gcode_M221(self, data):
self._flowrate_multiplier = float(re.search('S([0-9]+)', data).group(1))
self._flowrate_multiplier = float(re.search(r'S([0-9]+)', data).group(1))
def _gcode_M400(self, data):
self.buffered.join()
@@ -632,8 +632,8 @@ class VirtualPrinter(object):
_gcode_G3 = _gcode_G0
def _gcode_G4(self, data):
matchS = re.search('S([0-9]+)', data)
matchP = re.search('P([0-9]+)', data)
matchS = re.search(r'S([0-9]+)', data)
matchP = re.search(r'P([0-9]+)', data)
_timeout = 0
if matchP:
@@ -961,7 +961,7 @@ class VirtualPrinter(object):
def _parseHotendCommand(self, line, wait=False, support_r=False):
only_wait_if_higher = True
tool = 0
toolMatch = re.search('T([0-9]+)', line)
toolMatch = re.search(r'T([0-9]+)', line)
if toolMatch:
try:
tool = int(toolMatch.group(1))
@@ -972,11 +972,11 @@ class VirtualPrinter(object):
return
try:
self.targetTemp[tool] = float(re.search('S([0-9]+)', line).group(1))
self.targetTemp[tool] = float(re.search(r'S([0-9]+)', line).group(1))
except Exception:
if support_r:
try:
self.targetTemp[tool] = float(re.search('R([0-9]+)', line).group(1))
self.targetTemp[tool] = float(re.search(r'R([0-9]+)', line).group(1))
only_wait_if_higher = False
except Exception:
pass
@@ -989,11 +989,11 @@ class VirtualPrinter(object):
def _parseBedCommand(self, line, wait=False, support_r=False):
only_wait_if_higher = True
try:
self.bedTargetTemp = float(re.search('S([0-9]+)', line).group(1))
self.bedTargetTemp = float(re.search(r'S([0-9]+)', line).group(1))
except Exception:
if support_r:
try:
self.bedTargetTemp = float(re.search('R([0-9]+)', line).group(1))
self.bedTargetTemp = float(re.search(r'R([0-9]+)', line).group(1))
only_wait_if_higher = False
except Exception:
pass
@@ -1004,11 +1004,11 @@ class VirtualPrinter(object):
self._send("TargetBed:%d" % self.bedTargetTemp)
def _performMove(self, line):
matchX = re.search("X([0-9.]+)", line)
matchY = re.search("Y([0-9.]+)", line)
matchZ = re.search("Z([0-9.]+)", line)
matchE = re.search("E([0-9.]+)", line)
matchF = re.search("F([0-9.]+)", line)
matchX = re.search(r"X([0-9.]+)", line)
matchY = re.search(r"Y([0-9.]+)", line)
matchZ = re.search(r"Z([0-9.]+)", line)
matchE = re.search(r"E([0-9.]+)", line)
matchF = re.search(r"F([0-9.]+)", line)
duration = 0.0
if matchF is not None:
@@ -1089,10 +1089,10 @@ class VirtualPrinter(object):
time.sleep(duration)
def _setPosition(self, line):
matchX = re.search("X([0-9.]+)", line)
matchY = re.search("Y([0-9.]+)", line)
matchZ = re.search("Z([0-9.]+)", line)
matchE = re.search("E([0-9.]+)", line)
matchX = re.search(r"X([0-9.]+)", line)
matchY = re.search(r"Y([0-9.]+)", line)
matchZ = re.search(r"Z([0-9.]+)", line)
matchE = re.search(r"E([0-9.]+)", line)
if matchX is None and matchY is None and matchZ is None and matchE is None:
self._lastX = self._lastY = self._lastZ = self._lastE[self.currentExtruder] = 0
+2 -2
View File
@@ -44,10 +44,10 @@ class PrinterInterface(object):
valid_axes = ("x", "y", "z", "e")
"""Valid axes identifiers."""
valid_tool_regex = re.compile("^(tool\d+)$")
valid_tool_regex = re.compile(r"^(tool\d+)$")
"""Regex for valid tool identifiers."""
valid_heater_regex = re.compile("^(tool\d+|bed)$")
valid_heater_regex = re.compile(r"^(tool\d+|bed)$")
"""Regex for valid heater identifiers."""
@classmethod
+3 -3
View File
@@ -1014,7 +1014,7 @@ class Server(object):
def regex_replace(s, find, replace):
return re.sub(find, replace, s)
html_header_regex = re.compile("<h(?P<number>[1-6])>(?P<content>.*?)</h(?P=number)>")
html_header_regex = re.compile(r"<h(?P<number>[1-6])>(?P<content>.*?)</h(?P=number)>")
def offset_html_headers(s, offset):
def repl(match):
number = int(match.group("number"))
@@ -1026,7 +1026,7 @@ class Server(object):
return "<h{number}>{content}</h{number}>".format(number=number, content=match.group("content"))
return html_header_regex.sub(repl, s)
markdown_header_regex = re.compile("^(?P<hashs>#+)\s+(?P<content>.*)$", flags=re.MULTILINE)
markdown_header_regex = re.compile(r"^(?P<hashs>#+)\s+(?P<content>.*)$", flags=re.MULTILINE)
def offset_markdown_headers(s, offset):
def repl(match):
number = len(match.group("hashs"))
@@ -1038,7 +1038,7 @@ class Server(object):
return "{hashs} {content}".format(hashs="#" * number, content=match.group("content"))
return markdown_header_regex.sub(repl, s)
html_link_regex = re.compile("<(?P<tag>a.*?)>(?P<content>.*?)</a>")
html_link_regex = re.compile(r"<(?P<tag>a.*?)>(?P<content>.*?)</a>")
def externalize_links(text):
def repl(match):
tag = match.group("tag")
+1 -1
View File
@@ -77,7 +77,7 @@ def printerToolCommand():
if response is not None:
return response
validation_regex = re.compile("tool\d+")
validation_regex = re.compile(r"tool\d+")
tags = {"source:api", "api:printer.tool"}
+3 -3
View File
@@ -60,7 +60,7 @@ class LessImportRewrite(UrlRewriter):
name = "less_importrewrite"
patterns = {
"import_rewrite": re.compile("(@import(\s+\(.*\))?\s+)\"(.*)\";")
"import_rewrite": re.compile(r"(@import(\s+\(.*\))?\s+)\"(.*)\";")
}
def import_rewrite(self, m):
@@ -73,7 +73,7 @@ class SourceMapRewrite(UrlRewriter):
name = "sourcemap_urlrewrite"
patterns = {
"url_rewrite": re.compile("(//#\s+sourceMappingURL=)(.*)")
"url_rewrite": re.compile(r"(//#\s+sourceMappingURL=)(.*)")
}
def url_rewrite(self, m):
@@ -86,7 +86,7 @@ class SourceMapRemove(PatternRewriter):
name = "sourcemap_remove"
patterns = {
"sourcemap_remove": re.compile("(//#\s+sourceMappingURL=)(.*)")
"sourcemap_remove": re.compile(r"(//#\s+sourceMappingURL=)(.*)")
}
def sourcemap_remove(self, m):
+4 -4
View File
@@ -359,9 +359,9 @@ default_settings = {
"apps": {}
},
"terminalFilters": [
{ "name": "Suppress temperature messages", "regex": "(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)" },
{ "name": "Suppress SD status messages", "regex": "(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)" },
{ "name": "Suppress wait responses", "regex": "Recv: wait"}
{ "name": "Suppress temperature messages", "regex": r"(Send: (N\d+\s+)?M105)|(Recv:\s+(ok\s+)?.*(B|T\d*):\d+)" },
{ "name": "Suppress SD status messages", "regex": r"(Send: (N\d+\s+)?M27)|(Recv: SD printing byte)|(Recv: Not SD printing)" },
{ "name": "Suppress wait responses", "regex": r"Recv: wait"}
],
"plugins": {
"_disabled": []
@@ -1103,7 +1103,7 @@ class Settings(object):
self._logger.info("Migrating config (event subscriptions)...")
# migrate event hooks to new format
placeholderRe = re.compile("%\((.*?)\)s")
placeholderRe = re.compile(r"%\((.*?)\)s")
eventNameReplacements = {
"ClientOpen": "ClientOpened",
+3 -3
View File
@@ -51,12 +51,12 @@ _capture_glob = "{prefix}-*.jpg"
_output_format = "{prefix}{postfix}.{extension}"
# ffmpeg progress regexes
_ffmpeg_duration_regex = re.compile("Duration: (\d{2}):(\d{2}):(\d{2})\.\d{2}")
_ffmpeg_current_regex = re.compile("time=(\d{2}):(\d{2}):(\d{2})\.\d{2}")
_ffmpeg_duration_regex = re.compile(r"Duration: (\d{2}):(\d{2}):(\d{2})\.\d{2}")
_ffmpeg_current_regex = re.compile(r"time=(\d{2}):(\d{2}):(\d{2})\.\d{2}")
# old capture format, needed to delete old left-overs from
# versions <1.2.9
_old_capture_format_re = re.compile("^tmp_\d{5}.jpg$")
_old_capture_format_re = re.compile(r"^tmp_\d{5}.jpg$")
# valid timelapses
_valid_timelapse_types = ["off", "timed", "zchange"]
+27 -27
View File
@@ -52,38 +52,38 @@ _logger = logging.getLogger(__name__)
# a bunch of regexes we'll need for the communication parsing...
regex_float_pattern = "[-+]?[0-9]*\.?[0-9]+"
regex_positive_float_pattern = "[+]?[0-9]*\.?[0-9]+"
regex_int_pattern = "\d+"
regex_float_pattern = r"[-+]?[0-9]*\.?[0-9]+"
regex_positive_float_pattern = r"[+]?[0-9]*\.?[0-9]+"
regex_int_pattern = r"\d+"
regex_command = re.compile("^\s*((?P<codeGM>[GM]\d+)(\\.(?P<subcode>\d+))?|(?P<codeT>T)\d+|(?P<codeF>F)\d+)")
regex_command = re.compile(r"^\s*((?P<codeGM>[GM]\d+)(\\.(?P<subcode>\d+))?|(?P<codeT>T)\d+|(?P<codeF>F)\d+)")
"""Regex for a GCODE command."""
regex_float = re.compile(regex_float_pattern)
"""Regex for a float value."""
regexes_parameters = dict(
floatE=re.compile("(^|[^A-Za-z])[Ee](?P<value>%s)" % regex_float_pattern),
floatF=re.compile("(^|[^A-Za-z])[Ff](?P<value>%s)" % regex_float_pattern),
floatP=re.compile("(^|[^A-Za-z])[Pp](?P<value>%s)" % regex_float_pattern),
floatR=re.compile("(^|[^A-Za-z])[Rr](?P<value>%s)" % regex_float_pattern),
floatS=re.compile("(^|[^A-Za-z])[Ss](?P<value>%s)" % regex_float_pattern),
floatX=re.compile("(^|[^A-Za-z])[Xx](?P<value>%s)" % regex_float_pattern),
floatY=re.compile("(^|[^A-Za-z])[Yy](?P<value>%s)" % regex_float_pattern),
floatZ=re.compile("(^|[^A-Za-z])[Zz](?P<value>%s)" % regex_float_pattern),
intN=re.compile("(^|[^A-Za-z])[Nn](?P<value>%s)" % regex_int_pattern),
intS=re.compile("(^|[^A-Za-z])[Ss](?P<value>%s)" % regex_int_pattern),
intT=re.compile("(^|[^A-Za-z])[Tt](?P<value>%s)" % regex_int_pattern)
floatE=re.compile(r"(^|[^A-Za-z])[Ee](?P<value>%s)" % regex_float_pattern),
floatF=re.compile(r"(^|[^A-Za-z])[Ff](?P<value>%s)" % regex_float_pattern),
floatP=re.compile(r"(^|[^A-Za-z])[Pp](?P<value>%s)" % regex_float_pattern),
floatR=re.compile(r"(^|[^A-Za-z])[Rr](?P<value>%s)" % regex_float_pattern),
floatS=re.compile(r"(^|[^A-Za-z])[Ss](?P<value>%s)" % regex_float_pattern),
floatX=re.compile(r"(^|[^A-Za-z])[Xx](?P<value>%s)" % regex_float_pattern),
floatY=re.compile(r"(^|[^A-Za-z])[Yy](?P<value>%s)" % regex_float_pattern),
floatZ=re.compile(r"(^|[^A-Za-z])[Zz](?P<value>%s)" % regex_float_pattern),
intN=re.compile(r"(^|[^A-Za-z])[Nn](?P<value>%s)" % regex_int_pattern),
intS=re.compile(r"(^|[^A-Za-z])[Ss](?P<value>%s)" % regex_int_pattern),
intT=re.compile(r"(^|[^A-Za-z])[Tt](?P<value>%s)" % regex_int_pattern)
)
"""Regexes for parsing various GCODE command parameters."""
regex_minMaxError = re.compile("Error:[0-9]\n")
regex_minMaxError = re.compile(r"Error:[0-9]\n")
"""Regex matching first line of min/max errors from the firmware."""
regex_marlinKillError = re.compile("Heating failed|Thermal Runaway|MAXTEMP triggered|MINTEMP triggered|Invalid extruder number|Watchdog barked|KILL caused")
regex_marlinKillError = re.compile(r"Heating failed|Thermal Runaway|MAXTEMP triggered|MINTEMP triggered|Invalid extruder number|Watchdog barked|KILL caused")
"""Regex matching first line of kill causing errors from Marlin."""
regex_sdPrintingByte = re.compile("(?P<current>[0-9]*)/(?P<total>[0-9]*)")
regex_sdPrintingByte = re.compile(r"(?P<current>[0-9]*)/(?P<total>[0-9]*)")
"""Regex matching SD printing status reports.
Groups will be as follows:
@@ -92,7 +92,7 @@ Groups will be as follows:
* ``total``: total size of file being printed
"""
regex_sdFileOpened = re.compile("File opened:\s*(?P<name>.*?)\s+Size:\s*(?P<size>%s)" % regex_int_pattern)
regex_sdFileOpened = re.compile(r"File opened:\s*(?P<name>.*?)\s+Size:\s*(?P<size>%s)" % regex_int_pattern)
"""Regex matching "File opened" messages from the firmware.
Groups will be as follows:
@@ -101,7 +101,7 @@ Groups will be as follows:
* ``size``: size of the file in bytes (int)
"""
regex_temp = re.compile("(?P<tool>B|T(?P<toolnum>\d*)):\s*(?P<actual>%s)(\s*\/?\s*(?P<target>%s))?" % (regex_float_pattern, regex_float_pattern))
regex_temp = re.compile(r"(?P<tool>B|T(?P<toolnum>\d*)):\s*(?P<actual>%s)(\s*\/?\s*(?P<target>%s))?" % (regex_float_pattern, regex_float_pattern))
"""Regex matching temperature entries in line.
Groups will be as follows:
@@ -112,7 +112,7 @@ Groups will be as follows:
* ``target``: target temperature, if provided (float)
"""
regex_repetierTempExtr = re.compile("TargetExtr(?P<toolnum>\d+):(?P<target>%s)" % regex_float_pattern)
regex_repetierTempExtr = re.compile(r"TargetExtr(?P<toolnum>\d+):(?P<target>%s)" % regex_float_pattern)
"""Regex for matching target temp reporting from Repetier.
Groups will be as follows:
@@ -122,7 +122,7 @@ Groups will be as follows:
* ``target``: new target temperature (float)
"""
regex_repetierTempBed = re.compile("TargetBed:(?P<target>%s)" % regex_float_pattern)
regex_repetierTempBed = re.compile(r"TargetBed:(?P<target>%s)" % regex_float_pattern)
"""Regex for matching target temp reporting from Repetier for beds.
Groups will be as follows:
@@ -130,7 +130,7 @@ Groups will be as follows:
* ``target``: new target temperature (float)
"""
regex_position = re.compile("X:\s*(?P<x>{float})\s*Y:\s*(?P<y>{float})\s*Z:\s*(?P<z>{float})\s*((E:\s*(?P<e>{float}))|(?P<es>(E\d+:\s*{float}\s*)+))".format(float=regex_float_pattern))
regex_position = re.compile(r"X:\s*(?P<x>{float})\s*Y:\s*(?P<y>{float})\s*Z:\s*(?P<z>{float})\s*((E:\s*(?P<e>{float}))|(?P<es>(E\d+:\s*{float}\s*)+))".format(float=regex_float_pattern))
"""Regex for matching position reporting.
Groups will be as follows:
@@ -142,7 +142,7 @@ Groups will be as follows:
* ``es``: multiple E coordinates if present, to be parsed further with regex_e_positions
"""
regex_e_positions = re.compile("E(?P<id>\d+):\s*(?P<value>{float})".format(float=regex_float_pattern))
regex_e_positions = re.compile(r"E(?P<id>\d+):\s*(?P<value>{float})".format(float=regex_float_pattern))
"""Regex for matching multiple E coordinates in a position report.
Groups will be as follows:
@@ -151,10 +151,10 @@ Groups will be as follows:
* ``value``: reported position value
"""
regex_firmware_splitter = re.compile("\s*([A-Z0-9_]+):\s*")
regex_firmware_splitter = re.compile(r"\s*([A-Z0-9_]+):\s*")
"""Regex to use for splitting M115 responses."""
regex_resend_linenumber = re.compile("(N|N:)?(?P<n>%s)" % regex_int_pattern)
regex_resend_linenumber = re.compile(r"(N|N:)?(?P<n>%s)" % regex_int_pattern)
"""Regex to use for request line numbers in resend requests"""
def serialList():
@@ -4155,7 +4155,7 @@ class SendQueue(PrependableQueue):
return self._resend_queue.qsize() + self._send_queue.qsize()
_temp_command_regex = re.compile("^M(?P<command>104|109|140|190)(\s+T(?P<tool>\d+)|\s+S(?P<temperature>[-+]?\d*\.?\d*))+")
_temp_command_regex = re.compile(r"^M(?P<command>104|109|140|190)(\s+T(?P<tool>\d+)|\s+S(?P<temperature>[-+]?\d*\.?\d*))+")
def apply_temperature_offsets(line, offsets, current_tool=None):
if offsets is None:
+4 -3
View File
@@ -61,7 +61,7 @@ class TestCommHelpers(unittest.TestCase):
self.assertEqual(input, actual)
else:
import re
match = re.search("S(\d+(\.\d+)?)", actual)
match = re.search(r"S(\d+(\.\d+)?)", actual)
if not match:
self.fail("No temperature found")
temperature = float(match.group(1))
@@ -103,14 +103,15 @@ class TestCommHelpers(unittest.TestCase):
m.update(input)
return m.hexdigest()
temp_regex = b'T:((\d*\.)\d+)'
# rb'' doesn't exist in Python2
temp_regex = r'T:((\d*\.)\d+)'.encode('utf-8')
temp_template = b"Temp: {}"
temp2_template = b"Temperature: {}"
temp_key = md5sum(temp_regex)
temp_template_key = md5sum(temp_template)
temp2_template_key = md5sum(temp2_template)
x_regex = b"X:(?P<x>\d+)"
x_regex = r"X:(?P<x>\d+)".encode('utf-8')
x_template = b"X: {x}"
x_key = md5sum(x_regex)
x_template_key = md5sum(x_template)