mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
automatic fixes from ruf version 11 for spurious uses of int()
This commit is contained in:
parent
065fad39c5
commit
464b68bd98
@ -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):
|
||||
|
@ -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
|
||||
|
@ -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'
|
||||
|
@ -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:
|
||||
|
@ -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'<h[1-3][^>]*>', re.IGNORECASE)
|
||||
self.html_preprocess_sections = len(heading.findall(html))
|
||||
|
@ -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):
|
||||
|
@ -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')
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -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':
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -378,7 +378,7 @@ class Results(QWidget):
|
||||
self.current_result = 0
|
||||
prefixes = [QStaticText(f'<b>{os.path.basename(x)}</b>') 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):
|
||||
|
@ -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)
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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))
|
||||
|
@ -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):
|
||||
|
@ -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]:
|
||||
|
@ -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:]
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user