diff --git a/setup/translations.py b/setup/translations.py index 29f0228914..414f27cc23 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -511,7 +511,7 @@ class Translations(POT): # {{{ locale = fmap[src] trans, untrans = data['translated'], data['untranslated'] total = trans + untrans - stats[locale] = int(round(100 * trans / total)) + stats[locale] = round(100 * trans / total) with TemporaryDirectory() as tdir, ZipFile(self.j(srcbase, 'locales.zip'), 'w', ZIP_STORED) as zf: for f in os.listdir(srcbase): diff --git a/src/calibre/db/__init__.py b/src/calibre/db/__init__.py index 6e20d86b98..5360706d80 100644 --- a/src/calibre/db/__init__.py +++ b/src/calibre/db/__init__.py @@ -38,12 +38,12 @@ def _get_next_series_num_for_list(series_indices, unwrap=True): return i # really shouldn't get here. if tweaks['series_index_auto_increment'] == 'next_free': - for i in range(int(ceil(series_indices[0])), 10000): + for i in range(ceil(series_indices[0]), 10000): if i not in series_indices: return i # really shouldn't get here. if tweaks['series_index_auto_increment'] == 'last_free': - for i in range(int(ceil(series_indices[-1])), 0, -1): + for i in range(ceil(series_indices[-1]), 0, -1): if i not in series_indices: return i return series_indices[-1] + 1 diff --git a/src/calibre/db/search.py b/src/calibre/db/search.py index d18c80baad..a6920cfa38 100644 --- a/src/calibre/db/search.py +++ b/src/calibre/db/search.py @@ -300,7 +300,7 @@ class NumericSearch: # {{{ raise ParseException( _('Non-numeric value in query: {0}').format(query)) if dt == 'half-rating': - q = int(round(q * 2)) + q = round(q * 2) cast = int qfalse = query == 'false' diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 90f62393ab..436f16af27 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -2858,7 +2858,7 @@ class KOBOTOUCH(KOBO): # NOTE: Unlike Qt, we round to avoid accumulating errors, # as ImageOps will then floor via fit_image aspect_ratio = library_size[0] / library_size[1] - rescaled_width = int(round(kobo_size[1] * aspect_ratio)) + rescaled_width = round(kobo_size[1] * aspect_ratio) if expand: use_height = (rescaled_width >= kobo_size[0]) @@ -2868,7 +2868,7 @@ class KOBOTOUCH(KOBO): if use_height: kobo_size = (rescaled_width, kobo_size[1]) else: - kobo_size = (kobo_size[0], int(round(kobo_size[0] / aspect_ratio))) + kobo_size = (kobo_size[0], round(kobo_size[0] / aspect_ratio)) # Did we actually want to letterbox? if not letterbox: diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index cb8605f167..6518821379 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -207,7 +207,7 @@ class HeuristicProcessor: if wordcount > 7000: if wordcount > 200000: typical_chapters = 15000. - self.min_chapters = int(ceil(wordcount / typical_chapters)) + self.min_chapters = ceil(wordcount / typical_chapters) self.log.debug('minimum chapters required are: '+str(self.min_chapters)) heading = re.compile(r']*>', re.IGNORECASE) self.html_preprocess_sections = len(heading.findall(html)) diff --git a/src/calibre/ebooks/covers.py b/src/calibre/ebooks/covers.py index b0120681f0..dcd6217bdd 100644 --- a/src/calibre/ebooks/covers.py +++ b/src/calibre/ebooks/covers.py @@ -184,7 +184,7 @@ class Block: @property def height(self): - return int(ceil(sum(l if isinstance(l, numbers.Number) else l.boundingRect().height() for l in self.layouts))) + return ceil(sum(l if isinstance(l, numbers.Number) else l.boundingRect().height() for l in self.layouts)) @property def position(self): diff --git a/src/calibre/ebooks/docx/to_html.py b/src/calibre/ebooks/docx/to_html.py index 554da8ad0a..8e7eb1cd66 100644 --- a/src/calibre/ebooks/docx/to_html.py +++ b/src/calibre/ebooks/docx/to_html.py @@ -715,7 +715,7 @@ class Convert: ans.append(text.elem) ans.set('data-noteref-container', self.uuid) elif self.namespace.is_tag(child, 'w:tab'): - spaces = int(math.ceil((self.settings.default_tab_stop / 36) * 6)) + spaces = math.ceil((self.settings.default_tab_stop / 36) * 6) text.add_elem(SPAN(NBSP * spaces)) ans.append(text.elem) ans[-1].set('class', 'tab') diff --git a/src/calibre/ebooks/fb2/fb2ml.py b/src/calibre/ebooks/fb2/fb2ml.py index b5bd4af51a..8a771d8810 100644 --- a/src/calibre/ebooks/fb2/fb2ml.py +++ b/src/calibre/ebooks/fb2/fb2ml.py @@ -430,7 +430,7 @@ class FB2MLizer: tag = barename(elem_tree.tag) # Number of blank lines above tag try: - ems = int(round((float(style.marginTop) / style.fontSize) - 1)) + ems = round((float(style.marginTop) / style.fontSize) - 1) if ems < 0: ems = 0 except: diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index d8576b26b2..eb9dedc579 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -987,7 +987,7 @@ class HTMLConverter: line_height = (int(self.current_block.textStyle.attrs['baselineskip']) + int(self.current_block.textStyle.attrs['linespace']))//10 line_height *= self.profile.dpi/72 - lines = int(ceil(height/line_height)) + lines = ceil(height/line_height) dc = DropCaps(lines) dc.append(Plot(im, xsize=ceil(width*factor), ysize=ceil(height*factor))) self.current_para.append(dc) @@ -1028,7 +1028,7 @@ class HTMLConverter: if max(width, height) <= min(pwidth, pheight)/5: self.current_para.append(Plot(im, xsize=ceil(width*factor), ysize=ceil(height*factor))) - elif height <= int(floor((2/3)*pheight)): + elif height <= floor((2/3)*pheight): pb = self.current_block self.end_current_para() self.process_alignment(tag_css) @@ -1046,7 +1046,7 @@ class HTMLConverter: self.current_page.contents[0:1] = [] self.current_page.append(Canvas(width=pwidth, height=height)) - left = int(floor((pwidth - width)/2)) + left = floor((pwidth - width)/2) self.current_page.contents[-1].put_object( ImageBlock(self.images[path], xsize=width, ysize=height, x1=width, y1=height, @@ -1324,9 +1324,9 @@ class HTMLConverter: result = unit * 0.4 * (dpi) if result is not None: if pts: - result = int(round(result * (720/dpi))) + result = round(result * (720/dpi)) else: - result = int(round(result)) + result = round(result) return result def text_properties(self, tag_css): diff --git a/src/calibre/ebooks/lrf/html/table.py b/src/calibre/ebooks/lrf/html/table.py index 1f968601ca..617196b474 100644 --- a/src/calibre/ebooks/lrf/html/table.py +++ b/src/calibre/ebooks/lrf/html/table.py @@ -11,7 +11,7 @@ from polyglot.builtins import native_string_type, string_or_bytes def ceil(num): - return int(math.ceil(num)) + return math.ceil(num) def print_xml(elem): diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py index 4d0fceb43f..5c52fa09b4 100644 --- a/src/calibre/ebooks/metadata/sources/identify.py +++ b/src/calibre/ebooks/metadata/sources/identify.py @@ -297,7 +297,7 @@ class ISBNMerge: if rating and rating > 0 and rating <= 5: ratings.append(rating) if ratings: - ans.rating = int(round(sum(ratings)/len(ratings))) + ans.rating = round(sum(ratings)/len(ratings)) # Smallest language is likely to be valid ans.language = self.length_merge('language', results, diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 75a0962969..0e2376c147 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -160,8 +160,8 @@ class MobiMLizer: return ptsize embase = self.profile.fbase if round(ptsize) < embase: - return f'{int(round(ptsize))}pt' - return f'{int(round(ptsize/embase))}em' + return f'{round(ptsize)}pt' + return f'{round(ptsize/embase)}em' def preize_text(self, text, pre_wrap=False): text = str(text) @@ -219,7 +219,7 @@ class MobiMLizer: ems = self.profile.mobi_ems_per_blockquote para = wrapper = etree.SubElement(parent, XHTML('blockquote')) para = wrapper - emleft = int(round(left / self.profile.fbase)) - ems + emleft = round(left / self.profile.fbase) - ems emleft = min((emleft, 10)) while emleft > ems / 2: para = etree.SubElement(para, XHTML('blockquote')) @@ -237,7 +237,7 @@ class MobiMLizer: wrapper.attrib['height'] = self.mobimlize_measure(vspace) para.attrib['width'] = self.mobimlize_measure(indent) elif tag == 'table' and vspace > 0: - vspace = int(round(vspace / self.profile.fbase)) + vspace = round(vspace / self.profile.fbase) while vspace > 0: wrapper.addprevious(etree.Element(XHTML('br'))) vspace -= 1 @@ -403,13 +403,13 @@ class MobiMLizer: padding = asfloat(style['padding-left']) lspace = margin + padding if lspace > 0: - spaces = int(round((lspace * 3) / style['font-size'])) + spaces = round((lspace * 3) / style['font-size']) elem.text = ('\xa0' * spaces) + (elem.text or '') margin = convert_margin(style, 'margin-right') padding = asfloat(style['padding-right']) rspace = margin + padding if rspace > 0: - spaces = int(round((rspace * 3) / style['font-size'])) + spaces = round((rspace * 3) / style['font-size']) if len(elem) == 0: elem.text = (elem.text or '') + ('\xa0' * spaces) else: @@ -459,8 +459,8 @@ class MobiMLizer: # img sizes in units other than px # See #7520 for test case try: - pixs = int(round(float(value) / - (72/self.profile.dpi))) + pixs = round(float(value) / + (72/self.profile.dpi)) except: continue result = str(pixs) @@ -503,7 +503,7 @@ class MobiMLizer: istate.attrib['width'] = raww else: prop = style['width'] / self.profile.width - istate.attrib['width'] = f'{int(round(prop*100))}%' + istate.attrib['width'] = f'{round(prop*100)}%' elif display == 'table': tag = 'table' elif display == 'table-row': diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py index 823359bbe9..30a81d8b30 100644 --- a/src/calibre/ebooks/oeb/polish/container.py +++ b/src/calibre/ebooks/oeb/polish/container.py @@ -131,7 +131,7 @@ def href_to_name(href, root, base=None): def seconds_to_timestamp(duration: float) -> str: - seconds = int(floor(duration)) + seconds = floor(duration) float_part = duration - seconds hours = seconds // 3600 minutes = (seconds % 3600) // 60 diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index f4a916141f..17d7bb0b3f 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -1076,7 +1076,7 @@ class Page: frag.indented = 1 # 1em else: # Assume left margin of approx = number of chars # Should check for values approx the same, as with indents - frag.margin_left = int(round(((frag.left - left_min) / self.stats_margin_px)+0.5)) + frag.margin_left = round(((frag.left - left_min) / self.stats_margin_px)+0.5) if last_frag is not None \ and stats.para_space > 0 \ and frag.bottom - last_frag.bottom > stats.para_space*SECTION_FACTOR: diff --git a/src/calibre/ebooks/pml/pmlml.py b/src/calibre/ebooks/pml/pmlml.py index e69a3d36b3..c11651ac5c 100644 --- a/src/calibre/ebooks/pml/pmlml.py +++ b/src/calibre/ebooks/pml/pmlml.py @@ -337,7 +337,7 @@ class PMLMLizer: # Soft scene breaks. try: - ems = int(round((float(style.marginTop) / style.fontSize) - 1)) + ems = round((float(style.marginTop) / style.fontSize) - 1) if ems >= 1: text.append('\n\\c \n\\c\n') except: diff --git a/src/calibre/ebooks/txt/markdownml.py b/src/calibre/ebooks/txt/markdownml.py index 5b117ba3cf..c710f8bda4 100644 --- a/src/calibre/ebooks/txt/markdownml.py +++ b/src/calibre/ebooks/txt/markdownml.py @@ -264,7 +264,7 @@ class MarkdownMLizer(OEB2HTML): # Soft scene breaks. if 'margin-bottom' in style.cssdict() and style['margin-bottom'] != 'auto': - ems = int(round((float(style.marginBottom) / style.fontSize) - 1)) + ems = round((float(style.marginBottom) / style.fontSize) - 1) if ems >= 1: text.append('\n\n' * ems) diff --git a/src/calibre/ebooks/txt/textileml.py b/src/calibre/ebooks/txt/textileml.py index a26ce03a69..e11e2371ab 100644 --- a/src/calibre/ebooks/txt/textileml.py +++ b/src/calibre/ebooks/txt/textileml.py @@ -186,7 +186,7 @@ class TextileMLizer(OEB2HTML): if 'margin-left' in style.cssdict() and style['margin-left'] != 'auto': left_margin_pts = unit_convert(style['margin-left'], style.width, style.fontSize, stylizer.profile.dpi) left = add(left_margin_pts, left_padding_pts) - emleft = min(int(round(left / stylizer.profile.fbase)), self.MAX_EM) + emleft = min(round(left / stylizer.profile.fbase), self.MAX_EM) if emleft >= 1: txt += '(' * emleft right_padding_pts = 0 @@ -196,7 +196,7 @@ class TextileMLizer(OEB2HTML): if 'margin-right' in style.cssdict() and style['margin-right'] != 'auto': right_margin_pts = unit_convert(style['margin-right'], style.width, style.fontSize, stylizer.profile.dpi) right = add(right_margin_pts, right_padding_pts) - emright = min(int(round(right / stylizer.profile.fbase)), self.MAX_EM) + emright = min(round(right / stylizer.profile.fbase), self.MAX_EM) if emright >= 1: txt += ')' * emright @@ -492,7 +492,7 @@ class TextileMLizer(OEB2HTML): # Soft scene breaks. if 'margin-bottom' in style.cssdict() and style['margin-bottom'] != 'auto': - ems = min(int(round((float(style.marginBottom) / style.fontSize) - 1)), self.MAX_EM) + ems = min(round((float(style.marginBottom) / style.fontSize) - 1), self.MAX_EM) if ems >= 1: text.append('\n\n\xa0' * ems) diff --git a/src/calibre/ebooks/txt/txtml.py b/src/calibre/ebooks/txt/txtml.py index 0258ec68f3..99b25705f4 100644 --- a/src/calibre/ebooks/txt/txtml.py +++ b/src/calibre/ebooks/txt/txtml.py @@ -233,7 +233,7 @@ class TXTMLizer: text.append('\n\n* * *\n\n') # Soft scene breaks. try: - ems = int(round((float(style.marginTop) / style.fontSize) - 1)) + ems = round((float(style.marginTop) / style.fontSize) - 1) if ems >= 1: text.append('\n' * ems) except: diff --git a/src/calibre/gui2/dialogs/trim_image.py b/src/calibre/gui2/dialogs/trim_image.py index 2c576f506e..614e94bd3b 100644 --- a/src/calibre/gui2/dialogs/trim_image.py +++ b/src/calibre/gui2/dialogs/trim_image.py @@ -31,7 +31,7 @@ from calibre.gui2.tweak_book.editor.canvas import Canvas def reduce_to_ratio(w, h, r): h = min(h, w / r) w = r * h - return int(round(w)), int(round(h)) + return round(w), round(h) class Region(QDialog): diff --git a/src/calibre/gui2/icon_theme.py b/src/calibre/gui2/icon_theme.py index b9dd7d3046..70958f2f76 100644 --- a/src/calibre/gui2/icon_theme.py +++ b/src/calibre/gui2/icon_theme.py @@ -211,7 +211,7 @@ def default_cover_icons(cols=5): def create_cover(report=None, icons=(), cols=5, size=120, padding=16, darkbg=False): icons = icons or tuple(default_cover_icons(cols)) - rows = int(math.ceil(len(icons) / cols)) + rows = math.ceil(len(icons) / cols) def get_path_for_icon(icon: str) -> str: if report is not None: diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py index 74510abfea..2e3df1df72 100644 --- a/src/calibre/gui2/library/alternate_views.py +++ b/src/calibre/gui2/library/alternate_views.py @@ -1395,7 +1395,7 @@ class GridView(QListView): # pixelDelta() is broken on linux with wheel mice dy = number_of_degrees.y() / 15.0 # Scroll by approximately half a row - dy = int(math.ceil((dy) * b.singleStep() / 2.0)) + dy = math.ceil((dy) * b.singleStep() / 2.0) else: dy = number_of_pixels.y() if abs(dy) > 0: diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index 332a9cc924..d35540af51 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -124,7 +124,7 @@ class TagDelegate(QStyledItemDelegate): # {{{ width = painter.fontMetrics().boundingRect(count).width() r = QRect(tr) dr = 1 if widget is None else widget.devicePixelRatioF() - r.setRight(r.right() - 1), r.setLeft(r.right() - width - int(ceil(4 * dr))) + r.setRight(r.right() - 1), r.setLeft(r.right() - width - ceil(4 * dr)) painter.drawText(r, Qt.AlignmentFlag.AlignCenter | Qt.TextFlag.TextSingleLine, count) tr.setRight(r.left() - 1) else: diff --git a/src/calibre/gui2/toc/location.py b/src/calibre/gui2/toc/location.py index 2a542d477a..ad53f2052c 100644 --- a/src/calibre/gui2/toc/location.py +++ b/src/calibre/gui2/toc/location.py @@ -441,7 +441,7 @@ class ItemEdit(QWidget): self.current_changed(item) def get_loctext(self, frac): - frac = int(round(frac * 100)) + frac = round(frac * 100) if frac == 0: loctext = _('Top of the file') else: diff --git a/src/calibre/gui2/tweak_book/completion/popup.py b/src/calibre/gui2/tweak_book/completion/popup.py index be4c5de13e..1a929a777e 100644 --- a/src/calibre/gui2/tweak_book/completion/popup.py +++ b/src/calibre/gui2/tweak_book/completion/popup.py @@ -82,8 +82,8 @@ class ChoosePopupWidget(QWidget): max_width = height = 0 for text, positions in self.current_results: sz = self.get_static_text(text, positions).size() - height += int(ceil(sz.height())) + self.BOTTOM_MARGIN - max_width = max(max_width, int(ceil(sz.width()))) + height += ceil(sz.height()) + self.BOTTOM_MARGIN + max_width = max(max_width, ceil(sz.width())) self.current_size_hint = QSize(max_width + 2 * self.SIDE_MARGIN, height + self.BOTTOM_MARGIN + self.TOP_MARGIN) return self.current_size_hint @@ -92,7 +92,7 @@ class ChoosePopupWidget(QWidget): bottom = self.rect().bottom() for i, (text, positions) in enumerate(self.current_results[self.current_top_index:]): st = self.get_static_text(text, positions) - height = self.BOTTOM_MARGIN + int(ceil(st.size().height())) + height = self.BOTTOM_MARGIN + ceil(st.size().height()) if y + height > bottom: break yield i + self.current_top_index, st, y, height diff --git a/src/calibre/gui2/tweak_book/diff/view.py b/src/calibre/gui2/tweak_book/diff/view.py index 6b0b1a084c..4197098986 100644 --- a/src/calibre/gui2/tweak_book/diff/view.py +++ b/src/calibre/gui2/tweak_book/diff/view.py @@ -687,7 +687,7 @@ class DiffSplit(QSplitter): # {{{ w, h = int(img.width()/img.devicePixelRatio()), int(img.height()/img.devicePixelRatio()) scaled, w, h = fit_image(w, h, view.available_width() - 3, int(0.9 * view.height())) line_height = view.blockBoundingRect(view.document().begin()).height() - return int(ceil(h / line_height)) + 1, w + return ceil(h / line_height) + 1, w # }}} # text diffs {{{ @@ -1062,7 +1062,7 @@ class DiffView(QWidget): # {{{ self.scrollbar.setSingleStep(min(ls.singleStep(), rs.singleStep())) self.scrollbar.setRange(0, ls.maximum() + self.delta) self.scrollbar.setVisible(self.view.left.document().lineCount() > ls.pageStep() or self.view.right.document().lineCount() > rs.pageStep()) - self.syncpos = int(ceil(self.scrollbar.pageStep() * self.SYNC_POSITION)) + self.syncpos = ceil(self.scrollbar.pageStep() * self.SYNC_POSITION) def finalize(self): self.view.finalize() diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index 0604c41095..be11370d1b 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -42,7 +42,7 @@ from polyglot.builtins import itervalues, string_or_bytes def create_icon(text, palette=None, sz=None, divider=2, fill='white'): if isinstance(fill, string_or_bytes): fill = QColor(fill) - sz = sz or int(math.ceil(tprefs['toolbar_icon_size'] * QApplication.instance().devicePixelRatio())) + sz = sz or math.ceil(tprefs['toolbar_icon_size'] * QApplication.instance().devicePixelRatio()) if palette is None: palette = QApplication.palette() img = QImage(sz, sz, QImage.Format.Format_ARGB32) diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py index 926bccc508..f4ba02680e 100644 --- a/src/calibre/gui2/tweak_book/widgets.py +++ b/src/calibre/gui2/tweak_book/widgets.py @@ -378,7 +378,7 @@ class Results(QWidget): self.current_result = 0 prefixes = [QStaticText(f'{os.path.basename(x)}') for x in results] [(p.setTextFormat(Qt.TextFormat.RichText), p.setTextOption(self.text_option)) for p in prefixes] - self.maxwidth = max(int(ceil(x.size().width())) for x in prefixes) + self.maxwidth = max(ceil(x.size().width()) for x in prefixes) self.results = tuple((prefix, self.make_text(text, positions), text) for prefix, (text, positions) in zip(prefixes, iteritems(results))) else: @@ -417,7 +417,7 @@ class Results(QWidget): p.drawStaticText(offset, prefix) offset.setX(self.maxwidth + 5) p.drawStaticText(offset, self.divider) - offset.setX(offset.x() + int(ceil(self.divider.size().width()))) + offset.setX(offset.x() + ceil(self.divider.size().width())) p.drawStaticText(offset, full) offset.setY(int(offset.y() + size.height() + self.MARGIN // 2)) if i in (self.current_result, self.mouse_hover_result): diff --git a/src/calibre/gui2/viewer/highlights.py b/src/calibre/gui2/viewer/highlights.py index 612ea7b8b2..b49b3375f2 100644 --- a/src/calibre/gui2/viewer/highlights.py +++ b/src/calibre/gui2/viewer/highlights.py @@ -110,7 +110,7 @@ def decoration_for_style(palette, style, icon_size, device_pixel_ratio, is_dark) q = builtin_decorations.get(which) if q is not None: style = q - sz = int(math.ceil(icon_size * device_pixel_ratio)) + sz = math.ceil(icon_size * device_pixel_ratio) canvas = QImage(sz, sz, QImage.Format.Format_ARGB32) canvas.fill(Qt.GlobalColor.transparent) canvas.setDevicePixelRatio(device_pixel_ratio) diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py index e821b4af66..9633a79550 100644 --- a/src/calibre/utils/filenames.py +++ b/src/calibre/utils/filenames.py @@ -72,7 +72,7 @@ def shorten_components_to(length, components, more_to_take=0, last_has_extension deltas = [] for x in components: pct = len(x)/float(len(filepath)) - deltas.append(int(ceil(pct*extra))) + deltas.append(ceil(pct*extra)) ans = [] for i, x in enumerate(components): diff --git a/src/calibre/utils/fonts/sfnt/__init__.py b/src/calibre/utils/fonts/sfnt/__init__.py index 2375c60053..350b19806c 100644 --- a/src/calibre/utils/fonts/sfnt/__init__.py +++ b/src/calibre/utils/fonts/sfnt/__init__.py @@ -55,7 +55,7 @@ class FixedProperty: return val / 0x10000 def __set__(self, obj, val): - return int(round(val*(0x10000))) + return round(val*(0x10000)) def max_power_of_two(x): diff --git a/src/calibre/utils/fonts/sfnt/metrics.py b/src/calibre/utils/fonts/sfnt/metrics.py index 774e2dbe93..31faa04a25 100644 --- a/src/calibre/utils/fonts/sfnt/metrics.py +++ b/src/calibre/utils/fonts/sfnt/metrics.py @@ -42,7 +42,7 @@ class FontMetrics: self._sig = hash(self.sfnt[b'name'].raw) # Metrics for embedding in PDF - pdf_scale = self.pdf_scale = lambda x: int(round(x*1000./self.units_per_em)) + pdf_scale = self.pdf_scale = lambda x: round(x*1000./self.units_per_em) self.pdf_ascent, self.pdf_descent = map(pdf_scale, (self.os2.typo_ascender, self.os2.typo_descender)) self.pdf_bbox = tuple(map(pdf_scale, self.bbox)) diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py index 1c35f7d3d7..db6f30838d 100644 --- a/src/calibre/utils/formatter_functions.py +++ b/src/calibre/utils/formatter_functions.py @@ -491,7 +491,7 @@ Throws an exception if ``value`` is not a number. def evaluate(self, formatter, kwargs, mi, locals, value): value = float(value if value and value != 'None' else 0) - return str(int(ceil(value))) + return str(ceil(value)) class BuiltinFloor(BuiltinFormatterFunction): @@ -506,7 +506,7 @@ an exception if ``value`` is not a number. def evaluate(self, formatter, kwargs, mi, locals, value): value = float(value if value and value != 'None' else 0) - return str(int(floor(value))) + return str(floor(value)) class BuiltinRound(BuiltinFormatterFunction): @@ -521,7 +521,7 @@ r''' def evaluate(self, formatter, kwargs, mi, locals, value): value = float(value if value and value != 'None' else 0) - return str(int(round(value))) + return str(round(value)) class BuiltinMod(BuiltinFormatterFunction): diff --git a/src/calibre/utils/ipc/server.py b/src/calibre/utils/ipc/server.py index 2d4ed61fb4..61b39aa566 100644 --- a/src/calibre/utils/ipc/server.py +++ b/src/calibre/utils/ipc/server.py @@ -268,7 +268,7 @@ class Server(Thread): and i is the index of the element x in the original list. ''' ans, count, pos = [], 0, 0 - delta = int(ceil(len(tasks)/float(self.pool_size))) + delta = ceil(len(tasks)/float(self.pool_size)) while count < len(tasks): section = [] for t in tasks[pos:pos+delta]: diff --git a/src/calibre/utils/matcher.py b/src/calibre/utils/matcher.py index f5ce696f07..514739e8e7 100644 --- a/src/calibre/utils/matcher.py +++ b/src/calibre/utils/matcher.py @@ -67,7 +67,7 @@ def split(tasks, pool_size): and i is the index of the element x in the original list. ''' ans, count = [], 0 - delta = int(ceil(len(tasks) / pool_size)) + delta = ceil(len(tasks) / pool_size) while tasks: section = [(count + i, task) for i, task in enumerate(tasks[:delta])] tasks = tasks[delta:] diff --git a/src/calibre/utils/short_uuid.py b/src/calibre/utils/short_uuid.py index 9b344e20b7..cb7e109fdb 100644 --- a/src/calibre/utils/short_uuid.py +++ b/src/calibre/utils/short_uuid.py @@ -38,7 +38,7 @@ class ShortUUID: self.alphabet = tuple(sorted(str(alphabet or (string.digits + string.ascii_letters)[2:]))) self.alphabet_len = len(self.alphabet) self.alphabet_map = {c:i for i, c in enumerate(self.alphabet)} - self.uuid_pad_len = int(math.ceil(math.log(1 << 128, self.alphabet_len))) + self.uuid_pad_len = math.ceil(math.log(1 << 128, self.alphabet_len)) def uuid4(self, pad_to_length=None): if pad_to_length is None: