From 7d69da2c75170ab060a19c5d2614deb0e3471225 Mon Sep 17 00:00:00 2001 From: zzj <29055749+zjzh@users.noreply.github.com> Date: Sat, 22 Jan 2022 22:19:01 +0800 Subject: [PATCH 1/2] refactoring code with For Else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactoring code with For Else which is more pythonic, concise and efficient; how do you think this change which has practical value? --- html5lib/_ihatexml.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py index 3ff803c1..b11a0c70 100644 --- a/html5lib/_ihatexml.py +++ b/html5lib/_ihatexml.py @@ -104,16 +104,16 @@ def charStringToList(chars): charRanges = [item.strip() for item in chars.split(" | ")] rv = [] for item in charRanges: - foundMatch = False + for regexp in (reChar, reCharRange): match = regexp.match(item) if match is not None: rv.append([hexToInt(item) for item in match.groups()]) if len(rv[-1]) == 1: rv[-1] = rv[-1] * 2 - foundMatch = True + break - if not foundMatch: + else: assert len(item) == 1 rv.append([ord(item)] * 2) From 7cd5c9e584b26272316d0d1eb7e590122968fa0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Langa?= Date: Wed, 1 Mar 2023 15:52:36 +0100 Subject: [PATCH 2/2] Remove spurious empty lines --- html5lib/_ihatexml.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/html5lib/_ihatexml.py b/html5lib/_ihatexml.py index b11a0c70..d725eabd 100644 --- a/html5lib/_ihatexml.py +++ b/html5lib/_ihatexml.py @@ -104,18 +104,15 @@ def charStringToList(chars): charRanges = [item.strip() for item in chars.split(" | ")] rv = [] for item in charRanges: - for regexp in (reChar, reCharRange): match = regexp.match(item) if match is not None: rv.append([hexToInt(item) for item in match.groups()]) if len(rv[-1]) == 1: rv[-1] = rv[-1] * 2 - break else: assert len(item) == 1 - rv.append([ord(item)] * 2) rv = normaliseCharList(rv) return rv pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy