diff --git a/xml2rfc/utils.py b/xml2rfc/utils.py index 12bbe371..1c845724 100644 --- a/xml2rfc/utils.py +++ b/xml2rfc/utils.py @@ -268,9 +268,9 @@ def replacer(match): .replace(':', ':' + wj_char) ) if 'http://' in text: - text = re.sub('http:\S*', replacer, text) + text = re.sub(r'http:\S*', replacer, text) if 'https://' in text: - text = re.sub('https:\S*', replacer, text) + text = re.sub(r'https:\S*', replacer, text) return text # ---------------------------------------------------------------------- @@ -286,13 +286,13 @@ def formatXmlWhitespace(tree): # Preserve formatting on artwork if element.tag != 'artwork': if element.text is not None: - element.text = re.sub('\s*\n\s*', ' ', \ - re.sub('\.\s*\n\s*', '. ', \ + element.text = re.sub(r'\s*\n\s*', ' ', \ + re.sub(r'\.\s*\n\s*', '. ', \ element.text.lstrip())) if element.tail is not None: - element.tail = re.sub('\s*\n\s*', ' ', \ - re.sub('\.\s*\n\s*', '. ', \ + element.tail = re.sub(r'\s*\n\s*', ' ', \ + re.sub(r'\.\s*\n\s*', '. ', \ element.tail)) @@ -580,7 +580,7 @@ def _replace_slashed_words(str, slashList): """ replace slashed separated words the list with   /   """ - match = re.findall(u'(\w+(/\w+)+)', str) + match = re.findall(r'(\w+(/\w+)+)', str) for item in match: if item[0] in slashList: str = re.sub(item[0], slashList[item[0]], str) diff --git a/xml2rfc/writers/base.py b/xml2rfc/writers/base.py index 8821605c..6500d44c 100644 --- a/xml2rfc/writers/base.py +++ b/xml2rfc/writers/base.py @@ -609,7 +609,7 @@ def get_initials(self, author): # period initials = initials.strip() initials += '.' if not initials.endswith('.') else '' - initials = re.sub('([^.]) ', '\g<1>. ', initials) + initials = re.sub(r'([^.]) ', r'\g<1>. ', initials) else: initials = initials_list[0] + "." return initials @@ -1347,7 +1347,7 @@ def _build_document(self): xml2rfc.log.warn("No (or empty) 'docName' attribute in the element -- can't insert draft name on first page.") if docName and '.' in docName: xml2rfc.log.warn("The 'docName' attribute of the element should not contain any filename extension: docName=\"draft-foo-bar-02\".") - if docName and not rfcnum and not re.search('-\d\d$', docName): + if docName and not rfcnum and not re.search(r'-\d\d$', docName): xml2rfc.log.warn("The 'docName' attribute of the element should have a revision number as the last component: docName=\"draft-foo-bar-02\".") self.write_title(title.text, docName, title.sourceline)