mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
unnecessary regex (auto-fix)
ruff 'RUF055'
This commit is contained in:
parent
7f6a11a368
commit
bd59682f46
@ -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': ''})
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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])
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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']
|
||||
|
||||
|
@ -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
|
||||
|
@ -153,7 +153,7 @@ class HTMLConverter:
|
||||
# Remove <br> and replace <br><br> with <p>
|
||||
(re.compile(r'<br.*?>\s*<br.*?>', re.IGNORECASE), lambda match: '<p>'),
|
||||
(re.compile(r'(.*)<br.*?>', 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'(?<!%)%t', options.title, fheader)
|
||||
fheader = re.sub(r'(?<!%)%a', options.author, fheader)
|
||||
fheader = re.sub(r'%%a','%a',fheader)
|
||||
fheader = re.sub(r'%%t','%t',fheader)
|
||||
fheader = fheader.replace('%%a', '%a')
|
||||
fheader = fheader.replace('%%t', '%t')
|
||||
header.append(fheader + ' ')
|
||||
book, fonts = Book(options, logger, header=header, **args)
|
||||
le = re.compile(options.link_exclude) if options.link_exclude else \
|
||||
|
@ -312,7 +312,7 @@ class FlowSplitter:
|
||||
def split_text(self, text, root, size):
|
||||
self.log.debug('\t\t\tSplitting text of length: %d'%len(text))
|
||||
rest = text.replace('\r', '')
|
||||
parts = re.split('\n\n', rest)
|
||||
parts = rest.split('\n\n')
|
||||
self.log.debug('\t\t\t\tFound %d parts'%len(parts))
|
||||
if max(map(len, parts)) > size:
|
||||
raise SplitError('Cannot split as file contains a <pre> tag '
|
||||
|
@ -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)
|
||||
|
@ -594,7 +594,7 @@ class Textile:
|
||||
|
||||
line = self.doPBr(line)
|
||||
if self.html_type == 'xhtml':
|
||||
line = re.sub(r'<br>', '<br />', line)
|
||||
line = line.replace('<br>', '<br />')
|
||||
|
||||
if ext and anon:
|
||||
out.append(out.pop() + '\n' + line)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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':
|
||||
|
@ -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:
|
||||
|
@ -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")]')
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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'
|
||||
|
Loading…
x
Reference in New Issue
Block a user