mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
bff2ebc9d5
commit
35cd019066
@ -172,12 +172,12 @@ def parse_css(data, fname='<string>', is_declaration=False, decode=None, log_lev
|
|||||||
data = parser.parseString(data, href=fname, validate=False)
|
data = parser.parseString(data, href=fname, validate=False)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def apply_func_to_match_groups(match, func):
|
def apply_func_to_match_groups(match, func=icu_upper):
|
||||||
'''Apply the specified function to individual groups in the match object (the result of re.search() or
|
'''Apply the specified function to individual groups in the match object (the result of re.search() or
|
||||||
the whole match if no groups were defined. Returns the replaced string.'''
|
the whole match if no groups were defined. Returns the replaced string.'''
|
||||||
found_groups = False
|
found_groups = False
|
||||||
i = 0
|
i = 0
|
||||||
parts, pos = [], 0
|
parts, pos = [], match.start()
|
||||||
while True:
|
while True:
|
||||||
i += 1
|
i += 1
|
||||||
try:
|
try:
|
||||||
@ -191,6 +191,6 @@ def apply_func_to_match_groups(match, func):
|
|||||||
pos = end
|
pos = end
|
||||||
if not found_groups:
|
if not found_groups:
|
||||||
return func(match.group())
|
return func(match.group())
|
||||||
parts.append(match.string[pos:])
|
parts.append(match.string[pos:match.end()])
|
||||||
return ''.join(parts)
|
return ''.join(parts)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user