From e5455662a9762fc2cb8859134d855413d84fd265 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 14 Jan 2019 15:50:51 +0000 Subject: bitbake: bitbake: Fix Deprecated warnings from regexs Fix handling of escape characters in regexs and hence fix python Deprecation warnings which will be problematic in python 3.8. (Bitbake rev: c1fcc46e2498ddd41425d8756754f814d682aba3) Signed-off-by: Richard Purdie --- bitbake/lib/bs4/dammit.py | 12 ++++++------ bitbake/lib/bs4/element.py | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'bitbake/lib/bs4') diff --git a/bitbake/lib/bs4/dammit.py b/bitbake/lib/bs4/dammit.py index 68d419feb5..805aa908a5 100644 --- a/bitbake/lib/bs4/dammit.py +++ b/bitbake/lib/bs4/dammit.py @@ -45,9 +45,9 @@ except ImportError: pass xml_encoding_re = re.compile( - '^<\?.*encoding=[\'"](.*?)[\'"].*\?>'.encode(), re.I) + r'^<\?.*encoding=[\'"](.*?)[\'"].*\?>'.encode(), re.I) html_meta_re = re.compile( - '<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I) + r'<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I) class EntitySubstitution(object): @@ -80,11 +80,11 @@ class EntitySubstitution(object): ">": "gt", } - BARE_AMPERSAND_OR_BRACKET = re.compile("([<>]|" - "&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)" - ")") + BARE_AMPERSAND_OR_BRACKET = re.compile(r"([<>]|" + r"&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)" + r")") - AMPERSAND_OR_BRACKET = re.compile("([<>&])") + AMPERSAND_OR_BRACKET = re.compile(r"([<>&])") @classmethod def _substitute_html_entity(cls, matchobj): diff --git a/bitbake/lib/bs4/element.py b/bitbake/lib/bs4/element.py index 0c30759ffc..3775a60458 100644 --- a/bitbake/lib/bs4/element.py +++ b/bitbake/lib/bs4/element.py @@ -10,7 +10,7 @@ from bs4.dammit import EntitySubstitution DEFAULT_OUTPUT_ENCODING = "utf-8" PY3K = (sys.version_info[0] > 2) -whitespace_re = re.compile("\s+") +whitespace_re = re.compile(r"\s+") def _alias(attr): """Alias one attribute name to another for backward compatibility""" @@ -67,7 +67,7 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution): The value of the 'content' attribute will be one of these objects. """ - CHARSET_RE = re.compile("((^|;)\s*charset=)([^;]*)", re.M) + CHARSET_RE = re.compile(r"((^|;)\s*charset=)([^;]*)", re.M) def __new__(cls, original_value): match = cls.CHARSET_RE.search(original_value) @@ -580,7 +580,7 @@ class PageElement(object): # Methods for supporting CSS selectors. - tag_name_re = re.compile('^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$') + tag_name_re = re.compile(r'^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$') # /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ # \---------------------------/ \---/\-------------/ \-------/ @@ -1364,7 +1364,7 @@ class Tag(PageElement): if tag_name == '': raise ValueError( "A pseudo-class must be prefixed with a tag name.") - pseudo_attributes = re.match('([a-zA-Z\d-]+)\(([a-zA-Z\d]+)\)', pseudo) + pseudo_attributes = re.match(r'([a-zA-Z\d-]+)\(([a-zA-Z\d]+)\)', pseudo) found = [] if pseudo_attributes is None: pseudo_type = pseudo -- cgit v1.2.3-54-g00ecf