diff --git a/recipes/brewiarz.recipe b/recipes/brewiarz.recipe index 4e9552ba51..bccc858010 100644 --- a/recipes/brewiarz.recipe +++ b/recipes/brewiarz.recipe @@ -92,8 +92,7 @@ class brewiarz(BasicNewsRecipe): for sublink in sublinks: link_title = self.tag_to_string( link) + ' - ' + self.tag_to_string(sublink) - link_url_print = re.sub( - 'php3', 'php3?kr=_druk&wr=lg&', sublink['href']) + link_url_print = sublink['href'].replace('php3', 'php3?kr=_druk&wr=lg&') link_url = url[:-10] + link_url_print current_articles.append({'title': link_title, 'url': link_url, 'description': '', 'date': ''}) @@ -102,8 +101,7 @@ class brewiarz(BasicNewsRecipe): continue else: link_title = self.tag_to_string(link) - link_url_print = re.sub( - 'php3', 'php3?kr=_druk&wr=lg&', link['href']) + link_url_print = link['href'].replace('php3', 'php3?kr=_druk&wr=lg&') link_url = url[:-10] + link_url_print current_articles.append({'title': link_title, 'url': link_url, 'description': '', 'date': ''}) diff --git a/recipes/calgary_herald.recipe b/recipes/calgary_herald.recipe index e74af9365a..981558e25d 100644 --- a/recipes/calgary_herald.recipe +++ b/recipes/calgary_herald.recipe @@ -170,18 +170,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/edmonton_journal.recipe b/recipes/edmonton_journal.recipe index 2c43582ad0..5800a552d5 100644 --- a/recipes/edmonton_journal.recipe +++ b/recipes/edmonton_journal.recipe @@ -170,18 +170,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/montreal_gazette.recipe b/recipes/montreal_gazette.recipe index cc3633e2a2..6d8a65cb03 100644 --- a/recipes/montreal_gazette.recipe +++ b/recipes/montreal_gazette.recipe @@ -170,18 +170,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/nikkei_news.recipe b/recipes/nikkei_news.recipe index 28dfdff1c9..bd493cf260 100644 --- a/recipes/nikkei_news.recipe +++ b/recipes/nikkei_news.recipe @@ -86,7 +86,7 @@ class NikkeiNet_paper_subscription(BasicNewsRecipe): sect_title = sect_title.contents[0] sect_result = [] url = sect.a['href'] - url = re.sub('/article/', '/print-article/', url) + url = url.replace('/article/', '/print-article/') url = 'http://www.nikkei.com' + url sect_result.append(dict(title=sect_title, url=url, date='',description='', content='')) result.append([sect_title, sect_result]) diff --git a/recipes/ottawa_citizen.recipe b/recipes/ottawa_citizen.recipe index 0154d55758..21af4a8d5e 100644 --- a/recipes/ottawa_citizen.recipe +++ b/recipes/ottawa_citizen.recipe @@ -170,18 +170,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/regina_leader_post.recipe b/recipes/regina_leader_post.recipe index d9b37fc9bc..c3bb4625a2 100644 --- a/recipes/regina_leader_post.recipe +++ b/recipes/regina_leader_post.recipe @@ -129,18 +129,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/respekt_magazine.recipe b/recipes/respekt_magazine.recipe index ecb9cae42b..d8da4aa66f 100644 --- a/recipes/respekt_magazine.recipe +++ b/recipes/respekt_magazine.recipe @@ -73,7 +73,7 @@ class respektRecipe(BasicNewsRecipe): def preprocess_raw_html(self, raw_html, url): root = lxml.html.fromstring(raw_html) if root.xpath('//title')[0].text == (u'Respekt • Despekt • RESPEKT'): - raw_html = re.sub('h2','h1',raw_html) + raw_html = raw_html.replace('h2', 'h1') return raw_html def parse_index(self): diff --git a/recipes/saskatoon_star_phoenix.recipe b/recipes/saskatoon_star_phoenix.recipe index 6b89e889c7..b6e94ace43 100644 --- a/recipes/saskatoon_star_phoenix.recipe +++ b/recipes/saskatoon_star_phoenix.recipe @@ -129,18 +129,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/vancouver_province.recipe b/recipes/vancouver_province.recipe index f6281b62e6..7e2e354bc2 100644 --- a/recipes/vancouver_province.recipe +++ b/recipes/vancouver_province.recipe @@ -183,18 +183,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/vancouver_sun.recipe b/recipes/vancouver_sun.recipe index 5326e44731..03016d6e25 100644 --- a/recipes/vancouver_sun.recipe +++ b/recipes/vancouver_sun.recipe @@ -171,18 +171,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/vic_times.recipe b/recipes/vic_times.recipe index dcadbe8c18..c4893c606b 100644 --- a/recipes/vic_times.recipe +++ b/recipes/vic_times.recipe @@ -133,18 +133,18 @@ class TimesColonist(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/recipes/windsor_star.recipe b/recipes/windsor_star.recipe index c28eebe4f6..db20312efe 100644 --- a/recipes/windsor_star.recipe +++ b/recipes/windsor_star.recipe @@ -129,18 +129,18 @@ class CanWestPaper(BasicNewsRecipe): def fixChars(self, string): # Replace lsquo (\x91) - fixed = re.sub('\x91', '‘', string) + fixed = string.replace('\x91', '‘') # Replace rsquo (\x92) - fixed = re.sub('\x92', '’', fixed) + fixed = fixed.replace('\x92', '’') # Replace ldquo (\x93) - fixed = re.sub('\x93', '“', fixed) + fixed = fixed.replace('\x93', '“') # Replace rdquo (\x94) - fixed = re.sub('\x94', '”', fixed) + fixed = fixed.replace('\x94', '”') # Replace ndash (\x96) - fixed = re.sub('\x96', '–', fixed) + fixed = fixed.replace('\x96', '–') # Replace mdash (\x97) - fixed = re.sub('\x97', '—', fixed) - fixed = re.sub('’', '’', fixed) + fixed = fixed.replace('\x97', '—') + fixed = fixed.replace('’', '’') return fixed def massageNCXText(self, description): diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml index 44033b2eab..ac6a054c2b 100644 --- a/ruff-strict-pep8.toml +++ b/ruff-strict-pep8.toml @@ -33,6 +33,7 @@ select = [ 'RUF', # nota: RUF can flag many unsolicited errors # preview rules 'RUF051', 'RUF056', # useless dict operation + 'RUF055', # unnecessary regex ] [lint.per-file-ignores] @@ -45,6 +46,7 @@ select = [ "src/calibre/gui2/store/stores/*" = ['UP'] "src/calibre/gui2/tts/manager.py" = ['UP037'] "src/calibre/utils/copy_files.py" = ['UP037'] +"src/calibre/utils/smartypants.py" = ['RUF055'] "src/qt/*.py" = ['I'] "src/qt/*.pyi" = ['I'] diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index 2aff246c21..2a4682f48e 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -686,7 +686,7 @@ class HeuristicProcessor: else: text_indent = style+':'+str(setting)+'pt;' if style == 'padding': - setting = re.sub('pt', '', setting).split(' ') + setting = setting.replace('pt', '').split(' ') if int(setting[1]) < 16 and int(setting[3]) < 16: if self.in_blockquote: debugabby = True diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index 0bed5ac710..92f2710a80 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -153,7 +153,7 @@ class HTMLConverter: # Remove
and replace

with

(re.compile(r'\s*', re.IGNORECASE), lambda match: '

'), (re.compile(r'(.*)', re.IGNORECASE), - lambda match: match.group() if re.match('<', match.group(1).lstrip()) or len(match.group(1)) < 40 + lambda match: match.group() if match.group(1).lstrip().startswith('<') or len(match.group(1)) < 40 else match.group(1)), # Remove hyphenation (re.compile(r'-\n\r?'), lambda match: ''), @@ -1864,8 +1864,8 @@ def process_file(path, options, logger): fheader = '%t by %a' fheader = re.sub(r'(? size: raise SplitError('Cannot split as file contains a

 tag '
diff --git a/src/calibre/ebooks/rtf/rtfml.py b/src/calibre/ebooks/rtf/rtfml.py
index 8de1fab772..28c3784d94 100644
--- a/src/calibre/ebooks/rtf/rtfml.py
+++ b/src/calibre/ebooks/rtf/rtfml.py
@@ -200,7 +200,7 @@ class RTFMLizer:
         # Remove excessive spaces
         text = re.sub('[ ]{2,}', ' ', text)
         text = re.sub('\t{2,}', '\t', text)
-        text = re.sub('\t ', '\t', text)
+        text = text.replace('\t ', '\t')
 
         # Remove excessive line breaks
         text = re.sub(r'(\{\\line \}\s*){3,}', r'{\\line }{\\line }', text)
diff --git a/src/calibre/ebooks/textile/functions.py b/src/calibre/ebooks/textile/functions.py
index 0fc53b151b..f83877cfa5 100644
--- a/src/calibre/ebooks/textile/functions.py
+++ b/src/calibre/ebooks/textile/functions.py
@@ -594,7 +594,7 @@ class Textile:
 
             line = self.doPBr(line)
             if self.html_type == 'xhtml':
-                line = re.sub(r'
', '
', line) + line = line.replace('
', '
') if ext and anon: out.append(out.pop() + '\n' + line) diff --git a/src/calibre/ebooks/txt/markdownml.py b/src/calibre/ebooks/txt/markdownml.py index 9b418f6e5e..53465bde6c 100644 --- a/src/calibre/ebooks/txt/markdownml.py +++ b/src/calibre/ebooks/txt/markdownml.py @@ -63,7 +63,7 @@ class MarkdownMLizer(OEB2HTML): start = start.group() else: start = '' - l = re.sub('\t', '', l) + l = l.replace('\t', '') new_text.append(start + l) text = '\n'.join(new_text) diff --git a/src/calibre/ebooks/txt/textileml.py b/src/calibre/ebooks/txt/textileml.py index 09b7ecfaf3..210505b186 100644 --- a/src/calibre/ebooks/txt/textileml.py +++ b/src/calibre/ebooks/txt/textileml.py @@ -95,7 +95,7 @@ class TextileMLizer(OEB2HTML): # remove empty spans text = re.sub(r'%\xa0+', r'%', text) # remove empty spans - MAY MERGE SOME ? - text = re.sub(r'%%', r'', text) + text = text.replace('%%', '') # remove spans from tagged output text = re.sub(r'%([_+*-]+)%', r'\1', text) # remove spaces before a newline @@ -402,7 +402,7 @@ class TextileMLizer(OEB2HTML): txt = self.build_block('', style, attribs, stylizer) txt += '. ' if txt != '\n. ': - txt = re.sub('\n', '', txt) + txt = txt.replace('\n', '') text.append(txt) tags.append('|\n') elif tag == 'td': diff --git a/src/calibre/gui2/actions/catalog.py b/src/calibre/gui2/actions/catalog.py index 4ffe9e9923..97c79b43f5 100644 --- a/src/calibre/gui2/actions/catalog.py +++ b/src/calibre/gui2/actions/catalog.py @@ -72,7 +72,7 @@ class GenerateCatalogAction(InterfaceAction): # jobs.results is a list - the first entry is the intended title for the dialog # Subsequent strings are error messages dialog_title = job.result.pop(0) - if re.search('warning', job.result[0].lower()): + if 'warning' in job.result[0].lower(): msg = _('Catalog generation complete, with warnings.') warning_dialog(self.gui, dialog_title, msg, det_msg='\n'.join(job.result), show=True) else: diff --git a/src/calibre/gui2/store/stores/nexto_plugin.py b/src/calibre/gui2/store/stores/nexto_plugin.py index 162c6f3f48..92feedaa73 100644 --- a/src/calibre/gui2/store/stores/nexto_plugin.py +++ b/src/calibre/gui2/store/stores/nexto_plugin.py @@ -82,10 +82,10 @@ class NextoStore(BasicStoreConfig, StorePlugin): price = ''.join(data.xpath('.//strong[@class="nprice"]/text()')) cover_url = ''.join(data.xpath('.//picture[@class="cover"]/img/@data-src')) - cover_url = re.sub(r'%2F', '/', cover_url) - cover_url = re.sub(r'widthMax=235&heightMax=335', 'widthMax=64&heightMax=64', cover_url) + cover_url = cover_url.replace('%2F', '/') + cover_url = cover_url.replace('widthMax=235&heightMax=335', 'widthMax=64&heightMax=64') title = ''.join(data.xpath('.//a[@class="title"]/text()')) - title = re.sub(r' – ebook', '', title) + title = title.replace(' – ebook', '') author = ', '.join(data.xpath('.//div[@class="col-7"]//h4//a/text()')) formats = ', '.join(data.xpath('.//ul[@class="formats"]/li//b/text()')) DrmFree = data.xpath('.//ul[@class="formats"]/li//b[contains(@title, "znak")]') diff --git a/src/calibre/gui2/store/stores/rw2010_plugin.py b/src/calibre/gui2/store/stores/rw2010_plugin.py index 6a4317678c..4c08c5bf66 100644 --- a/src/calibre/gui2/store/stores/rw2010_plugin.py +++ b/src/calibre/gui2/store/stores/rw2010_plugin.py @@ -75,7 +75,7 @@ class RW2010Store(BasicStoreConfig, StorePlugin): s.title = title.strip() s.author = author.strip() s.price = price - s.detail_item = re.sub(r'%3D', '=', id) + s.detail_item = id.replace('%3D', '=') s.drm = SearchResult.DRM_UNLOCKED s.formats = formats[0:-2].upper() diff --git a/src/calibre/library/catalogs/utils.py b/src/calibre/library/catalogs/utils.py index 5e7441c1e6..967b5faff4 100644 --- a/src/calibre/library/catalogs/utils.py +++ b/src/calibre/library/catalogs/utils.py @@ -88,9 +88,9 @@ class NumberToText: # {{{ # Special case ordinals if re.search('[st|nd|rd|th]',self.number): - self.number = re.sub(',','',self.number) + self.number = self.number.replace(',', '') ordinal_suffix = re.search(r'[\D]', self.number) - ordinal_number = re.sub(r'\D','',re.sub(',','',self.number)) + ordinal_number = re.sub(r'\D','',self.number.replace(',', '')) if self.verbose: self.log('Ordinal: %s' % ordinal_number) self.number_as_float = ordinal_number @@ -102,17 +102,17 @@ class NumberToText: # {{{ self.text = '%s' % (self.ORDINALS[int(ordinal_number)]) # Test for time - elif re.search(':',self.number): + elif ':' in self.number: if self.verbose: self.log('Time: %s' % self.number) - self.number_as_float = re.sub(':','.',self.number) + self.number_as_float = self.number.replace(':', '.') time_strings = self.number.split(':') hours = NumberToText(time_strings[0]).text minutes = NumberToText(time_strings[1]).text self.text = f'{hours.capitalize()}-{minutes}' # Test for % - elif re.search('%', self.number): + elif '%' in self.number: if self.verbose: self.log('Percent: %s' % self.number) self.number_as_float = self.number.split('%')[0] @@ -129,7 +129,7 @@ class NumberToText: # {{{ self.text = f'{left.capitalize()} point {right}' # Test for hyphenated - elif re.search('-', self.number): + elif '-' in self.number: if self.verbose: self.log('Hyphenated: %s' % self.number) self.number_as_float = self.number.split('-')[0] @@ -143,10 +143,10 @@ class NumberToText: # {{{ self.text = f'{left}-{right}' # Test for only commas and numbers - elif re.search(',', self.number) and not re.search('[^0-9,]',self.number): + elif ',' in self.number and not re.search('[^0-9,]',self.number): if self.verbose: self.log('Comma(s): %s' % self.number) - self.number_as_float = re.sub(',','',self.number) + self.number_as_float = self.number.replace(',', '') self.text = NumberToText(self.number_as_float).text # Test for hybrid e.g., 'K2, 2nd, 10@10'