sys.maxint -> sys.maxsize

This commit is contained in:
Kovid Goyal 2019-03-27 07:21:14 +05:30
parent 4fa69111ec
commit fdc64f40ad
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
19 changed files with 30 additions and 30 deletions

View File

@ -66,7 +66,7 @@ class Plugin(object): # {{{
#: When more than one plugin exists for a filetype,
#: the plugins are run in order of decreasing priority.
#: Plugins with higher priority will be run first.
#: The highest possible priority is ``sys.maxint``.
#: The highest possible priority is ``sys.maxsize``.
#: Default priority is 1.
priority = 1

View File

@ -273,10 +273,10 @@ class KTCollectionsBookList(CollectionsBookList):
if is_series:
if doing_dc:
collections[cat_name][lpath] = \
(book, book.get('series_index', sys.maxint), tsval)
(book, book.get('series_index', sys.maxsize), tsval)
else:
collections[cat_name][lpath] = \
(book, book.get(attr+'_index', sys.maxint), tsval)
(book, book.get(attr+'_index', sys.maxsize), tsval)
else:
collections[cat_name][lpath] = (book, tsval, tsval)
if show_debug:

View File

@ -350,7 +350,7 @@ class PALADIN(USBMS):
values (?,?,?,?,?,?,?,?)
'''
t = (title, author, book.get('comments', None), int(time.time() * 1000),
book.get('series', None), book.get('series_index', sys.maxint), lpath,
book.get('series', None), book.get('series_index', sys.maxsize), lpath,
book.mime or mime_type_ext(path_to_ext(lpath)))
cursor.execute(query, t)
book.bookId = connection.last_insert_rowid()

View File

@ -256,10 +256,10 @@ class CollectionsBookList(BookList):
elif is_series:
if doing_dc:
collections[cat_name][lpath] = \
(book, book.get('series_index', sys.maxint), tsval)
(book, book.get('series_index', sys.maxsize), tsval)
else:
collections[cat_name][lpath] = \
(book, book.get(attr+'_index', sys.maxint), tsval)
(book, book.get(attr+'_index', sys.maxsize), tsval)
else:
if lpath not in collections[cat_name]:
collections[cat_name][lpath] = (book, tsval, tsval)

View File

@ -55,7 +55,7 @@ class LRFOptions(object):
self.ignore_colors = False
from calibre.ebooks.lrf import PRS500_PROFILE
self.profile = PRS500_PROFILE
self.link_levels = sys.maxint
self.link_levels = sys.maxsize
self.link_exclude = '@'
self.no_links_in_toc = True
self.disable_chapter_detection = True

View File

@ -190,7 +190,7 @@ def depth_first(root, flat, visited=set([])):
visited.add(hf)
def traverse(path_to_html_file, max_levels=sys.maxint, verbose=0, encoding=None):
def traverse(path_to_html_file, max_levels=sys.maxsize, verbose=0, encoding=None):
'''
Recursively traverse all links in the HTML file.

View File

@ -154,7 +154,7 @@ class Cell(object):
mwidth = width
return parindent + mwidth + 2
def text_block_size(self, tb, maxwidth=sys.maxint, debug=False):
def text_block_size(self, tb, maxwidth=sys.maxsize, debug=False):
ts = tb.textStyle.attrs
default_font = get_font(ts['fontfacename'], self.pts_to_pixels(ts['fontsize']))
parindent = self.pts_to_pixels(ts['parindent'])
@ -200,7 +200,7 @@ class Cell(object):
return right+3+max(parindent, 10), bottom
def text_block_preferred_width(self, tb, debug=False):
return self.text_block_size(tb, sys.maxint, debug=debug)[0]
return self.text_block_size(tb, sys.maxsize, debug=debug)[0]
def preferred_width(self, debug=False):
return ceil(max([self.text_block_preferred_width(i, debug=debug) for i in self.text_blocks]))

View File

@ -714,7 +714,7 @@ class OPF(object): # {{{
def create_manifest_item(self, href, media_type, append=False):
ids = [i.get('id', None) for i in self.itermanifest()]
id = None
for c in range(1, sys.maxint):
for c in range(1, sys.maxsize):
id = 'id%d'%c
if id not in ids:
break

View File

@ -143,7 +143,7 @@ class Jacket(Base):
def remove_existing_jacket(self):
for x in self.oeb.spine[:4]:
if XPath(JACKET_XPATH)(x.data):
self.remove_images(x, limit=sys.maxint)
self.remove_images(x, limit=sys.maxsize)
self.oeb.manifest.remove(x)
self.log('Removed existing jacket')
break

View File

@ -172,7 +172,7 @@ class Column(object):
self.elements.sort(key=lambda x: x.bottom)
self.top = self.elements[0].top
self.bottom = self.elements[-1].bottom
self.left, self.right = sys.maxint, 0
self.left, self.right = sys.maxsize, 0
for x in self:
self.left = min(self.left, x.left)
self.right = max(self.right, x.right)

View File

@ -387,7 +387,7 @@ class PdfDevice(QPaintDevice): # {{{
if m == self.PdmDepth:
return 32
if m == self.PdmNumColors:
return sys.maxint
return sys.maxsize
if m == self.PdmWidthMM:
return int(round(self.body_width * 0.35277777777778))
if m == self.PdmHeightMM:

View File

@ -92,8 +92,8 @@ class LinearGradientPattern(Dictionary):
page_rect = tuple(map(inv.map, (
QPointF(0, 0), QPointF(pixel_page_width, 0), QPointF(0, pixel_page_height),
QPointF(pixel_page_width, pixel_page_height))))
maxx = maxy = -sys.maxint-1
minx = miny = sys.maxint
maxx = maxy = -sys.maxsize-1
minx = miny = sys.maxsize
for p in page_rect:
minx, maxx = min(minx, p.x()), max(maxx, p.x())

View File

@ -214,7 +214,7 @@ file.
see_string = ''
changed_string = ''
lines = my_string.split('\n')
end_bracket_count = sys.maxint
end_bracket_count = sys.maxsize
for line in lines:
token_info = line[:16]
if token_info == 'ob<nu<open-brack':
@ -248,7 +248,7 @@ file.
bookmark_string = ''
index_string = ''
lines = my_string.split('\n')
end_bracket_count = sys.maxint
end_bracket_count = sys.maxsize
for line in lines:
token_info = line[:16]
if token_info == 'ob<nu<open-brack':
@ -335,7 +335,7 @@ file.
book_type = 0
toc_string = ''
lines = my_string.split('\n')
end_bracket_count = sys.maxint
end_bracket_count = sys.maxsize
for line in lines:
token_info = line[:16]
if token_info == 'ob<nu<open-brack':

View File

@ -188,7 +188,7 @@ class TextBlock(object):
self.font_loader, self.logger, self.opts = font_loader, logger, opts
self.in_link = False
self.link_activated = link_activated
self.max_y = self.bs.blockheight if (respect_max_y or self.bs.blockrule.lower() in ('vert-fixed', 'block-fixed')) else sys.maxint
self.max_y = self.bs.blockheight if (respect_max_y or self.bs.blockrule.lower() in ('vert-fixed', 'block-fixed')) else sys.maxsize
self.height = 0
self.peek_index = -1
@ -373,7 +373,7 @@ class Line(QGraphicsItem):
self.children = self.childItems
def start_link(self, refobj, slot):
self.current_link = [self.current_width, sys.maxint, refobj, slot]
self.current_link = [self.current_width, sys.maxsize, refobj, slot]
def end_link(self):
if self.current_link is not None:

View File

@ -249,7 +249,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
hidden_cols.remove('ondevice')
def col_pos(x):
return config_cols.index(x) if x in config_cols else sys.maxint
return config_cols.index(x) if x in config_cols else sys.maxsize
positions = {}
for i, col in enumerate((sorted(model.column_map, key=col_pos))):
positions[col] = i

View File

@ -58,7 +58,7 @@ def next_tag_boundary(block, offset, forward=True, max_lines=10000):
if not forward and boundary.offset < offset:
return block, boundary
block = block.next() if forward else block.previous()
offset = -1 if forward else sys.maxint
offset = -1 if forward else sys.maxsize
max_lines -= 1
return None, None
@ -74,11 +74,11 @@ def next_attr_boundary(block, offset, forward=True):
if not forward and boundary.offset <= offset:
return block, boundary
block = block.next() if forward else block.previous()
offset = -1 if forward else sys.maxint
offset = -1 if forward else sys.maxsize
return None, None
def find_closest_containing_tag(block, offset, max_tags=sys.maxint):
def find_closest_containing_tag(block, offset, max_tags=sys.maxsize):
''' Find the closest containing tag. To find it, we search for the first
opening tag that does not have a matching closing tag before the specified
position. Search through at most max_tags. '''
@ -180,7 +180,7 @@ def find_end_of_attribute(block, offset):
return block, boundary.offset
def find_closing_tag(tag, max_tags=sys.maxint):
def find_closing_tag(tag, max_tags=sys.maxsize):
''' Find the closing tag corresponding to the specified tag. To find it we
search for the first closing tag after the specified tag that does not
match a previous opening tag. Search through at most max_tags. '''
@ -491,7 +491,7 @@ class Smarts(NullSmarts):
if boundary.is_start and not boundary.closing and boundary.offset <= offset:
start_block, start_offset = block, boundary.offset
break
block, offset = block.previous(), sys.maxint
block, offset = block.previous(), sys.maxsize
end_block = None
if start_block is not None:
end_block, boundary = next_tag_boundary(start_block, start_offset)

View File

@ -185,7 +185,7 @@ else:
class Server(Thread):
def __init__(self, notify_on_job_done=lambda x: x, pool_size=None,
limit=sys.maxint, enforce_cpu_limit=True):
limit=sys.maxsize, enforce_cpu_limit=True):
Thread.__init__(self)
self.daemon = True
global _counter

View File

@ -98,7 +98,7 @@ def get_mx(host, verbose=0):
if verbose:
print('Find mail exchanger for', host)
answers = list(dns.resolver.query(host, 'MX'))
answers.sort(key=lambda x: int(getattr(x, 'preference', sys.maxint)))
answers.sort(key=lambda x: int(getattr(x, 'preference', sys.maxsize)))
return [str(x.exchange) for x in answers if hasattr(x, 'exchange')]

View File

@ -596,7 +596,7 @@ def option_parser(usage=_('%prog URL\n\nWhere URL is for example https://google.
parser.add_option('-r', '--max-recursions', default=1,
help=_('Maximum number of levels to recurse i.e. depth of links to follow. Default %default'),
type='int', dest='max_recursions')
parser.add_option('-n', '--max-files', default=sys.maxint, type='int', dest='max_files',
parser.add_option('-n', '--max-files', default=sys.maxsize, type='int', dest='max_files',
help=_('The maximum number of files to download. This only applies to files from <a href> tags. Default is %default'))
parser.add_option('--delay', default=0, dest='delay', type='float',
help=_('Minimum interval in seconds between consecutive fetches. Default is %default s'))